Prevent users from muting themselves

Why are users like this...
This commit is contained in:
Deukhoofd 2019-02-09 10:07:18 +01:00
parent af39acfe03
commit 7e6da01a76
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 6 additions and 3 deletions

View File

@ -202,7 +202,7 @@ namespace DeukBot4.MessageHandlers.CommandHandler
return;
}
}
var msg = await SilenceUser(user, span);
var msg = await SilenceUser(user, request.OriginalMessage.Author, span);
if (msg != null)
{
request.SendSimpleEmbed("Silence", msg);
@ -216,20 +216,23 @@ namespace DeukBot4.MessageHandlers.CommandHandler
{
var guildChannel = (IGuildChannel)request.OriginalMessage.Channel;
var user = await request.Parameters[0].AsDiscordGuildUser(guildChannel.Guild);
var msg = await SilenceUser(user, TimeSpan.FromHours(6));
var msg = await SilenceUser(user, request.OriginalMessage.Author, TimeSpan.FromHours(6));
if (msg != null)
{
request.SendSimpleEmbed("Silence", msg);
}
}
private static async Task<string> SilenceUser(IGuildUser user, TimeSpan span)
private static async Task<string> SilenceUser(IGuildUser user, IUser author, TimeSpan span)
{
if (user.Id == Program.BotId)
{
return "Stop trying to mute me.";
}
if (user.Id == author.Id)
return "You can't mute yourself...";
if (span.TotalHours > 24)
return "Can't mute for that long.";