示例#1
0
        private async Task GuildLeaveLog(SocketGuild guild)
        {
            var logChannel = _client.GetChannel(647167484616769566) as SocketTextChannel;

            var embed = new Discord.EmbedBuilder()
            {
                Title = "📤 Left guild 📤",
                Color = Discord.Color.Red
            };

            embed.AddField("Name", guild.Name, true);
            embed.AddField("ID", guild.Id, true);
            embed.WithFooter($"Now in {_client.Guilds.Count.ToString()} guilds.");
            embed.WithCurrentTimestamp();

            //await logChannel.SendMessageAsync($"📤 Left guild \"{guild.Name}\" (`{guild.Id}`). Now in {_client.Guilds.Count.ToString()} guilds.");
            await logChannel.SendMessageAsync("", embed : embed.Build());
        }
示例#2
0
        public async Task OnCommandExecutedAsync(Optional <CommandInfo> command, ICommandContext context, IResult result)
        {
            if (!string.IsNullOrWhiteSpace(result?.ErrorReason) && result.Error != CommandError.UnknownCommand /*&& result.Error != CommandError.UnmetPrecondition && result.Error != CommandError.ParseFailed && result.Error != CommandError.BadArgCount*/)
            {
                var errorEmbed = new Discord.EmbedBuilder()
                {
                    Title       = "Error",
                    Description = result.ErrorReason,
                    Color       = Discord.Color.Red
                };
                errorEmbed.WithCurrentTimestamp();
                errorEmbed.WithFooter("If you think this is a bug, please report it in the #support channel in our server (~support).");
                await context.Channel.SendMessageAsync("", embed : errorEmbed.Build());
                await Log(new LogMessage(LogSeverity.Error, "Command", $"A command errored. Message: [{context.Message.Content}] | Error reason: [{result.ErrorReason}] | Guild: [{context.Guild.Name} ({context.Guild.Id})]"));

                return;
            }

            var commandName = command.IsSpecified ? command.Value.Name : "Unknown Command";

            await Log(new LogMessage(LogSeverity.Info, "Command", $"A command executed successfully. Message: [{context.Message.Content}] | Command: [{commandName}] | Guild: [{context.Guild.Name} ({context.Guild.Id})]"));
        }
示例#3
0
        public async Task LogCommand(ICommandContext context, IResult result)
        {
            if (_client.GetChannel(LogChannel) is SocketTextChannel channel)
            {
                var embedBuilder = new EmbedBuilder
                {
                    Color = result.IsSuccess ? new Color(10, 200, 10) : new Color(200, 10, 10),
                };

                embedBuilder.AddField(f =>
                {
                    f.Name  = "Guild:";
                    f.Value = $"**Name:** {context.Guild.Name} \n" +
                              $"**Id:** {context.Guild.Id}";
                    f.IsInline = true;
                });
                embedBuilder.AddField(f =>
                {
                    f.Name  = "Channel:";
                    f.Value = $"**Name:** {context.Channel.Name} \n" +
                              $"**Id:** {context.Channel.Id}";
                    f.IsInline = true;
                });
                embedBuilder.AddField(f =>
                {
                    f.Name  = "Content:";
                    f.Value = context.Message.Content;
                });
                embedBuilder.AddField(f =>
                {
                    f.Name  = "Result:";
                    f.Value = result.ToString();
                });

                embedBuilder.WithCurrentTimestamp();
                await channel.SendMessageAsync("A command has been called!", false, embedBuilder.Build());
            }
        }