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)); }
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)); }
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)); } }
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); }
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)); }
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)); }
public async Task ResetGuild() { await Guilds.ResetAsync(Context.Guild); await ReplyAsync(EmbedHandler.CreateSimpleEmbed(ModuleName, "Succesfully Reset Server Settings 🔃", Color.Green)); }
public async Task SendSupportMessage() => await ReplyAsync(EmbedHandler.CreateSimpleEmbed("Support 💬", $"**3PG Discord Server**: {Global.Config.DashboardURL}/support", Color.Purple));