public async Task SetChannelType( [Summary("channel type")] string channelType = null, [Summary("channel (current channel if unspecified)")] Discord.IChannel channel = null) { if (channel == null) { channel = (IChannel)Context.Channel; } if (CHANNEL_TYPES.Contains(channelType)) { if (TryLinkChannelType(channelType, channel, Context.Guild)) { await Context.Channel.SendMessageAsync($"Channel updated! Set {channelType} to <#{channel.Id}>"); } else { await Context.Channel.SendMessageAsync($"Unable to set {channelType} to <#{channel.Id}>"); } } else { EmbedBuilder builder = new EmbedBuilder() { Description = $"💾 Accepted channel types: ```{string.Join(", ", CHANNEL_TYPES)}```", Color = Color.Magenta }; await Context.Channel.SendMessageAsync("", false, builder.Build()); } }
public async Task Channel([Summary("Channel (eg #alerts)")] Discord.IChannel channel) { CheckServerEntryExists(Context.Guild.Id); var ServerConfig = _floofDB.NicknameAlertConfigs.Find(Context.Guild.Id); ServerConfig.Channel = channel.Id; _floofDB.SaveChanges(); await Context.Channel.SendMessageAsync("Channel updated! I will send nickname alerts to <#" + channel.Id + ">"); }
public async Task Channel([Summary("Channel (eg #errors)")] Discord.IChannel channel = null) { if (channel == null) { channel = (IChannel)Context.Channel; } var ServerConfig = GetServerConfig(Context.Guild.Id); ServerConfig.ChannelId = channel.Id; _floofDB.SaveChanges(); await Context.Channel.SendMessageAsync("Channel updated! I will send fatal errors to <#" + channel.Id + ">"); }
public async Task ModChannel([Summary("Channel (eg #alerts)")] Discord.IChannel channel = null) { if (channel == null) { channel = Context.Channel; } var ServerConfig = GetServerConfig(Context.Guild.Id); ServerConfig.ModChannelId = channel.Id; _floofDB.SaveChanges(); await Context.Channel.SendMessageAsync("Channel updated! I will raid notifications to <#" + channel.Id + ">"); }
private bool TryLinkChannelType(string channelType, Discord.IChannel channel, Discord.IGuild guild) { ulong serverId = guild.Id; ulong channelId = channel == null ? 0 : channel.Id; AddServerIfNotExists(serverId); try { string updateCommand = $"UPDATE LogConfigs SET {channelType} = {channelId} WHERE ServerID = {serverId}"; _floofDB.Database.ExecuteSqlRaw(updateCommand); _floofDB.SaveChanges(); return(true); } catch (Exception e) { string errorMsg = $"Error: Unable to link {channelType} to <#{channelId}>"; Log.Error(errorMsg + Environment.NewLine + e); return(false); } }