dm users when banned, show command exceptions better
This commit is contained in:
parent
e28af98c6c
commit
a898e69b58
|
@ -73,7 +73,15 @@ namespace DeukBot4.MessageHandlers.CommandHandler
|
|||
$"User is trying to use blocked command in PM: {message.Author.Username}");
|
||||
return;
|
||||
}
|
||||
await req.Item1.Command.Invoke(req.Item1);
|
||||
|
||||
try
|
||||
{
|
||||
await req.Item1.Command.Invoke(req.Item1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await Logger.Log("An error occured: \n" + e);
|
||||
}
|
||||
break;
|
||||
case CommandRequest.RequestCode.UnknownCommand:
|
||||
var permission = await PermissionValidator.GetUserPermissionLevel(message);
|
||||
|
|
|
@ -96,6 +96,21 @@ namespace DeukBot4.MessageHandlers.CommandHandler
|
|||
reason = request.Parameters[1].AsString();
|
||||
}
|
||||
|
||||
string desc = "No reason was given.";
|
||||
if (!string.IsNullOrWhiteSpace(reason))
|
||||
{
|
||||
desc = "The given reason was: " + desc;
|
||||
}
|
||||
|
||||
var eb = new EmbedBuilder();
|
||||
eb.Color = Color.Gold;
|
||||
eb.Title = "You were banned from " + channel.Guild.Name;
|
||||
eb.Description = desc;
|
||||
eb.Author = new EmbedAuthorBuilder();
|
||||
eb.Author.Name = request.OriginalMessage.Author.Username;
|
||||
eb.Author.IconUrl = request.OriginalMessage.Author.GetAvatarUrl();
|
||||
eb.Timestamp = request.OriginalMessage.Timestamp;
|
||||
user.SendMessageAsync("", embed: eb.Build());
|
||||
// and ban
|
||||
await channel.Guild.AddBanAsync(user, 0, reason);
|
||||
await request.SendMessageAsync($"User was banned: {user.Username}");
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Discord.Net.Udp;
|
||||
|
||||
namespace DeukBot4.MessageHandlers.CommandHandler.RequestStructure
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue