From 9742614a1dc4699c1f2c69d923d402237672335d Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 26 Oct 2020 19:03:53 -0700 Subject: repo: push main from local to remote --- src/modules/commands/.todo | 52 ++ src/modules/commands/admins/config.rs | 756 +++++++++++++++++++++++++++++ src/modules/commands/admins/ignore.rs | 168 +++++++ src/modules/commands/admins/management.rs | 317 +++++++++++++ src/modules/commands/admins/mod.rs | 85 ++++ src/modules/commands/admins/premium.rs | 165 +++++++ src/modules/commands/admins/roles.rs | 160 +++++++ src/modules/commands/admins/tests.rs | 77 +++ src/modules/commands/general/animals.rs | 183 +++++++ src/modules/commands/general/fun.rs | 301 ++++++++++++ src/modules/commands/general/misc.rs | 320 +++++++++++++ src/modules/commands/general/mod.rs | 122 +++++ src/modules/commands/general/nsfw.rs | 50 ++ src/modules/commands/general/roles.rs | 278 +++++++++++ src/modules/commands/general/tags.rs | 168 +++++++ src/modules/commands/general/utilities.rs | 761 ++++++++++++++++++++++++++++++ src/modules/commands/mod.rs | 4 + src/modules/commands/mods/hackbans.rs | 117 +++++ src/modules/commands/mods/info.rs | 49 ++ src/modules/commands/mods/kickbans.rs | 97 ++++ src/modules/commands/mods/mod.rs | 80 ++++ src/modules/commands/mods/mute.rs | 179 +++++++ src/modules/commands/mods/notes.rs | 108 +++++ src/modules/commands/mods/roles.rs | 338 +++++++++++++ src/modules/commands/mods/watchlist.rs | 113 +++++ src/modules/commands/owners/log.rs | 27 ++ src/modules/commands/owners/mod.rs | 14 + src/modules/commands/owners/premium.rs | 76 +++ src/modules/mod.rs | 1 + 29 files changed, 5166 insertions(+) create mode 100644 src/modules/commands/.todo create mode 100644 src/modules/commands/admins/config.rs create mode 100644 src/modules/commands/admins/ignore.rs create mode 100644 src/modules/commands/admins/management.rs create mode 100644 src/modules/commands/admins/mod.rs create mode 100644 src/modules/commands/admins/premium.rs create mode 100644 src/modules/commands/admins/roles.rs create mode 100644 src/modules/commands/admins/tests.rs create mode 100644 src/modules/commands/general/animals.rs create mode 100644 src/modules/commands/general/fun.rs create mode 100644 src/modules/commands/general/misc.rs create mode 100644 src/modules/commands/general/mod.rs create mode 100644 src/modules/commands/general/nsfw.rs create mode 100644 src/modules/commands/general/roles.rs create mode 100644 src/modules/commands/general/tags.rs create mode 100644 src/modules/commands/general/utilities.rs create mode 100644 src/modules/commands/mod.rs create mode 100644 src/modules/commands/mods/hackbans.rs create mode 100644 src/modules/commands/mods/info.rs create mode 100644 src/modules/commands/mods/kickbans.rs create mode 100644 src/modules/commands/mods/mod.rs create mode 100644 src/modules/commands/mods/mute.rs create mode 100644 src/modules/commands/mods/notes.rs create mode 100644 src/modules/commands/mods/roles.rs create mode 100644 src/modules/commands/mods/watchlist.rs create mode 100644 src/modules/commands/owners/log.rs create mode 100644 src/modules/commands/owners/mod.rs create mode 100644 src/modules/commands/owners/premium.rs create mode 100644 src/modules/mod.rs (limited to 'src/modules') diff --git a/src/modules/commands/.todo b/src/modules/commands/.todo new file mode 100644 index 0000000..487377b --- /dev/null +++ b/src/modules/commands/.todo @@ -0,0 +1,52 @@ +Key: + * - Basically in. + / - Maybe... + +Commands: + Anime: + - [/] Darling + - [*] Waifu + Bot: + - [*] Donate + - [*] Suggest + Emma: + - [/] Fan Art + - [/] Ugly Cat + - [/] Verify + Fun: + - [/] Advice + - [/] Date Fact + - [/] Day Fact + - [/] FML + - [/] Fact + - [/] GitHub Zen + - [/] Insult + - [/] Minecraft Server Status + - [/] Number Fact + - [/] Onion + - [/] Spoiler + - [/] Year Fact + Moderation: + - [ ] Slow-mode + NSFW: + - [ ] Danbooru + - [ ] Gelbooru + - [ ] Rule 34 + Management: + - [ ] DM + - [/] Database + - [/] IP + - [ ] Leave Server + - [ ] Reload + - [/] Server Count + - [/] Status + - [/] Username + Reaction: + - [/] List + - [/] New + - [/] Remove + Server: + - [ ] Goodbye + - [ ] Oldest Member + - [/] Poll + - [ ] Random Member diff --git a/src/modules/commands/admins/config.rs b/src/modules/commands/admins/config.rs new file mode 100644 index 0000000..a26fc3d --- /dev/null +++ b/src/modules/commands/admins/config.rs @@ -0,0 +1,756 @@ +use crate::core::colours; +use crate::core::consts::*; +use crate::core::consts::DB as db; +use crate::core::utils::*; +use serenity::framework::standard::{ + Args, + Command, + CommandError, + CommandOptions +}; +use serenity::model::channel::Message; +use serenity::model::Permissions; +use serenity::prelude::Context; +use std::sync::Arc; + +pub struct ConfigRaw; +impl Command for ConfigRaw { + fn options(&self) -> Arc { + let default = CommandOptions::default(); + let options = CommandOptions { + desc: Some("Oh, you want it, raw...".to_string()), + required_permissions: Permissions::MANAGE_GUILD, + ..default + }; + Arc::new(options) + } + + fn execute(&self, _: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> { + if let Some(guild_id) = message.guild_id { + let guild_data = db.get_guild(guild_id.0 as i64)?; + message.channel_id.say(format!("{:?}", guild_data))?; + } else { + failed!(GUILDID_FAIL); + } + Ok(()) + } +} + +pub struct ConfigList; +impl Command for ConfigList { + fn options(&self) -> Arc { + let default = CommandOptions::default(); + let options = CommandOptions { + desc: Some("Yeah, sure, here's my config.".to_string()), + required_permissions: Permissions::MANAGE_GUILD, + ..default + }; + Arc::new(options) + } + + fn execute(&self, _: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> { + if let Some(guild_id) = message.guild_id { + let guild_data = db.get_guild(guild_id.0 as i64)?; + message.channel_id.send_message(|m| m + .embed(|e| e + .colour(*colours::MAIN) + .description(format!("{}", guild_data)) + ))?; + } else { + failed!(GUILDID_FAIL); + } + Ok(()) + } +} + +pub struct ConfigPrefix; +impl Command for ConfigPrefix { + fn options(&self) -> Arc { + let default = CommandOptions::default(); + let options = CommandOptions { + desc: Some("Change it, go ahead.".to_string()), + usage: Some("".to_string()), + example: Some("!!".to_string()), + min_args: Some(1), + max_args: Some(1), + required_permissions: Permissions::MANAGE_GUILD, + ..default + }; + Arc::new(options) + } + + fn execute(&self, _: &mut Context, message: &Message, mut args: Args) -> Result<(), CommandError> { + if let Some(guild_id) = message.guild_id { + let mut guild_data = db.get_guild(guild_id.0 as i64)?; + let pre = args.single::()?; + guild_data.prefix = pre; + match db.update_guild(guild_id.0 as i64, guild_data) { + Ok(guild) => { + message.channel_id.say(format!("Set prefix to {}", guild.prefix))?; + }, + Err(_) => { + message.channel_id.say("Failed to change prefix")?; + }, + } + } else { + failed!(GUILDID_FAIL); + } + Ok(()) + } +} + +pub struct ConfigAutorole; +impl Command for ConfigAutorole { + fn options(&self) -> Arc { + let default = CommandOptions::default(); + let options = CommandOptions { + desc: Some("Want to mess with my auto-role settings ? (A role must be provided for `add` or `remove`.)".to_string()), + usage: Some(" ".to_string()), + example: Some("add member".to_string()), + min_args: Some(1), + required_permissions: Permissions::MANAGE_GUILD, + ..default + }; + Arc::new(options) + } + + fn execute(&self, _: &mut Context, message: &Message, mut args: Args) -> Result<(), CommandError> { + if let Some(guild_id) = message.guild_id { + let mut guild_data = db.get_guild(guild_id.0 as i64)?; + let op = args.single::().unwrap_or(String::new()); + let mut val = args.rest().to_string(); + match op.to_lowercase().as_str() { + "add" => { + match parse_role(val.to_string(), guild_id) { + Some((role_id, role)) => { + guild_data.autoroles.push(role_id.0 as i64); + val = format!("{} ({})", role.name, role_id.0); + }, + None => { + message.channel_id.say("I couldn't find that role.")?; + return Ok(()) + }, + } + }, + "remove" => { + match parse_role(val.to_string(), guild_id) { + Some((role_id, role)) => { + guild_data.autoroles.retain(|e| *e != role_id.0 as i64); + val = format!("{} ({})", role.name, role_id.0); + }, + None => { + message.channel_id.say("I couldn't find that role.")?; + return Ok(()) + }, + } + }, + "enable" => { + guild_data.autorole = true; + }, + "disable" => { + guild_data.autorole = false; + }, + _ => { + message.channel_id.say("I didn't understand that option. Valid options are: `add`, `remove`, `enable`, `disable`. For more information see `help config autorole`")?; + return Ok(()) + }, + } + let guild = db.update_guild(guild_id.0 as i64, guild_data)?; + message.channel_id.send_message(|m| m + .embed(|e| e + .title("Config Autorole Summary") + .colour(*colours::MAIN) + .description(format!("**Operation:** {}\n**Value:** {}", + op, + if val.is_empty() { guild.autorole.to_string() } else { val } , + )) + ))?; + } else { + failed!(GUILDID_FAIL); + } + Ok(()) + } +} + +pub struct ConfigAdmin; +impl Command for ConfigAdmin { + fn options(&self) -> Arc { + let default = CommandOptions::default(); + let options = CommandOptions { + desc: Some("Who do you want me to consider an admin ?".to_string()), + usage: Some(" ".to_string()), + example: Some("add admin".to_string()), + min_args: Some(2), + required_permissions: Permissions::MANAGE_GUILD, + ..default + }; + Arc::new(options) + } + + fn execute(&self, _: &mut Context, message: &Message, mut args: Args) -> Result<(), CommandError> { + if let Some(guild_id) = message.guild_id { + let mut guild_data = db.get_guild(guild_id.0 as i64)?; + let op = args.single::().unwrap_or(String::new()); + let mut val = args.rest().to_string(); + match op.to_lowercase().as_str() { + "add" => { + match parse_role(val.to_string(), guild_id) { + Some((role_id, role)) => { + guild_data.admin_roles.push(role_id.0 as i64); + val = format!("{} ({})", role.name, role_id.0); + }, + None => { + message.channel_id.say("I couldn't find that role.")?; + return Ok(()) + }, + } + }, + "remove" => { + match parse_role(val.to_string(), guild_id) { + Some((role_id, role)) => { + guild_data.admin_roles.retain(|e| *e != role_id.0 as i64); + val = format!("{} ({})", role.name, role_id.0); + }, + None => { + message.channel_id.say("I couldn't find that role.")?; + return Ok(()) + }, + } + }, + _ => { + message.channel_id.say("I didn't understand that option. Valid options are: `add`, `remove`. For more information see `help config admin`")?; + return Ok(()) + }, + } + db.update_guild(guild_id.0 as i64, guild_data)?; + message.channel_id.send_message(|m| m + .embed(|e| e + .title("Config Admin Summary") + .colour(*colours::MAIN) + .description(format!("**Operation:** {}\n**Value:** {}", + op, + val, + )) + ))?; + } else { + failed!(GUILDID_FAIL); + } + Ok(()) + } +} + +pub struct ConfigMod; +impl Command for ConfigMod { + fn options(&self) -> Arc { + let default = CommandOptions::default(); + let options = CommandOptions { + desc: Some("Welcome to moderation !".to_string()), + usage: Some(" ".to_string()), + example: Some("add staff".to_string()), + min_args: Some(2), + required_permissions: Permissions::MANAGE_GUILD, + ..default + }; + Arc::new(options) + } + + fn execute(&self, _: &mut Context, message: &Message, mut args: Args) -> Result<(), CommandError> { + if let Some(guild_id) = message.guild_id { + let mut guild_data = db.get_guild(guild_id.0 as i64)?; + let op = args.single::().unwrap_or(String::new()); + let mut val = args.rest().to_string(); + match op.to_lowercase().as_str() { + "add" => { + match parse_role(val.to_string(), guild_id) { + Some((role_id, role)) => { + guild_data.mod_roles.push(role_id.0 as i64); + val = format!("{} ({})", role.name, role_id.0); + }, + None => { + message.channel_id.say("I couldn't find that role.")?; + return Ok(()) + }, + } + }, + "remove" => { + match parse_role(val.to_string(), guild_id) { + Some((role_id, role)) => { + guild_data.mod_roles.retain(|e| *e != role_id.0 as i64); + val = format!("{} ({})", role.name, role_id.0); + }, + None => { + message.channel_id.say("I couldn't find that role.")?; + return Ok(()) + }, + } + }, + _ => { + message.channel_id.say("I didn't understand that option. Valid options are: `add`, `remove`. For more information see `help config mod`")?; + return Ok(()) + }, + } + db.update_guild(guild_id.0 as i64, guild_data)?; + message.channel_id.send_message(|m| m + .embed(|e| e + .title("Config Mod Summary") + .colour(*colours::MAIN) + .description(format!("**Operation:** {}\n**Value:** {}", + op, + val, + )) + ))?; + } else { + failed!(GUILDID_FAIL); + } + Ok(()) + } +} + +pub struct ConfigAudit; +impl Command for ConfigAudit { + fn options(&self) -> Arc { + let default = CommandOptions::default(); + let options = CommandOptions { + desc: Some("Amping up security around here ? Change audit log settings. (A channel must be provided for `channel`.)".to_string()), + usage: Some(" ".to_string()), + example: Some("channel #audit-logs".to_string()), + min_args: Some(1), + required_permissions: Permissions::MANAGE_GUILD, + ..default + }; + Arc::new(options) + } + + fn execute(&self, _: &mut Context, message: &Message, mut args: Args) -> Result<(), CommandError> { + if let Some(guild_id) = message.guild_id { + let mut guild_data = db.get_guild(guild_id.0 as i64)?; + let op = args.single::().unwrap_or(String::new()); + let mut val = args.rest().to_string(); + match op.to_lowercase().as_str() { + "enable" => { + guild_data.audit = true; + }, + "disable" => { + guild_data.audit = false; + }, + "channel" => { + match parse_channel(val.to_string(), guild_id) { + Some((channel_id, channel)) => { + guild_data.audit_channel = channel_id.0 as i64; + val = format!("{} ({})", channel.name, channel_id.0); + }, + None => { + message.channel_id.say("I couldn't find that channel.")?; + return Ok(()) + }, + } + }, + "threshold" => { + match val.parse::() { + Ok(th) => { + guild_data.audit_threshold = th; + val = th.to_string(); + }, + Err(_) => { message.channel_id.say("Please input a number as the threshold")?; } + } + }, + _ => { + message.channel_id.say("I didn't understand that option. Valid options are: `enable`, `disable`, `channel`, `threshold`. For more information see `help config audit`")?; + return Ok(()) + }, + } + let guild = db.update_guild(guild_id.0 as i64, guild_data)?; + message.channel_id.send_message(|m| m + .embed(|e| e + .title("Config Audit Summary") + .colour(*colours::MAIN) + .description(format!("**Operation:** {}\n**Value:** {}", + op, + if val.is_empty() { format!("{}", guild.audit) } else { val }, + )) + ))?; + } else { + failed!(GUILDID_FAIL); + } + Ok(()) + } +} + +pub struct ConfigModlog; +impl Command for ConfigModlog { + fn options(&self) -> Arc { + let default = CommandOptions::default(); + let options = CommandOptions { + desc: Some("Moderation log settings, move along. (A channel must be provided for `channel`.)".to_string()), + usage: Some(" ".to_string()), + example: Some("channel #mod-logs".to_string()), + min_args: Some(1), + required_permissions: Permissions::MANAGE_GUILD, + ..default + }; + Arc::new(options) + } + + fn execute(&self, _: &mut Context, message: &Message, mut args: Args) -> Result<(), CommandError> { + if let Some(guild_id) = message.guild_id { + let mut guild_data = db.get_guild(guild_id.0 as i64)?; + let op = args.single::().unwrap_or(String::new()); + let mut val = args.rest().to_string(); + match op.to_lowercase().as_str() { + "enable" => { + guild_data.modlog = true; + }, + "disable" => { + guild_data.modlog = false; + }, + "channel" => { + match parse_channel(val.to_string(), guild_id) { + Some((channel_id, channel)) => { + guild_data.modlog_channel = channel_id.0 as i64; + val = format!("{} ({})", channel.name, channel_id.0); + }, + None => { + message.channel_id.say("I couldn't find that channel.")?; + return Ok(()) + }, + } + }, + _ => { + message.channel_id.say("I didn't understand that option. Valid options are: `enable`, `disable`, `channel`. For more information see `help config modlog`")?; + return Ok(()) + }, + } + let guild = db.update_guild(guild_id.0 as i64, guild_data)?; + message.channel_id.send_message(|m| m + .embed(|e| e + .title("Config Modlog Summary") + .colour(*colours::MAIN) + .description(format!("**Operation:** {}\n**Value:** {}", + op, + if val.is_empty() { guild.modlog.to_string() } else { val }, + )) + ))?; + } else { + failed!(GUILDID_FAIL); + } + Ok(()) + } +} + +pub struct ConfigWelcome; +impl Command for ConfigWelcome { + fn options(&self) -> Arc { + let default = CommandOptions::default(); + let options = CommandOptions { + // desc: Some("Change welcome message settings.\nOption is one of enable, disable, channel, message, type and the respective values should be none, none, channel_resolvable, desired message.\nType designates if the message is plain or embed. Anything other than embed will result in plain.".to_string()), + desc: Some("Want a sick, custom welcome message !?\n\nOptions:\n`enable` - none.\n`disable` - none.\n`channel` - `channel_resolvable` (Mentionable).\n`message` - Your desired welcome message.\n`type` - `plain` or `embed`.".to_string()), + usage: Some("