aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/consts.rs2
-rw-r--r--src/core/framework.rs13
-rw-r--r--src/core/handler.rs5
-rw-r--r--src/core/utils.rs72
-rw-r--r--src/db/models.rs6
-rw-r--r--src/main.rs2
-rw-r--r--src/modules/commands/admins/config.rs132
-rw-r--r--src/modules/commands/admins/ignore.rs2
-rw-r--r--src/modules/commands/general/fun.rs5
-rw-r--r--src/modules/commands/general/utilities.rs14
10 files changed, 166 insertions, 87 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
+ })})
+}
diff --git a/src/db/models.rs b/src/db/models.rs
index 2e6a460..b410edd 100644
--- a/src/db/models.rs
+++ b/src/db/models.rs
@@ -203,7 +203,7 @@ pub struct UserUpdate {
impl Display for Guild {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
- write!(f, "**Admin Roles:** {}\n**Audit:** {}\n**Audit Channel:** {}\n**Audit Threshold:** {}\n**Autorole:** {}\n**Autoroles:** {}\n**Ignored Channels:** {}\n**Ignore Level:** {}\n**Introduction:** {}\n**Introduction Channel:** {}\n**Introduction Type:** {}\n**Introduction Message:** {}\n**Mod Roles: ** {}\n**Modlog:** {}\n**Modlog Channel:** {}\n**Mute Setup:** {}\n**Prefix:** {}\n**Welcome:** {}\n**Welcome Channel:** {}\n**Welcome Type:** {}\n**Welcome Message:** {}\n**Disabled Commands:** {}\n**Disabled Log Types:** {}",
+ write!(f, "**Admin Roles:** {}\n**Audit:** {}\n**Audit Channel:** {}\n**Audit Threshold:** {}\n**Autorole:** {}\n**Autoroles:** {}\n**Ignored Channels:** {}\n**Ignore Level:** {}\n**Introduction:** {}\n**Introduction Channel:** {}\n**Introduction Type:** {}\n**Introduction Message:** {}\n**Mod Roles: ** {}\n**Modlog:** {}\n**Modlog Channel:** {}\n**Mute Setup:** {}\n**Prefix:** {}\n**Welcome:** {}\n**Welcome Channel:** {}\n**Welcome Type:** {}\n**Welcome Message:** {}\n**Goodbye:** {}\n**Goodbye Channel:** {}\n**Goodbye Type:** {}\n**Goodbye Message:** {}\n**Disabled Commands:** {}\n**Disabled Log Types:** {}",
self.admin_roles.iter().map(|e| match RoleId(*e as u64).to_role_cached() {
Some(role) => role.name,
None => format!("{}", e),
@@ -234,6 +234,10 @@ impl Display for Guild {
format!("<#{}>", self.welcome_channel),
self.welcome_type,
self.welcome_message,
+ self.goodbye,
+ format!("<#{}>", self.goodbye_channel),
+ self.goodbye_type,
+ self.goodbye_message,
self.commands.join(", "),
self.logging.join(", ")
)}
diff --git a/src/main.rs b/src/main.rs
index e4235a0..d1d8351 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -50,7 +50,7 @@ fn fern_setup() -> Result<(), log::SetLoggerError> {
target_width = 60
))
})
- .chain(fern::log_file("output.log").expect("Failed to load log file"))
+ .chain(fern::log_file("output.log").expect("Failed to load log file."))
.into_shared();
fern::Dispatch::new()
diff --git a/src/modules/commands/admins/config.rs b/src/modules/commands/admins/config.rs
index a26fc3d..43e2215 100644
--- a/src/modules/commands/admins/config.rs
+++ b/src/modules/commands/admins/config.rs
@@ -505,73 +505,73 @@ impl Command for ConfigWelcome {
}
}
-pub struct ConfigGoodbye;
-impl Command for ConfigGoodbye {
- fn options(&self) -> Arc<CommandOptions> {
- 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("People leaving you ? At least make it cool and custom.\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("<option> <value>".to_string()),
- example: Some("message {user} has left {guild}...".to_string()),
- min_args: Some(1),
- required_permissions: Permissions::MANAGE_GUILD,
- ..default
- };
- Arc::new(options)
- }
+// pub struct ConfigGoodbye;
+// impl Command for ConfigGoodbye {
+// fn options(&self) -> Arc<CommandOptions> {
+// 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("People leaving you ? At least make it cool and custom.\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("<option> <value>".to_string()),
+// example: Some("message {user} has left {guild}...".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::<String>().unwrap_or(String::new());
- let mut val = args.rest().to_string();
- match op.to_lowercase().as_str() {
- "enable" => {
- guild_data.welcome = true;
- },
- "disable" => {
- guild_data.welcome = false;
- },
- "channel" => {
- match parse_channel(val.to_string(), guild_id) {
- Some((channel_id, channel)) => {
- guild_data.welcome_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" => {
- guild_data.welcome_message = val.to_string();
- },
- "type" => {
- guild_data.welcome_type = val.to_string();
- },
- _ => {
- message.channel_id.say("I didn't understand that option. Valid options are: `enable`, `disable`, `channel`, `message`, `type`. For more information see `help config goodbye`")?;
- 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("Goodbye Configuration Summary")
- .colour(*colours::MAIN)
- .description(format!("**Operation:** {}\n**Value:** {}",
- op,
- if val.is_empty() { guild.welcome.to_string() } else { val },
- ))
- ))?;
- } else {
- failed!(GUILDID_FAIL);
- }
- Ok(())
- }
-}
+// 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::<String>().unwrap_or(String::new());
+// let mut val = args.rest().to_string();
+// match op.to_lowercase().as_str() {
+// "enable" => {
+// guild_data.welcome = true;
+// },
+// "disable" => {
+// guild_data.welcome = false;
+// },
+// "channel" => {
+// match parse_channel(val.to_string(), guild_id) {
+// Some((channel_id, channel)) => {
+// guild_data.welcome_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" => {
+// guild_data.welcome_message = val.to_string();
+// },
+// "type" => {
+// guild_data.welcome_type = val.to_string();
+// },
+// _ => {
+// message.channel_id.say("I didn't understand that option. Valid options are: `enable`, `disable`, `channel`, `message`, `type`. For more information see `help config goodbye`")?;
+// 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("Goodbye Configuration Summary")
+// .colour(*colours::MAIN)
+// .description(format!("**Operation:** {}\n**Value:** {}",
+// op,
+// if val.is_empty() { guild.welcome.to_string() } else { val },
+// ))
+// ))?;
+// } else {
+// failed!(GUILDID_FAIL);
+// }
+// Ok(())
+// }
+// }
pub struct ConfigIntroduction;
impl Command for ConfigIntroduction {
diff --git a/src/modules/commands/admins/ignore.rs b/src/modules/commands/admins/ignore.rs
index efafdac..a716a45 100644
--- a/src/modules/commands/admins/ignore.rs
+++ b/src/modules/commands/admins/ignore.rs
@@ -59,6 +59,7 @@ impl Command for IgnoreRemove {
let default = CommandOptions::default();
let options = CommandOptions {
desc: Some("Finally, I can see.".to_string()),
+ aliases: vec!["rm", "delete", "del"].iter().map(|e| e.to_string()).collect(),
usage: Some("<channel_resolvable>".to_string()),
example: Some("#general".to_string()),
min_args: Some(1),
@@ -99,6 +100,7 @@ impl Command for IgnoreList {
let default = CommandOptions::default();
let options = CommandOptions {
desc: Some("You want ME to tell YOU want channels I'm ignoring ?.".to_string()),
+ aliases: vec!["ls"].iter().map(|e| e.to_string()).collect(),
required_permissions: Permissions::MANAGE_GUILD,
max_args: Some(0),
..default
diff --git a/src/modules/commands/general/fun.rs b/src/modules/commands/general/fun.rs
index 79f37c9..75243d2 100644
--- a/src/modules/commands/general/fun.rs
+++ b/src/modules/commands/general/fun.rs
@@ -228,10 +228,7 @@ impl Command for RussianRoulette {
let default = CommandOptions::default();
let options = CommandOptions {
desc: Some("A simple game, one in the chamber, who gets splattered ?".to_string()),
- // usage: Some("[tags]".to_string()),
- // example: Some("minecraft".to_string()),
- // aliases: vec!["furry"].iter().map(|e| e.to_string()).collect(),
- // owner_privileges: false,
+ aliases: vec!["rr"].iter().map(|e| e.to_string()).collect(),
..default
};
Arc::new(options)
diff --git a/src/modules/commands/general/utilities.rs b/src/modules/commands/general/utilities.rs
index fc6fc36..74052de 100644
--- a/src/modules/commands/general/utilities.rs
+++ b/src/modules/commands/general/utilities.rs
@@ -344,15 +344,15 @@ impl Command for ServerInfo {
.embed(|e| e
.thumbnail(guild.icon_url().unwrap_or("https://cdn.discordapp.com/embed/avatars/0.png".to_string()))
.color(*colours::MAIN)
- .field("ID", guild.id, true)
.field("Name", &guild.name, true)
+ .field("ID", guild.id, true)
.field("Owner", guild.owner_id.mention(), true)
.field("Region", guild.region, true)
- .field(format!("Channels [{}]", guild.channels.len()), format!("Categories: {}\nText: {}\nVoice: {}", channels.2, channels.0, channels.1), true)
.field(format!("Members [{}/{}]", members.2, guild.members.len()), format!("Humans: {}\nBots: {}", members.0, members.1), true)
- .field("Created", guild.id.created_at().format("%a, %d %h %Y @ %H:%M:%S").to_string(), false)
+ .field(format!("Channels [{}]", guild.channels.len()), format!("Categories: {}\nText: {}\nVoice: {}", channels.2, channels.0, channels.1), true)
.field("Roles", guild.roles.len(), true)
.field("Emojis", guild.emojis.len(), true)
+ .field("Created", guild.id.created_at().format("%a, %d %h %Y @ %H:%M:%S").to_string(), false)
.title(guild.name)
))?;
},
@@ -708,7 +708,7 @@ impl Command for Wisp {
.description("Hey ! I'm Wisp, I was written in [Rust](https://www.rust-lang.org/) using [Serenity](https://github.com/serenity-rs/serenity).")
.field("Owner/ Developer", format!(
"Name: {}\nID: {}"
- ,owner.tag()
+ ,owner.mention()
,owner.id)
,true)
// .field("Links", format!(
@@ -720,8 +720,10 @@ impl Command for Wisp {
// ,true)
.field("Useful Links", format!(
// "[Support Server]({})\n[Invite]({})\n[GitLab]({})\n[Patreon]({})"
- "[Invite]({})"
- // ,SUPPORT_SERV_INVITE
+ "[Support Server]({})\n[GitHub Organization]({})\n[Feature Request]({})\n[Invite]({})"
+ ,SUPPORT_SERV_INVITE
+ ,GITHUB_ORG_LINK
+ ,FEATURE_REQUEST_LINK
,BOT_INVITE)
// ,GITLAB_LINK
// ,PATREON_LINK)