diff --git a/Geekbot.net/Commands/AdminCmd.cs b/Geekbot.net/Commands/AdminCmd.cs index 060fc78..213f9cc 100644 --- a/Geekbot.net/Commands/AdminCmd.cs +++ b/Geekbot.net/Commands/AdminCmd.cs @@ -123,16 +123,10 @@ namespace Geekbot.net.Commands [Command("modchannel", RunMode = RunMode.Async)] [Remarks(CommandCategories.Admin)] [Summary("Set a channel for moderation purposes")] - public async Task selectModChannel([Summary("ChannelId")] ulong channelId) + public async Task selectModChannel([Summary("#Channel")] ISocketMessageChannel channel) { try { - var channel = (ISocketMessageChannel)_client.GetChannel(channelId); - if (string.IsNullOrEmpty(channel.Name)) - { - await ReplyAsync("I couldn't find that channel..."); - return; - } var sb = new StringBuilder(); sb.AppendLine("Successfully saved mod channel, you can now do the following"); sb.AppendLine("- `!admin showleave true` - send message to mod channel when someone leaves"); @@ -152,7 +146,7 @@ namespace Geekbot.net.Commands [Summary("Notify modchannel when someone leaves")] public async Task showLeave([Summary("true/false")] bool enabled) { - var modChannelId = (ulong)_redis.HashGet($"{Context.Guild.Id}:Settings", "ModChannel"); + var modChannelId = ulong.Parse(_redis.HashGet($"{Context.Guild.Id}:Settings", "ModChannel")); try { var modChannel = (ISocketMessageChannel) _client.GetChannel(modChannelId); @@ -179,7 +173,7 @@ namespace Geekbot.net.Commands [Summary("Notify modchannel when someone deletes a message")] public async Task showDelete([Summary("true/false")] bool enabled) { - var modChannelId = (ulong)_redis.HashGet($"{Context.Guild.Id}:Settings", "ModChannel"); + var modChannelId = ulong.Parse(_redis.HashGet($"{Context.Guild.Id}:Settings", "ModChannel")); try { var modChannel = (ISocketMessageChannel) _client.GetChannel(modChannelId); diff --git a/Geekbot.net/Commands/Role.cs b/Geekbot.net/Commands/Role.cs index 2e1939e..8be5fe6 100644 --- a/Geekbot.net/Commands/Role.cs +++ b/Geekbot.net/Commands/Role.cs @@ -69,7 +69,7 @@ namespace Geekbot.net.Commands } if (guildUser.RoleIds.Contains(roleId)) { - guildUser.RemoveRoleAsync(role); + await guildUser.RemoveRoleAsync(role); await ReplyAsync($"Removed you from {role.Name}"); return; } diff --git a/Geekbot.net/Handlers.cs b/Geekbot.net/Handlers.cs index d671c76..a98731c 100644 --- a/Geekbot.net/Handlers.cs +++ b/Geekbot.net/Handlers.cs @@ -105,10 +105,10 @@ namespace Geekbot.net var sendLeftEnabled = _redis.HashGet($"{user.Guild.Id}:Settings", "ShowLeave"); if (sendLeftEnabled.ToString() == "1") { - var modChannel = _redis.HashGet($"{user.Guild.Id}:Settings", "ModChannel"); - if (!string.IsNullOrEmpty(modChannel)) + var modChannel = ulong.Parse(_redis.HashGet($"{user.Guild.Id}:Settings", "ModChannel")); + if (!string.IsNullOrEmpty(modChannel.ToString())) { - var modChannelSocket = (ISocketMessageChannel) await _client.GetChannelAsync((ulong)modChannel); + var modChannelSocket = (ISocketMessageChannel) await _client.GetChannelAsync(modChannel); await modChannelSocket.SendMessageAsync($"{user.Username}#{user.Discriminator} left the server"); } } @@ -132,15 +132,15 @@ namespace Geekbot.net var sendLeftEnabled = _redis.HashGet($"{guild.Id}:Settings", "ShowDelete"); if (sendLeftEnabled.ToString() == "1") { - var modChannel = _redis.HashGet($"{guild.Id}:Settings", "ModChannel"); - if (!string.IsNullOrEmpty(modChannel)) + var modChannel = ulong.Parse(_redis.HashGet($"{guild.Id}:Settings", "ModChannel")); + if (!string.IsNullOrEmpty(modChannel.ToString()) && modChannel != channel.Id) { - var modChannelSocket = (ISocketMessageChannel) await _client.GetChannelAsync((ulong)modChannel); + var modChannelSocket = (ISocketMessageChannel) await _client.GetChannelAsync(modChannel); var sb = new StringBuilder(); if (message.Value != null) { sb.AppendLine( - $"{message.Value.Author.Username}#{message.Value.Author.Discriminator} deleted the following message from <#{channel.Id}>"); + $"The following message from {message.Value.Author.Username}#{message.Value.Author.Discriminator} was deleted in <#{channel.Id}>"); sb.AppendLine(message.Value.Content); } else diff --git a/Geekbot.net/Program.cs b/Geekbot.net/Program.cs index 637a8be..0a78266 100755 --- a/Geekbot.net/Program.cs +++ b/Geekbot.net/Program.cs @@ -182,7 +182,7 @@ namespace Geekbot.net return true; } - private async Task startWebApi() + private void startWebApi() { logger.Information("[API] Starting Webserver"); var webApiUrl = new Uri("http://localhost:12995");