예제 #1
0
        public async Task BanAsync([RequireBotHierarchy("ban")][RequireInvokerHierarchy("ban")] SocketGuildUser user, string prune = null, [Remainder] string reason = null)
        {
            List <Task> cmds = int.TryParse(prune, out int pruneDays)
                ? new List <Task>()
            {
                user.BanAsync(pruneDays, reason)
            }
                : new List <Task>()
            {
                user.BanAsync(0, reason)
            };

            EmbedBuilder embed = new EmbedBuilder()
                                 .WithColor(new Color(130, 0, 0))
                                 .WithDescription($"The communist spy {user.Mention} has been given the ~~ban~~ freedom hammer.");

            EmbedFieldBuilder reasonField = new EmbedFieldBuilder()
                                            .WithIsInline(false)
                                            .WithName("Reason")
                                            .WithValue($"{reason ?? "[none given]"}");

            embed.AddField(reasonField);

            cmds.AddRange(new List <Task>()
            {
                Context.Channel.SendMessageAsync(embed: embed.Build()),
                BanModLog.SendToModLogAsync(Context.User as SocketGuildUser, user, null, reason)
            });
            await Task.WhenAll(cmds);
        }
예제 #2
0
        public async Task TempBanAsync(string user, string length, string prune = null, [Remainder] string reason = null)
        {
            if (ulong.TryParse(user, out ulong userID))
            {
                SocketGuildUser u;
                if ((u = Context.Guild.GetUser(userID)) != null || !double.TryParse(length, out double days))
                {
                    await TempBanAsync(u, length, prune, reason);

                    return;
                }

                List <Task> cmds = int.TryParse(prune, out int pruneDays)
                    ? new List <Task>()
                {
                    Context.Guild.AddBanAsync(userID, pruneDays, reason)
                }
                    : new List <Task>()
                {
                    Context.Guild.AddBanAsync(userID, 0, reason)
                };

                EmbedBuilder embed = new EmbedBuilder()
                                     .WithColor(new Color(130, 0, 0))
                                     .WithDescription($"The communist spy <@{user}> shall not enter our borders for {length} {(days == 1 ? "day" : "days")}!");

                EmbedFieldBuilder reasonField = new EmbedFieldBuilder()
                                                .WithIsInline(false)
                                                .WithName("Reason")
                                                .WithValue($"{reason ?? "[none given]"}");
                embed.AddField(reasonField);

                cmds.AddRange(new List <Task>()
                {
                    Context.Channel.SendMessageAsync(embed: embed.Build()),
                    BanModLog.SendToModLogAsync(Context.User as SocketGuildUser, userID, length, reason)
                });
                await Task.WhenAll(cmds);

                await Task.Delay((int)(days * 24 * 60 * 60 * 1000));

                await Task.WhenAll
                (
                    Context.Guild.RemoveBanAsync(userID),
                    UnbanModLog.SendToModLogAsync(Context.Guild.CurrentUser, userID)
                );

                return;
            }
            await Context.Channel.SendMessageAsync("Our intelligence team has informed us that the given user does not exist.");
        }
예제 #3
0
        public async Task TempBanAsync([RequireBotHierarchy("tempban")][RequireInvokerHierarchy("tempban")] SocketGuildUser user, string length, string prune = null, [Remainder] string reason = null)
        {
            if (!double.TryParse(length, out double days))
            {
                await Context.Channel.SendMessageAsync($"Unfortunately, {length} is not a valid prison sentence length.");

                return;
            }

            List <Task> cmds = int.TryParse(prune, out int pruneDays)
                ? new List <Task>()
            {
                user.BanAsync(pruneDays, reason)
            }
                : new List <Task>()
            {
                user.BanAsync(0, reason)
            };

            EmbedBuilder embed = new EmbedBuilder()
                                 .WithColor(new Color(130, 0, 0))
                                 .WithDescription($"The communist spy {user.Mention} has been sent to Brazil for {length} {(days == 1 ? "day" : "days")}.");

            EmbedFieldBuilder reasonField = new EmbedFieldBuilder()
                                            .WithIsInline(false)
                                            .WithName("Reason")
                                            .WithValue($"{reason ?? "[none given]"}");

            embed.AddField(reasonField);

            cmds.AddRange(new List <Task>()
            {
                Context.Channel.SendMessageAsync(embed: embed.Build()),
                BanModLog.SendToModLogAsync(Context.User as SocketGuildUser, user, length, reason)
            });
            await Task.WhenAll(cmds);

            await Task.Delay((int)(days * 24 * 60 * 60 * 1000));

            await Task.WhenAll
            (
                Context.Guild.RemoveBanAsync(user),
                UnbanModLog.SendToModLogAsync(Context.Guild.CurrentUser, user)
            );
        }