-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow mentionable structs to be used as command arguments
Add EmojiIdentifier, allow User, UserId, Role, RoleId, EmojiIdentifier, Channel and ChannelId to be used as arguments for commands and add more parsing functions to utils
- Loading branch information
Showing
6 changed files
with
230 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
name: EmojiIdentifier | ||
description: Version of emoji struct used only when Id and name are known. | ||
fields: | ||
- name: id | ||
description: "The Id of the emoji." | ||
type: EmojiId | ||
- name: name | ||
description: "The name of the emoji. It must be at least 2 characters | ||
long and can only contain alphanumeric characters and underscores." | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
extern crate serenity; | ||
|
||
use serenity::utils::*; | ||
|
||
#[test] | ||
fn invite_parser() { | ||
assert_eq!(parse_invite("https://discord.gg/abc"), "abc"); | ||
assert_eq!(parse_invite("http://discord.gg/abc"), "abc"); | ||
assert_eq!(parse_invite("discord.gg/abc"), "abc"); | ||
} | ||
|
||
#[test] | ||
fn username_parser() { | ||
assert_eq!(parse_username("<@12345>").unwrap(), 12345); | ||
assert_eq!(parse_username("<@!12345>").unwrap(), 12345); | ||
} | ||
|
||
#[test] | ||
fn role_parser() { | ||
assert_eq!(parse_role("<@&12345>").unwrap(), 12345); | ||
} | ||
|
||
#[test] | ||
fn channel_parser() { | ||
assert_eq!(parse_channel("<#12345>").unwrap(), 12345); | ||
} | ||
|
||
#[test] | ||
fn emoji_parser() { | ||
let emoji = parse_emoji("<:name:12345>").unwrap(); | ||
assert_eq!(emoji.name, "name"); | ||
assert_eq!(emoji.id, 12345); | ||
} |