-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
214 additions
and
61 deletions.
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
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 |
---|---|---|
@@ -1,19 +1,107 @@ | ||
#[cfg(feature = "serde")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::{channel::ChannelId, guild::GuildId, permissions::RoleId}; | ||
|
||
/// Discord docs: https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object | ||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
pub struct AutoModerationRule {} | ||
pub struct AutoModerationRule { | ||
pub id: AutoModerationRuleId, | ||
pub guild_id: GuildId, | ||
pub name: String, | ||
pub creator_id: CreatorId, | ||
pub event_type: EventType, | ||
pub trigger_type: TriggerType, | ||
pub trigger_metadata: TriggerMetadata, | ||
pub actions: Vec<AutoModerationAction>, | ||
pub enabled: bool, | ||
pub exempt_roles: Vec<RoleId>, | ||
pub exempt_channels: Vec<ChannelId>, | ||
} | ||
|
||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
pub struct AutoModerationRuleId(pub String); | ||
|
||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
pub struct CreatorId(pub String); | ||
|
||
/// Discord docs: https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types | ||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
#[cfg_attr(feature = "serde", serde(rename_all = "SCREAMING_SNAKE_CASE"))] | ||
pub enum TriggerType { | ||
Keyword = 1, | ||
Spam = 3, | ||
KeywordPreset = 4, | ||
MentionSpam = 5, | ||
} | ||
|
||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
pub struct TriggerMetadata { | ||
pub keyword_filter: Vec<String>, | ||
pub regex_patterns: Vec<String>, | ||
pub presets: Vec<KeywordPresetType>, | ||
pub allow_list: Vec<String>, | ||
pub mention_total_limit: u8, | ||
pub mention_raid_protection_enabled: bool, | ||
} | ||
|
||
/// Discord docs: https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-preset-types | ||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
#[cfg_attr(feature = "serde", serde(rename_all = "SCREAMING_SNAKE_CASE"))] | ||
pub enum KeywordPresetType { | ||
Profanity = 1, | ||
SexualContent = 2, | ||
Slurs = 3, | ||
} | ||
|
||
/// Discord docs: https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types | ||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
#[cfg_attr(feature = "serde", serde(rename_all = "SCREAMING_SNAKE_CASE"))] | ||
pub enum EventType { | ||
MessageSend = 1, | ||
} | ||
|
||
/// Discord docs: https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-auto-moderation-action-structure | ||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
pub struct AutoModerationAction { | ||
pub r#type: ActionType, | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub metadata: Option<ActionMetadata>, | ||
} | ||
|
||
/// Discord docs: https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-types | ||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
#[cfg_attr(feature = "serde", serde(rename_all = "SCREAMING_SNAKE_CASE"))] | ||
pub enum ActionType { | ||
BlockMessage = 1, | ||
SendAlertMessage = 2, | ||
Timeout = 3, | ||
} | ||
|
||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
pub struct ActionMetadata { | ||
pub channel_id: ChannelId, | ||
pub duration_seconds: u32, | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub custom_message: Option<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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#[cfg(feature = "serde")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::{application::ApplicationId, guild::IntegrationId, ImageHash}; | ||
|
||
bitflags::bitflags! { | ||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
#[cfg_attr(feature = "serde", serde(rename_all = "SCREAMING_SNAKE_CASE"))] | ||
pub struct Permissions: u64 { | ||
const CreateInstantInvite = 1 << 0; | ||
const KickMembers = 1 << 1; | ||
const BanMembers = 1 << 2; | ||
const Administrator = 1 << 3; | ||
const ManageChannels = 1 << 4; | ||
const ManageGuild = 1 << 5; | ||
const AddReactions = 1 << 6; | ||
const ViewAuditLog = 1 << 7; | ||
const PrioritySpeaker = 1 << 8; | ||
const Stream = 1 << 9; | ||
const ViewChannel = 1 << 10; | ||
const SendMessages = 1 << 11; | ||
const SendTtsMessages = 1 << 12; | ||
const ManageMessages = 1 << 13; | ||
const EmbedLinks = 1 << 14; | ||
const AttachFiles = 1 << 15; | ||
const ReadMessageHistory = 1 << 16; | ||
const MentionEveryone = 1 << 17; | ||
const UseExternalEmojis = 1 << 18; | ||
const ViewGuildInsights = 1 << 19; | ||
const Connect = 1 << 20; | ||
const Speak = 1 << 21; | ||
const MuteMembers = 1 << 22; | ||
const DeafenMembers = 1 << 23; | ||
const MoveMembers = 1 << 24; | ||
const UseVad = 1 << 25; | ||
const ChangeNickname = 1 << 26; | ||
const ManageNicknames = 1 << 27; | ||
const ManageRoles = 1 << 28; | ||
const ManageWebhooks = 1 << 29; | ||
const ManageGuildExpressions = 1 << 30; | ||
const UseApplicationCommands = 1 << 31; | ||
const RequestToSpeak = 1 << 32; | ||
const ManageEvents = 1 << 33; | ||
const ManageThreads = 1 << 34; | ||
const CreatePublicThreads = 1 << 35; | ||
const CreatePrivateThreads = 1 << 36; | ||
const UseExternalStickers = 1 << 37; | ||
const SendMessagesInThreads = 1 << 38; | ||
const UseEmbeddedActivities = 1 << 39; | ||
const ModerateMembers = 1 << 40; | ||
const ViewCreatorMonetizationAnalytics = 1 << 41; | ||
const UseSoundboard = 1 << 42; | ||
const CreateGuildExpressions = 1 << 43; | ||
const CreateEvents = 1 << 44; | ||
const UseExternalSounds = 1 << 45; | ||
const SendVoiceMessages = 1 << 46; | ||
const SendPolls = 1 << 49; | ||
} | ||
} | ||
|
||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
pub struct Role { | ||
pub id: RoleId, | ||
pub name: String, | ||
pub color: Rgb, | ||
pub hoist: bool, | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub icon: Option<ImageHash>, | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub unicode_emoji: Option<String>, | ||
pub position: u64, | ||
pub permissions: Permissions, | ||
pub managed: bool, | ||
pub mentionable: bool, | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub tags: Option<RoleTags>, | ||
pub flags: RoleFlags, | ||
} | ||
|
||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
pub struct RoleId(pub String); | ||
|
||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
pub struct Rgb(pub u8, pub u8, pub u8); | ||
|
||
/// Discord docs: https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure | ||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
pub struct RoleTags { | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub bot_id: Option<ApplicationId>, | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub integration_id: Option<IntegrationId>, | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub premium_subscriber: bool, | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub subscription_listing_id: Option<String>, | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub available_for_purchase: bool, | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub guild_connections: bool, | ||
} | ||
|
||
/// Discord docs: https://discord.com/developers/docs/topics/permissions#role-object-role-flags | ||
#[cfg_attr(feature = "clone", derive(Clone))] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
pub enum RoleFlags { | ||
InPrompt = 1 << 0, | ||
} |
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