Fix kick command

This commit is contained in:
Runebaas 2017-10-30 20:43:07 +01:00
parent 3d93fe1a7a
commit 9aa2b17d1c
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6

View file

@ -53,25 +53,24 @@ namespace Geekbot.net.Commands
[Command("kick", RunMode = RunMode.Async)] [Command("kick", RunMode = RunMode.Async)]
[Remarks(CommandCategories.Admin)] [Remarks(CommandCategories.Admin)]
[Summary("Ban a user")] [Summary("Ban a user")]
public async Task kick([Summary("@user")] IUser userNormal, [Summary("reason"), Remainder] string reason) public async Task kick([Summary("@user")] IUser userNormal, [Summary("reason"), Remainder] string reason = "none")
{ {
try try
{ {
var user = (IGuildUser)userNormal; var user = (IGuildUser)userNormal;
if (string.IsNullOrEmpty(reason)) if (reason == "none")
{ {
reason = "No reason provided"; reason = "No reason provided";
} }
await user.KickAsync();
await user.GetOrCreateDMChannelAsync().Result.SendMessageAsync( await user.GetOrCreateDMChannelAsync().Result.SendMessageAsync(
$"You have been kicked from {Context.Guild.Name} for the following reason: \"{reason}\""); $"You have been kicked from {Context.Guild.Name} for the following reason: \"{reason}\"");
await user.KickAsync();
try try
{ {
var modChannelId = ulong.Parse(_redis.HashGet($"{Context.Guild.Id}:Settings", "ModChannel")); var modChannelId = ulong.Parse(_redis.HashGet($"{Context.Guild.Id}:Settings", "ModChannel"));
var modChannel = (ISocketMessageChannel) _client.GetChannel(modChannelId); var modChannel = (ISocketMessageChannel) _client.GetChannel(modChannelId);
var eb = new EmbedBuilder(); var eb = new EmbedBuilder();
eb.Title = "Kicked"; eb.Title = ":x: User Kicked";
eb.AddInlineField("User", user.Username); eb.AddInlineField("User", user.Username);
eb.AddInlineField("By Mod", Context.User.Username); eb.AddInlineField("By Mod", Context.User.Username);
eb.AddField("Reason", reason); eb.AddField("Reason", reason);