Skip to content

Instantly share code, notes, and snippets.

@mkrasnitski
Created May 30, 2023 10:47
Show Gist options
  • Save mkrasnitski/61d57612ce1346d14c83ecc9fde71187 to your computer and use it in GitHub Desktop.
Save mkrasnitski/61d57612ce1346d14c83ecc9fde71187 to your computer and use it in GitHub Desktop.
diff --git a/command_attr/src/structures.rs b/command_attr/src/structures.rs
index d8eb02a77..b53156d92 100644
--- a/command_attr/src/structures.rs
+++ b/command_attr/src/structures.rs
@@ -299,35 +299,47 @@ impl Permissions {
"PRESET_GENERAL" => 0b0000_0110_0011_0111_1101_1100_0100_0001,
"PRESET_TEXT" => 0b0000_0000_0000_0111_1111_1100_0100_0000,
"PRESET_VOICE" => 0b0000_0011_1111_0000_0000_0000_0000_0000,
- "CREATE_INVITE" => 0b0000_0000_0000_0000_0000_0000_0000_0001,
- "KICK_MEMBERS" => 0b0000_0000_0000_0000_0000_0000_0000_0010,
- "BAN_MEMBERS" => 0b0000_0000_0000_0000_0000_0000_0000_0100,
- "ADMINISTRATOR" => 0b0000_0000_0000_0000_0000_0000_0000_1000,
- "MANAGE_CHANNELS" => 0b0000_0000_0000_0000_0000_0000_0001_0000,
- "MANAGE_GUILD" => 0b0000_0000_0000_0000_0000_0000_0010_0000,
- "ADD_REACTIONS" => 0b0000_0000_0000_0000_0000_0000_0100_0000,
- "VIEW_AUDIT_LOG" => 0b0000_0000_0000_0000_0000_0000_1000_0000,
- "PRIORITY_SPEAKER" => 0b0000_0000_0000_0000_0000_0001_0000_0000,
- "READ_MESSAGES" => 0b0000_0000_0000_0000_0000_0100_0000_0000,
- "SEND_MESSAGES" => 0b0000_0000_0000_0000_0000_1000_0000_0000,
- "SEND_TTS_MESSAGES" => 0b0000_0000_0000_0000_0001_0000_0000_0000,
- "MANAGE_MESSAGES" => 0b0000_0000_0000_0000_0010_0000_0000_0000,
- "EMBED_LINKS" => 0b0000_0000_0000_0000_0100_0000_0000_0000,
- "ATTACH_FILES" => 0b0000_0000_0000_0000_1000_0000_0000_0000,
- "READ_MESSAGE_HISTORY" => 0b0000_0000_0000_0001_0000_0000_0000_0000,
- "MENTION_EVERYONE" => 0b0000_0000_0000_0010_0000_0000_0000_0000,
- "USE_EXTERNAL_EMOJIS" => 0b0000_0000_0000_0100_0000_0000_0000_0000,
- "CONNECT" => 0b0000_0000_0001_0000_0000_0000_0000_0000,
- "SPEAK" => 0b0000_0000_0010_0000_0000_0000_0000_0000,
- "MUTE_MEMBERS" => 0b0000_0000_0100_0000_0000_0000_0000_0000,
- "DEAFEN_MEMBERS" => 0b0000_0000_1000_0000_0000_0000_0000_0000,
- "MOVE_MEMBERS" => 0b0000_0001_0000_0000_0000_0000_0000_0000,
- "USE_VAD" => 0b0000_0010_0000_0000_0000_0000_0000_0000,
- "CHANGE_NICKNAME" => 0b0000_0100_0000_0000_0000_0000_0000_0000,
- "MANAGE_NICKNAMES" => 0b0000_1000_0000_0000_0000_0000_0000_0000,
- "MANAGE_ROLES" => 0b0001_0000_0000_0000_0000_0000_0000_0000,
- "MANAGE_WEBHOOKS" => 0b0010_0000_0000_0000_0000_0000_0000_0000,
- "MANAGE_EMOJIS_AND_STICKERS" => 0b0100_0000_0000_0000_0000_0000_0000_0000,
+ "CREATE_INVITE" | "CREATE_INSTANT_INVITE" => 1 << 0,
+ "KICK_MEMBERS" => 1 << 1,
+ "BAN_MEMBERS" => 1 << 2,
+ "ADMINISTRATOR" => 1 << 3,
+ "MANAGE_CHANNELS" => 1 << 4,
+ "MANAGE_GUILD" => 1 << 5,
+ "ADD_REACTIONS" => 1 << 6,
+ "VIEW_AUDIT_LOG" => 1 << 7,
+ "PRIORITY_SPEAKER" => 1 << 8,
+ "STREAM" => 1 << 9,
+ "VIEW_CHANNEL" => 1 << 10,
+ "SEND_MESSAGES" => 1 << 11,
+ "SEND_TTS_MESSAGES" => 1 << 12,
+ "MANAGE_MESSAGES" => 1 << 13,
+ "EMBED_LINKS" => 1 << 14,
+ "ATTACH_FILES" => 1 << 15,
+ "READ_MESSAGE_HISTORY" => 1 << 16,
+ "MENTION_EVERYONE" => 1 << 17,
+ "USE_EXTERNAL_EMOJIS" => 1 << 18,
+ "VIEW_GUILD_INSIGHTS" => 1 << 19,
+ "CONNECT" => 1 << 20,
+ "SPEAK" => 1 << 21,
+ "MUTE_MEMBERS" => 1 << 22,
+ "DEAFEN_MEMBERS" => 1 << 23,
+ "MOVE_MEMBERS" => 1 << 24,
+ "USE_VAD" => 1 << 25,
+ "CHANGE_NICKNAME" => 1 << 26,
+ "MANAGE_NICKNAMES" => 1 << 27,
+ "MANAGE_ROLES" => 1 << 28,
+ "MANAGE_WEBHOOKS" => 1 << 29,
+ "MANAGE_EMOJIS_AND_STICKERS" => 1 << 30,
+ "USE_SLASH_COMMANDS" => 1 << 31,
+ "REQUEST_TO_SPEAK" => 1 << 32,
+ "MANAGE_EVENTS" => 1 << 33,
+ "MANAGE_THREADS" => 1 << 34,
+ "CREATE_PUBLIC_THREADS" => 1 << 35,
+ "CREATE_PRIVATE_THREADS" => 1 << 36,
+ "USE_EXTERNAL_STICKERS" => 1 << 37,
+ "SEND_MESSAGES_IN_THREADS" => 1 << 38,
+ "USE_EMBEDDED_ACTIVITIES" => 1 << 39,
+ "MODERATE_MEMBERS" => 1 << 40,
_ => return None,
}))
}
diff --git a/src/builder/edit_message.rs b/src/builder/edit_message.rs
index d2ac122ef..2a44c88c8 100644
--- a/src/builder/edit_message.rs
+++ b/src/builder/edit_message.rs
@@ -217,6 +217,12 @@ impl EditMessage {
}
self
}
+
+ /// Remove all attachments.
+ pub fn remove_all_attachments(mut self) -> Self {
+ self.attachments.get_or_insert_with(Vec::new).clear();
+ self
+ }
}
#[cfg(feature = "http")]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment