예제 #1
0
        public async Task UnfreezeChannel()
        {
            var textChannel = Context.Channel as SocketTextChannel;
            await textChannel.RemovePermissionOverwriteAsync(Context.Guild.EveryoneRole);

            await ReplyAsync(await EmbedHandler.CreateSimpleEmbed(ModuleName, $"🔓 Unlocked {textChannel.Mention}", ModuleColour));
        }
예제 #2
0
        public async Task FreezeChannel()
        {
            var textChannel = Context.Channel as SocketTextChannel;
            await textChannel.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, OverwritePermissions.DenyAll(Context.Channel));

            await ReplyAsync(await EmbedHandler.CreateSimpleEmbed(ModuleName, $"🔒 Locked {textChannel.Mention}", ModuleColour));
        }
예제 #3
0
        public async Task ClearMessages(int amount = 100)
        {
            try
            {
                const int max = 100;
                if (amount <= 0 || amount > max)
                {
                    throw new ArgumentException("Messages to remove must be between 1 and 100");
                }

                var messages = amount == -1 ? Context.Channel.GetMessagesAsync().FlattenAsync().Result : Context.Channel.GetMessagesAsync(amount).FlattenAsync().Result;
                var channel  = Context.Channel as SocketTextChannel;

                try { await channel.DeleteMessagesAsync(messages); }
                catch (Exception ex) { throw new InvalidOperationException(ex.Message); }

                var reply = await ReplyAsync(await EmbedHandler.CreateSimpleEmbed("Clear", $"Cleared `{messages.Count()}` messages from {channel.Mention}", Color.Blue));

                await Task.Delay(4000);

                await reply.DeleteAsync();
            }
            catch (ArgumentException ex) { await ReplyAsync(EmbedHandler.CreateErrorEmbed(ModuleName, ex.Message)); }
            catch (InvalidOperationException ex) { await ReplyAsync(EmbedHandler.CreateErrorEmbed(ModuleName, ex.Message)); }
        }
예제 #4
0
        public async Task Ping()
        {
            var ping  = new Ping();
            var embed = await EmbedHandler.CreateSimpleEmbed("Pong! 🏓",
                                                             $"**Latency:** {Global.Client.Latency}ms\n", Color.Magenta);

            await ReplyAsync(embed);
        }
예제 #5
0
        public async Task UpdateGuilds()
        {
            int count        = 0;
            int failedCount  = 0;
            var socketGuilds = Context.Client.Guilds;

            foreach (var socketGuild in socketGuilds)
            {
                try
                {
                    var guild = await Guilds.GetAsync(socketGuild);

                    guild.InitializeModules();
                    await Guilds.Save(guild);

                    count++;
                }
                catch (Exception) { failedCount++; }
            }
            await ReplyAsync(await EmbedHandler.CreateSimpleEmbed(ModuleName, $":robot: Updated `{count}`/`{count + failedCount}` servers to the latest version!", Color.Purple));
        }
예제 #6
0
        public async Task UpdateUsers()
        {
            int count         = 0;
            int failedCount   = 0;
            var allGuildUsers = Context.Client.Guilds.Select(g => g.Users);

            foreach (var guildUsers in allGuildUsers)
            {
                foreach (var guildUser in guildUsers)
                {
                    try
                    {
                        var user = await Users.GetAsync(guildUser as SocketUser);

                        user.Reinitialize();
                        await Users.Save(user);

                        count++;
                    }
                    catch (Exception) { failedCount++; }
                }
            }
            await ReplyAsync(await EmbedHandler.CreateSimpleEmbed(ModuleName, $":robot: Updated `{count}`/`{count + failedCount}` users!", Color.Purple));
        }
예제 #7
0
        public async Task ResetGuild()
        {
            await Guilds.ResetAsync(Context.Guild);

            await ReplyAsync(EmbedHandler.CreateSimpleEmbed(ModuleName, "Succesfully Reset Server Settings 🔃", Color.Green));
        }
예제 #8
0
 public async Task SendSupportMessage()
 => await ReplyAsync(EmbedHandler.CreateSimpleEmbed("Support 💬", $"**3PG Discord Server**: {Global.Config.DashboardURL}/support", Color.Purple));