Exemplo n.º 1
0
        public async Task denyUserAsync(IUser requestedUser)
        {
            using (DiscordContext db = new DiscordContext())
            {
                ulong userId = Context.User.Id;
                if (db.Users.Where(x => x.DiscordId == userId).FirstOrDefault().Privilege < User.Privileges.Moderator)
                {
                    Logger.Warning(Context.User.Username, "User tried to use deny command and failed");
                    await ReplyAsync($"You're not my real mom. Go away.");

                    return;
                }
            }

            if (Context.Channel.Id != Channels.ProvingGrounds)
            {
                await ReplyAsync("You can only use the deny command in #proving-grounds.");

                return;
            }

            await ReplyAsync($"<@{requestedUser.Id}> has been denied by <@{Context.User.Id}>.");

            await BotReporting.ReportAsync(ReportColors.modCommand,
                                           Context.Channel as SocketTextChannel,
                                           $"User denied",
                                           $"<@{Context.User.Id}> denied <@{requestedUser.Id}>",
                                           Context.User,
                                           requestedUser as SocketUser);

            await KickUserHelper.KickAsync(Context.Channel as SocketTextChannel, requestedUser as SocketGuildUser);
        }
Exemplo n.º 2
0
        public async Task KickAsync(IUser requestedUser, [Remainder] string reason = null)
        {
            using (DiscordContext db = new DiscordContext())
            {
                ulong userId = Context.User.Id;
                if (db.Users.Where(x => x.DiscordId == userId).FirstOrDefault().Privilege < User.Privileges.Moderator)
                {
                    Logger.Warning(Context.User.Username, "User tried to use kick command and failed");
                    await ReplyAsync($"No can do Jonny boy. You need moddlet for that.");

                    return;
                }

                await KickUserHelper.KickAsync(Context.Channel as SocketTextChannel, requestedUser as SocketGuildUser);

                Logger.Warning(Context.User.Username, $"Kicked {requestedUser.Username} by {Context.User.Username}");

                await BotReporting.ReportAsync(ReportColors.adminCommand,
                                               (SocketTextChannel)Context.Channel,
                                               $"Kick Command by {Context.User.Username}",
                                               $"<@{requestedUser.Id}> has been kicked",
                                               Context.User,
                                               (SocketUser)requestedUser).ConfigureAwait(false);
            }
        }
Exemplo n.º 3
0
        public async Task warnAsync(IUser requestedUser)
        {
            using (DiscordContext db = new DiscordContext())
            {
                ulong userId = Context.User.Id;
                if (db.Users.Where(x => x.DiscordId == userId).FirstOrDefault().Privilege < User.Privileges.Moderator)
                {
                    Logger.Warning(Context.User.Username, "User tried to use warn command and failed");
                    await ReplyAsync($"You wanna get warned? Cause that's how you get warned.");

                    return;
                }

                User databaseUser = db.Users.Where(x => x.DiscordId == requestedUser.Id).FirstOrDefault();

                databaseUser.WarnCount++;

                // When a user reaches 5 warns they will be kicked.
                if (databaseUser.WarnCount % 5 == 0)
                {
                    await ReplyAsync($"<@{requestedUser.Id}>, we warned you and you didn't listen. Goodbye.");

                    await KickUserHelper.KickAsync((SocketTextChannel)Context.Channel, (SocketGuildUser)requestedUser);
                }
                else
                {
                    await ReplyAsync($"<@{requestedUser.Id}> you have been warned. Current: {databaseUser.WarnCount}, get 5 and you *will* be kicked.");
                }

                db.SaveChanges();

                await BotReporting.ReportAsync(ReportColors.modCommand,
                                               (SocketTextChannel)Context.Channel,
                                               $"{Context.User.Username} used warn command",
                                               $"{Context.User.Username} warned {requestedUser.Username} in {Context.Channel.Name}.",
                                               Context.User,
                                               (SocketGuildUser)requestedUser,
                                               $"Mod ID: {Context.User.Id}");
            }
        }
Exemplo n.º 4
0
        public async Task PurgeAsync()
        {
            SocketUser author = Context.User;

            using (DiscordContext db = new DiscordContext())
            {
                if (db.Users.Where(x => x.DiscordId == author.Id).FirstOrDefault().Privilege < User.Privileges.Admin)
                {
                    Logger.Debug(author.Username, "User attempted pruge command");
                    await ReplyAsync("Do you want to start a riot? ");
                }

                await BotReporting.ReportAsync(ReportColors.adminCommand,
                                               (SocketTextChannel)Context.Channel,
                                               $"Purge Command by {Context.User.Username}",
                                               $"<@{Context.User.Id}> started a purge.",
                                               Context.User).ConfigureAwait(false);

                SocketGuildChannel     channel = Context.Channel as SocketGuildChannel;
                List <SocketGuildUser> users   = channel.Guild.Users.ToList();

                await ReplyAsync("Let the purge begin! :trumpet: ");

                Logger.Debug(author.Username, "Purging the server!");

                DateTime twoWeeksAgo = DateTime.UtcNow.AddDays(-14);

                foreach (SocketGuildUser u in users)
                {
                    User databaseUser = db.Users.Where(x => x.DiscordId == u.Id).FirstOrDefault();

                    if (databaseUser == null)
                    {
                        Logger.Warning("System", $"{u.Username} not registered!");
                        continue;
                    }

                    if (databaseUser.Privilege >= User.Privileges.Moderator)
                    {
                        Logger.Info("System", $"Skipping: {u.Username}, user is moderator or higher.");
                        continue;
                    }

                    if (u.Id == 155149108183695360 || u.Id == UserIds.Luna)
                    {
                        Logger.Info("System", $"Skipping: {u.Username}, bot");
                        continue;
                    }

                    // check if user has messaged in the past 2 weeks. Kick if false
                    if (databaseUser.LastMessage.Subtract(twoWeeksAgo).TotalDays < 0)//&& databaseUser.TutorialFinished == true)
                    {
                        Thread.Sleep(500);
                        Logger.Info("System", $"Purging:  {u.Username} for inactivity.");
                        await KickUserHelper.KickAsync(channel as SocketTextChannel, u);
                    }
                    else if (databaseUser.TutorialFinished == false)
                    {
                        Logger.Verbose("System", $"Skipping: {u.Username}, tutorial not finished.");
                    }
                    else
                    {
                        Logger.Verbose("System", $"Skipping: {u.Username}, active user.");
                    }
                }

                await ReplyAsync("Purging finished. You all, are the lucky few...");
            }
        }