Beispiel #1
0
        private static async Task SendCommandExecutionExceptionMessage(Exception e, ReactionContext context, ReactionCommand command)
        {
            await context.Channel.SendEmbedAsync("Something went horribly wrong trying to execute your emojicommand! I have contacted my creators to help fix this issue!", true);

            if (GuildChannelHelper.TryGetChannel(GuildChannelHelper.DebugChannelId, out SocketTextChannel channel))
            {
                EmbedBuilder embed = new EmbedBuilder();
                embed.Color = BotCore.ErrorColor;
                embed.Title = "**__Exception__**";
                embed.AddField("Command", command.Emote);
                embed.AddField("Location", context.Channel.Mention);
                embed.AddField("Message", Markdown.MultiLineCodeBlock(e.Message));
                string stacktrace;
                if (e.StackTrace.Length <= 500)
                {
                    stacktrace = e.StackTrace;
                }
                else
                {
                    stacktrace = e.StackTrace.Substring(0, 500);
                }
                embed.AddField("StackTrace", Markdown.MultiLineCodeBlock(stacktrace));
                await channel.SendMessageAsync(embed : embed.Build());
            }
            await YNBBotCore.Logger(new LogMessage(LogSeverity.Error, "CMDSERVICE", string.Format("An Exception occured while trying to execute command `/{0}`.Message: '{1}'\nStackTrace {2}", command.Emote, e.Message, e.StackTrace)));
        }
 private async Task TryInvokeChannelModeratedEvent(OnChannelModeratedDelegate eventDelegates, ChannelModerationEntry entry)
 {
     if (eventDelegates != null)
     {
         foreach (Delegate del in eventDelegates.GetInvocationList())
         {
             OnChannelModeratedDelegate deleg = del as OnChannelModeratedDelegate;
             if (deleg != null)
             {
                 try
                 {
                     await deleg(this, entry);
                 }
                 catch (Exception e)
                 {
                     await YNBBotCore.Logger(new LogMessage(LogSeverity.Error, "GML", "A channel moderated log handler threw an unhandled exception", e));
                 }
             }
         }
     }
 }