Esempio n. 1
0
        public override async Task ProcessAsync(SocketMessage message, string[] parameters)
        {
            ulong userId = message.Author.Id;

            foreach (ulong mod in UserIds.Mods)
            {
                if (userId == mod)
                {
                    // Sanity check
                    if (message.MentionedUsers.Count == 0)
                    {
                        Logger.Warning(message.Author.Username, "Failed timout command. No mentioned user.");
                        await message.Channel.SendMessageAsync("No mentioned user. kmute [user] [time]");

                        return;
                    }

                    if (parameters.Length < 2)
                    {
                        Logger.Warning(message.Author.Username, "Failed timout command. Time given.");
                        await message.Channel.SendMessageAsync("Please specify an amount of time. kmute [user] [time]");

                        return;
                    }

                    if (!int.TryParse(parameters[1], out int seconds))
                    {
                        Logger.Warning(message.Author.Username, "Failed timout command. Time for timout failed.");
                        await message.Channel.SendMessageAsync("Time requested not a number. kmute [user] [time]");

                        return;
                    }

                    await MuteUserHelper.MuteAsync(message.Channel as SocketTextChannel, message.MentionedUsers.FirstOrDefault() as SocketGuildUser, seconds);

                    return;
                }
            }

            Logger.Warning(message.Author.Username, "Tried to use mute command");
            await message.Channel.SendMessageAsync("Sorry you do not have permission to use this command");

            return;
        }
Esempio n. 2
0
        public async Task TimeoutAsync(IUser requestedUser, int minutes)
        {
            using (DiscordContext db = new DiscordContext())
            {
                ulong userId = Context.User.Id;
                if (db.Users.Where(x => x.DiscordId == userId).FirstOrDefault().Privilege == 0)
                {
                    Logger.Warning(Context.User.Username, "Failed timout command. Not enough privileges.");
                    await ReplyAsync("You're not a moderator, go away.");

                    return;
                }

                await MuteUserHelper.MuteAsync(Context.Channel as SocketTextChannel, requestedUser as SocketGuildUser, minutes);

                await BotReporting.ReportAsync(ReportColors.modCommand,
                                               (SocketTextChannel)Context.Channel,
                                               $"Timeout command by {Context.User.Username}",
                                               $"<@{Context.User.Id}> has muted <@{requestedUser.Id}> for `{minutes}` minutes.",
                                               Context.User,
                                               (SocketUser)requestedUser).ConfigureAwait(false);
            }
        }