diff options
| author | Fuwn <[email protected]> | 2020-10-27 13:46:50 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2020-10-27 13:46:50 -0700 |
| commit | 7df153d4dd8279d1187deb8ad7cd90813cae153b (patch) | |
| tree | 2a5258b4eff8c79b0e349eaa15154b0b6ea1d1d9 /src/core | |
| parent | chore: change workflow name and step name (diff) | |
| download | dep-core-next-7df153d4dd8279d1187deb8ad7cd90813cae153b.tar.xz dep-core-next-7df153d4dd8279d1187deb8ad7cd90813cae153b.zip | |
feat, annotate, chore (desc)
feat:
- feature request
- github organization
- change up the `uwu!` response
- add parse and send goodbye to utils
- add goodbye stuff to config model
- add aliases to ignore remove and list
- add alias to russian roulette
annotate:
- framework.rs
chore:
- change command group names
- add discriminator to ready log
- add period to fern log output
- change up order of server info command + add stuff metnioned above
other:
- comment out config goodbye
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/consts.rs | 2 | ||||
| -rw-r--r-- | src/core/framework.rs | 13 | ||||
| -rw-r--r-- | src/core/handler.rs | 5 | ||||
| -rw-r--r-- | src/core/utils.rs | 72 |
4 files changed, 83 insertions, 9 deletions
diff --git a/src/core/consts.rs b/src/core/consts.rs index d76f2ff..bc68bfc 100644 --- a/src/core/consts.rs +++ b/src/core/consts.rs @@ -34,6 +34,8 @@ pub const TRANSCEND: GuildId = GuildId(348660188951216129); pub const SUPPORT_SERV_INVITE: &str = "https://discord.gg/ASrM7p9"; pub const BOT_INVITE: &str = "https://discordapp.com/oauth2/authorize/?permissions=335670488&scope=bot&client_id=699473263998271489"; +pub const FEATURE_REQUEST_LINK: &str = "http://mailto:[email protected]"; +pub const GITHUB_ORG_LINK: &str = "https://github.com/wispgg"; // pub const GITLAB_LINK: &str = "https://gitlab.com/fuwn/wisp"; // pub const PATREON_LINK: &str = "https://www.patreon.com/wisp"; diff --git a/src/core/framework.rs b/src/core/framework.rs index 901573f..5a2d85f 100644 --- a/src/core/framework.rs +++ b/src/core/framework.rs @@ -47,7 +47,7 @@ impl WispFramework { None })) .before(|ctx, message, command_name| { - if let false = message.is_private() { + if let false = message.is_private() { // If guild let guild_id = message.guild_id.unwrap_or(GuildId(0)); if let Ok(guild_data) = db.get_guild(guild_id.0 as i64) { if guild_data.ignored_channels.contains(&(message.channel_id.0 as i64)) { @@ -113,7 +113,6 @@ impl WispFramework { match error { DispatchError::LackOfPermissions(perm) => check_error!( message.channel_id.say(format!( - // "You lack the following permissions needed to execute this command: {:?}" "Sorry, but you need the following permissions to use this command; {:?}" ,perm))), DispatchError::RateLimited(time) => check_error!( @@ -154,18 +153,18 @@ impl WispFramework { .bucket("weather", 30, DAY as i64, 1000) .group("Anime", |_| general::init_anime()) .group("Animals", |_| general::init_animals()) - .group("Config", |_| admins::init_config()) + .group("Configuration", |_| admins::init_config()) .group("Fun", |_| general::init_fun()) // .group("Hackbans", |_| mods::init_hackbans()) - .group("Ignore Channels Management", |_| admins::init_ignore()) + .group("Ignored Channels", |_| admins::init_ignore()) .group("Kick and Ban", |_| mods::init_kickbans()) .group("Management", |_| admins::init_management()) .group("Minigames", |_| general::init_minigames()) // .group("Mod Info", |_| mods::init_info()) // .group("Mute", |_| mods::init_mute()) - // .group("Notes", |_| mods::init_notes()) + .group("Notes", |_| mods::init_notes()) .group("NSFW", |_| general::init_nsfw()) - .group("Owner/ Developer Only", |_| owners::init()) + .group("Owner/ Developer Only", |_| owners::init()) // .group("Premium", |_| admins::init_premium()) // .group("Role Management", |_| mods::init_roles()) // .group("Self Role Management", |_| admins::init_roles()) @@ -173,7 +172,7 @@ impl WispFramework { // .group("Tags", |_| general::init_tags()) .group("Tests", |_| admins::init_tests()) .group("Utilities", |_| general::init_utilities()) - .group("Watchlist Management", |_| mods::init_watchlist()) + .group("Watchlist", |_| mods::init_watchlist()) } } diff --git a/src/core/handler.rs b/src/core/handler.rs index 5f499bf..782cc6c 100644 --- a/src/core/handler.rs +++ b/src/core/handler.rs @@ -67,7 +67,7 @@ impl EventHandler for Handler { }); } else { failed!(API_FAIL); } }); - info!("Logged in as {}", ready.user.name); + info!("Logged in as {}#{}.", ready.user.name, ready.user.discriminator); } fn cached(&self, ctx: Context, guilds: Vec<GuildId>) { @@ -102,7 +102,7 @@ impl EventHandler for Handler { fn message(&self, _: Context, message: Message) { if message.content.contains("uwu!") { - check_error!(message.channel_id.say("Uwufier has been re-branded ! Please use the new prefix; `w.`!")); + check_error!(message.channel_id.say("Uwufier has been re-branded! However, due to Discord verified bot limitations, we are still awaiting for our username change to go through, until then, meet Wisp, your all-in-one Discord companion. For future reference, please use the new prefix; `w.` !")); } if message.mention_everyone { @@ -254,6 +254,7 @@ impl EventHandler for Handler { .colour(*colours::MAIN) .thumbnail(user_face) .description(format!("**Old:** {}\n**New:** {}", user_data.username, user_tag)) + // )).expect("Failed to send Message"); )).expect("Failed to send Message"); } } else { failed!(DB_GUILD_FAIL); } diff --git a/src/core/utils.rs b/src/core/utils.rs index 845b19f..2fb690b 100644 --- a/src/core/utils.rs +++ b/src/core/utils.rs @@ -300,3 +300,75 @@ pub fn send_welcome_embed(input: String, member: &Member, channel: ChannelId) -> e })}) } + +pub fn parse_goodbye_items<S: Into<String>>(input: S, member: &Member) -> String { + let input = input.into(); + let mut ret = input.clone(); + let user = member.user.read(); + for word in PLAIN_PARTS.captures_iter(input.as_str()) { + match word[0].to_lowercase().as_str() { + "{user}" => { + ret = ret.replace(&word[0], user.mention().as_str()); + }, + "{usertag}" => { + ret = ret.replace(&word[0], user.tag().as_str()); + }, + "{username}" => { + ret = ret.replace(&word[0], user.name.as_str()); + }, + "{guild}" => { + if let Ok(guild) = member.guild_id.to_partial_guild() { + ret = ret.replace(&word[0], guild.name.as_str()); + } + }, + "{membercount}" => { + if let Some(guild) = member.guild_id.to_guild_cached() { + ret = ret.replace(&word[0], guild.read().member_count.to_string().as_str()); + } + }, + _ => {}, + } + } + ret +} + +pub fn send_goodbye_embed(input: String, member: &Member, channel: ChannelId) -> Result<Message, Error> { + let user = member.user.read(); + channel.send_message(|m| { m .embed(|mut e| { + for item in EMBED_ITEM.captures_iter(input.as_str()) { + if let Some(caps) = EMBED_PARTS.captures(&item[0]) { + match caps["field"].to_lowercase().as_str() { + "title" => { + e = e.title(parse_goodbye_items(&caps["value"], member)); + }, + "description" => { + e = e.description(parse_goodbye_items(&caps["value"], member)); + }, + "thumbnail" => { + match caps["value"].to_lowercase().trim() { + "user" => { + e = e.thumbnail(user.face()); + }, + "member" => { + e = e.thumbnail(user.face()); + }, + "guild" => { + if let Ok(guild) = member.guild_id.to_partial_guild() { + if let Some(ref s) = guild.icon_url() { + e = e.thumbnail(s); + } + } + }, + _ => {}, + } + }, + "color" | "colour" => { + e = e.colour(u64::from_str_radix(&caps["value"].trim().replace("#",""), 16).unwrap_or(0)); + }, + _ => {}, + } + } + } + e + })}) +} |