private async Task HandleUserJoined(SocketGuildUser arg) { var roles = await _autoRoleServices.TakeAutoRolesAsync(arg.Guild); if (roles.Count > 0) { await arg.AddRolesAsync(roles); } var channelId = await _serverServices.GetWelcomeAsync(arg.Guild.Id); if (channelId == 0) { return; } var channel = arg.Guild.GetTextChannel(channelId); if (channel == null) { await _serverServices.ClearWelcomeAsync(arg.Guild.Id); return; } var background = await _serverServices.GetBackgroundAsync(arg.Guild.Id); string path = await _images.CreateImageAsync(arg, background); await channel.SendFileAsync(path, null); System.IO.File.Delete(path); }
public async Task Welcome(string option = null, string value = null) { if (option == null && value == null) { var fetchedChannelId = await _serverServices.GetWelcomeAsync(Context.Guild.Id); if (fetchedChannelId == 0) { await ReplyAsync("There has not been set a welcome channel yet!"); return; } var fetchedChannel = Context.Guild.GetTextChannel(fetchedChannelId); if (fetchedChannel == null) { await ReplyAsync("There has not been set a welcome channel yet!"); await _serverServices.ClearWelcomeAsync(Context.Guild.Id); return; } var fetchedBackground = await _serverServices.GetBackgroundAsync(Context.Guild.Id); if (fetchedBackground != null) { await ReplyAsync($"The channel used for the welcome module is{fetchedChannel.Mention}.\n The background is set to {fetchedBackground}. "); } else { await ReplyAsync($"The channel used for the welcome module is{fetchedChannel.Mention}."); } return; } if (option == "channel" && value != null) { if (!MentionUtils.TryParseChannel(value, out ulong parseId)) { await ReplyAsync("Please pass in a valid channel!"); return; } var parsedChannel = Context.Guild.GetTextChannel(parseId); if (parsedChannel == null) { await ReplyAsync("Please pass in a valid channel!"); return; } await _serverServices.ModifyWelcomeAsync(Context.Guild.Id, parseId); await ReplyAsync($"Successfully modified the welcome channel to {parsedChannel.Mention}."); return; } if (option == "background" && value != null) { if (value == "clear") { await _serverServices.ClearBackgroundAsync(Context.Guild.Id); await ReplyAsync("Successfully cleared the background for this server."); return; } await _serverServices.ModifyBackgroundAsync(Context.Guild.Id, value); await ReplyAsync($"Successfully modified the background to {value}."); return; } if (option == "clear" && value == null) { await _serverServices.ClearWelcomeAsync(Context.Guild.Id); await ReplyAsync("Successfully cleared the welcome channel."); return; } await ReplyAsync("Wrong command options!"); }