Added commands for allowing bot to talk on specific channels.

This commit is contained in:
Chris Darnell committed 2021-05-09 08:36:27 -07:00
1 parent c8095f3ba6
commit c9bf08c230
1 file changed
+103 -18
+103 -18
View File
@@ -23,29 +23,114 @@ namespace StarsiegeBot
Console.WriteLine("Channel Management Module loaded.");
}
[Command("Allow")]
public async Task AllowChannels(CommandContext ctx, [Description("List of discord channels to allow the bot to respond on.")]params DiscordChannel[] discordChannels)
[Group("allow")]
class Allow
{
}
[Command("Allow")]
public async Task AllowChannels(CommandContext ctx, string discordChannels = "")
{
}
[Command("deny")]
public async Task DenyChannels(CommandContext ctx, params DiscordChannel[] discordChannels)
{
foreach (DiscordChannel chan in discordChannels)
[Command("add")]
public async Task AddAllowedChannels(CommandContext ctx, [Description("List of discord channels to allow the bot to respond on.")] params DiscordChannel[] discordChannels)
{
Console.WriteLine(chan.Id.ToString());
string gId = ctx.Guild.Id.ToString();
// string output = "Added the following channel(s) to the allow list:";
string output = "";
foreach (DiscordChannel channel in discordChannels)
{
GuildSettings[gId].AllowChannels.Add(channel.Id.ToString());
if (!GuildSettings[gId].AllowChannels.Contains(channel.Id.ToString()))
{
if (output == "")
{
output = channel.Mention;
}
else
{
output += $", {channel.Mention}";
}
}
}
if (output == "")
{
output = "There was an error adding your channel(s) to the allow list.";
}
else
{
output = "Added the following channel(s) to the allow list: " + output;
}
await ctx.RespondAsync(StartEmbed(output));
}
[Command("remove")]
public async Task RemoveAllowedChannel(CommandContext ctx, params DiscordChannel[] discordChannels)
{
string success = "";
string failed = "";
string output = "";
string gId = ctx.Guild.Id.ToString();
foreach (DiscordChannel channel in discordChannels)
{
string chanId = channel.Id.ToString();
if (GuildSettings[gId].AllowChannels.Remove(chanId))
{
if (success == "")
{
success = channel.Mention;
}
else
{
success += $", {channel.Mention}";
}
}
else
{
if (failed == "")
{
failed = channel.Mention;
}
else
{
failed += $", {channel.Mention}";
}
}
}
if (success != "")
{
output += "Successfully removed from allowed channel(s): " + success;
}
if (failed != "")
{
if (output != "") output += "\r\n";
output += "Failed to removed from allowed channel(s): " + failed;
}
await ctx.RespondAsync(StartEmbed(output));
}
}
[Command("deny")]
public async Task DenyChannels(CommandContext ctx, [Description("List of discord channels to deny the bot to respond on.")] string discordChannels = "")
{
[Group("deny")]
class Deny
{
[Command("add")]
public async Task DenyChannels(CommandContext ctx, params DiscordChannel[] discordChannels)
{
foreach (DiscordChannel chan in discordChannels)
{
Console.WriteLine(chan.Id.ToString());
}
}
}
[Command("deny")]
private static DiscordEmbedBuilder StartEmbed(string desc)
{
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = desc,
Color = Program.colours[^2]
};
return embed;
}
}
}