示例#1
0
        public async Task EnableRaidRecovery()
        {
            if (Context.Channel is SocketTextChannel channel)
            {
                if (!RaidRecoveryTracker.Track(Context.Channel.Id, Context.User.Id, channel.SlowModeInterval))
                {
                    ulong?startedBy = RaidRecoveryTracker.StartedBy(Context.Channel.Id);

                    if (startedBy.HasValue)
                    {
                        await BetterReplyAsync($"Raid recovery system is already enabled. Enabled by {BetterUserFormat(UserFromUserId(startedBy.Value))}.");

                        return;
                    }
                    else
                    {
                        await BetterReplyAsync($"Raid recovery system is already enabled.");

                        return;
                    }
                }

                await channel.ModifyAsync(x => { x.SlowModeInterval = 120; });
            }
            else
            {
                await BetterReplyAsync("Invalid channel, not a text only channel.");

                return;
            }

            EmbedBuilder builder = new EmbedBuilder()
            {
                Color       = new Color(Constants.GeneralColor.R, Constants.GeneralColor.G, Constants.GeneralColor.B),
                Title       = "Raid Recovery System Enabled",
                Description = "This channel is now in slow mode, normal users can only send one message every two minutes."
            };

            builder.AddField("Commands", string.Join(Environment.NewLine, new string[] {
                $"Commands are used `@{Context.Guild.CurrentUser.Username} rr <command>`",
                "`disable` Disable raid recovery system",
                "`list <minutes>` List suspected users from the past # minutes",
                "`clean <minutes>` Remove messages from suspected users from the past # minutes",
                "`ban <minutes>` Ban suspected users in the past # minutes, will prompt for confirmation"
            }));

            LoggingManager.Log.Warn($"Raid recovery system enabled. {BetterLogFormat()}");
            await BetterReplyAsync(builder.Build());
            await LogMessageEmbedAsync("Raid recovery system enabled");
        }