aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaiddog <[email protected]>2017-05-27 15:00:01 -0500
committerZeyla Hellyer <[email protected]>2017-05-27 13:00:01 -0700
commite033ff33b94e024fe5f55a8c93c65c3e885f821b (patch)
tree95cd530ec7c294eefc202b19e95f26a69886bd27 /src
parentGuild::create_channel doesn't require mutability (diff)
downloadserenity-e033ff33b94e024fe5f55a8c93c65c3e885f821b.tar.xz
serenity-e033ff33b94e024fe5f55a8c93c65c3e885f821b.zip
Add CurrentUser::invite_url method
Diffstat (limited to 'src')
-rw-r--r--src/model/user.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/model/user.rs b/src/model/user.rs
index 9afd080..f356d5d 100644
--- a/src/model/user.rs
+++ b/src/model/user.rs
@@ -103,6 +103,18 @@ impl CurrentUser {
self.avatar.as_ref()
.map(|av| format!(cdn!("/avatars/{}/{}.webp?size=1024"), self.id.0, av))
}
+
+ /// Returns the invite url for the bot with the given permissions.
+ ///
+ /// If the permissions passed are empty, the permissions part will be dropped.
+ pub fn invite_url(&self, permissions: Permissions) -> String {
+ let bits = permissions.bits();
+ if bits == 0 {
+ format!("https://discordapp.com/api/oauth2/authorize?client_id={}&scope=bot", self.id)
+ } else {
+ format!("https://discordapp.com/api/oauth2/authorize?client_id={}&scope=bot&permissions={}", self.id, bits)
+ }
+ }
}
/// An enum that represents a default avatar.