Exemple #1
0
        public async Task <RuntimeResult> OBanAsync(ulong name, [Remainder] string reason = null)
        {
            if (CommandHandler.FeatureFlagDisabled(FeatureFlag.MODERATION))
            {
                return(CustomResult.FromIgnored());
            }
            var banLogChannel = Context.Guild.GetTextChannel(Global.PostTargets[PostTarget.BAN_LOG]);
            await Context.Guild.AddBanAsync(name, 0, reason);

            MuteTimerManager.UnMuteUserCompletely(name);


            if (reason == null)
            {
                reason = "No reason provided.";
            }

            var banMessage = new EmbedBuilder()
                             .WithColor(9896005)
                             .WithTitle("⛔️ Banned User")
                             .AddField("UserId", name, true)
                             .AddField("By", Extensions.FormatUserNameDetailed(Context.User), true)
                             .AddField("Reason", reason)
                             .AddField("Link", Extensions.FormatLinkWithDisplay("Jump!", Context.Message.GetJumpUrl()));

            await banLogChannel.SendMessageAsync(embed : banMessage.Build());

            return(CustomResult.FromSuccess());
        }
Exemple #2
0
        public async Task <RuntimeResult> OBanAsync(ulong name, [Remainder] string reason = null)
        {
            var modlog = Context.Guild.GetTextChannel(Global.Channels["modlog"]);
            await Context.Guild.AddBanAsync(name, 0, reason);

            MuteTimerManager.UnMuteUserCompletely(name);

            return(CustomResult.FromSuccess());
        }
Exemple #3
0
        public async Task <RuntimeResult> BanAsync(IGuildUser user, [Remainder] string reason = null)
        {
            if (CommandHandler.FeatureFlagDisabled(FeatureFlag.MODERATION))
            {
                return(CustomResult.FromIgnored());
            }
            if (user.IsBot)
            {
                return(CustomResult.FromError("You can't ban bots."));
            }


            if (user.GuildPermissions.PrioritySpeaker)
            {
                return(CustomResult.FromError("You can't ban staff."));
            }


            if (reason == null)
            {
                reason = "No reason provided.";
            }
            try
            {
                try
                {
                    const string banDMMessage = "You were banned on r/OnePlus for the following reason: {0}\n" +
                                                "If you believe this to be a mistake, please send an appeal e-mail with all the details to [email protected]";
                    await user.SendMessageAsync(string.Format(banDMMessage, reason));
                } catch (HttpException) {
                    await Context.Channel.SendMessageAsync("Seems like user disabled DMs, cannot send message about the ban.");
                }

                await Context.Guild.AddBanAsync(user, 0, reason);

                MuteTimerManager.UnMuteUserCompletely(user.Id);

                var banLogChannel = Context.Guild.GetTextChannel(Global.PostTargets[PostTarget.BAN_LOG]);
                var banlog        = new EmbedBuilder()
                                    .WithColor(9896005)
                                    .WithTitle("⛔️ Banned User")
                                    .AddField("User", Extensions.FormatUserNameDetailed(user), true)
                                    .AddField("By", Extensions.FormatUserNameDetailed(Context.User), true)
                                    .AddField("Reason", reason)
                                    .AddField("Link", Extensions.FormatLinkWithDisplay("Jump!", Context.Message.GetJumpUrl()));

                await banLogChannel.SendMessageAsync(embed : banlog.Build());

                return(CustomResult.FromSuccess());
            }
            catch (Exception ex)
            {
                //  may not be needed
                // await Context.Guild.AddBanAsync(user, 0, reason);
                return(CustomResult.FromError(ex.Message));
            }
        }
        public async Task <RuntimeResult> KickAsync(IGuildUser user, [Remainder] string reason = null)
        {
            if (user.IsBot)
            {
                return(CustomResult.FromError("You can't kick bots."));
            }


            if (user.GuildPermissions.PrioritySpeaker)
            {
                return(CustomResult.FromError("You can't kick staff."));
            }

            await user.KickAsync(reason);

            MuteTimerManager.UnMuteUserCompletely(user.Id);
            return(CustomResult.FromSuccess());
        }
        public async Task <RuntimeResult> OBanAsync(ulong name, [Remainder] string reason = null)
        {
            var banLogChannel = Context.Guild.GetTextChannel(Global.PostTargets[PostTarget.BAN_LOG]);
            await Context.Guild.AddBanAsync(name, 0, reason);

            MuteTimerManager.UnMuteUserCompletely(name);


            if (reason == null)
            {
                reason = "No reason provided.";
            }

            var modlog     = Context.Guild.GetTextChannel(Global.Channels["banlog"]);
            var banMessage = new EmbedBuilder()
                             .WithColor(9896005)
                             .WithTitle("⛔️ Banned User")
                             .AddField(efb => efb
                                       .WithName("UserId")
                                       .WithValue(name)
                                       .WithIsInline(true))
                             .AddField(efb => efb
                                       .WithName("By")
                                       .WithValue(Extensions.FormatUserName(Context.User))
                                       .WithIsInline(true))
                             .AddField(efb => efb
                                       .WithName("Reason")
                                       .WithValue(reason))
                             .AddField(efb => efb
                                       .WithName("Link")
                                       .WithValue(Extensions.GetMessageUrl(Global.ServerID, Context.Channel.Id, Context.Message.Id, "Jump!")));

            await banLogChannel.SendMessageAsync(embed : banMessage.Build());

            return(CustomResult.FromSuccess());
        }
        public async Task <RuntimeResult> BanAsync(IGuildUser user, [Remainder] string reason = null)
        {
            if (user.IsBot)
            {
                return(CustomResult.FromError("You can't ban bots."));
            }


            if (user.GuildPermissions.PrioritySpeaker)
            {
                return(CustomResult.FromError("You can't ban staff."));
            }


            if (reason == null)
            {
                reason = "No reason provided.";
            }
            try
            {
                try
                {
                    const string banDMMessage = "You were banned on r/OnePlus for the following reason: {0}\n" +
                                                "If you believe this to be a mistake, please send an appeal e-mail with all the details to [email protected]";
                    await user.SendMessageAsync(string.Format(banDMMessage, reason));
                } catch (HttpException) {
                    Console.WriteLine("User disabled DMs, unable to send message about ban.");
                }

                await Context.Guild.AddBanAsync(user, 0, reason);

                MuteTimerManager.UnMuteUserCompletely(user.Id);

                var banLogChannel = Context.Guild.GetTextChannel(Global.PostTargets[PostTarget.BAN_LOG]);
                var banlog        = new EmbedBuilder()
                                    .WithColor(9896005)
                                    .WithTitle("⛔️ Banned User")
                                    .AddField(efb => efb
                                              .WithName("User")
                                              .WithValue(Extensions.FormatUserNameDetailed(user))
                                              .WithIsInline(true))
                                    .AddField(efb => efb
                                              .WithName("By")
                                              .WithValue(Extensions.FormatUserName(Context.User))
                                              .WithIsInline(true))
                                    .AddField(efb => efb
                                              .WithName("Reason")
                                              .WithValue(reason))
                                    .AddField(efb => efb
                                              .WithName("Link")
                                              .WithValue(Extensions.GetMessageUrl(Global.ServerID, Context.Channel.Id, Context.Message.Id, "Jump!")));

                await banLogChannel.SendMessageAsync(embed : banlog.Build());

                return(CustomResult.FromSuccess());
            }
            catch (Exception ex)
            {
                //  may not be needed
                // await Context.Guild.AddBanAsync(user, 0, reason);
                return(CustomResult.FromError(ex.Message));
            }
        }