|
1 | 1 | //! Audit log types for administrative actions within guilds.
|
2 | 2 |
|
3 |
| -use std::mem::transmute; |
4 |
| - |
5 | 3 | use nonmax::{NonMaxU32, NonMaxU64};
|
6 | 4 | use serde::ser::{Serialize, Serializer};
|
7 | 5 |
|
@@ -71,22 +69,62 @@ impl Action {
|
71 | 69 | pub fn from_value(value: u8) -> Action {
|
72 | 70 | match value {
|
73 | 71 | 1 => Action::GuildUpdate,
|
74 |
| - 10..=12 => Action::Channel(unsafe { transmute(value) }), |
75 |
| - 13..=15 => Action::ChannelOverwrite(unsafe { transmute(value) }), |
76 |
| - 20..=28 => Action::Member(unsafe { transmute(value) }), |
77 |
| - 30..=32 => Action::Role(unsafe { transmute(value) }), |
78 |
| - 40..=42 => Action::Invite(unsafe { transmute(value) }), |
79 |
| - 50..=52 => Action::Webhook(unsafe { transmute(value) }), |
80 |
| - 60..=62 => Action::Emoji(unsafe { transmute(value) }), |
81 |
| - 72..=75 => Action::Message(unsafe { transmute(value) }), |
82 |
| - 80..=82 => Action::Integration(unsafe { transmute(value) }), |
83 |
| - 83..=85 => Action::StageInstance(unsafe { transmute(value) }), |
84 |
| - 90..=92 => Action::Sticker(unsafe { transmute(value) }), |
85 |
| - 100..=102 => Action::ScheduledEvent(unsafe { transmute(value) }), |
86 |
| - 110..=112 => Action::Thread(unsafe { transmute(value) }), |
87 |
| - 140..=145 => Action::AutoMod(unsafe { transmute(value) }), |
88 |
| - 150..=151 => Action::CreatorMonetization(unsafe { transmute(value) }), |
89 |
| - 192..=193 => Action::VoiceChannelStatus(unsafe { transmute(value) }), |
| 72 | + 10 => Action::Channel(ChannelAction::Create), |
| 73 | + 11 => Action::Channel(ChannelAction::Update), |
| 74 | + 12 => Action::Channel(ChannelAction::Delete), |
| 75 | + 13 => Action::ChannelOverwrite(ChannelOverwriteAction::Create), |
| 76 | + 14 => Action::ChannelOverwrite(ChannelOverwriteAction::Update), |
| 77 | + 15 => Action::ChannelOverwrite(ChannelOverwriteAction::Delete), |
| 78 | + 20 => Action::Member(MemberAction::Kick), |
| 79 | + 21 => Action::Member(MemberAction::Prune), |
| 80 | + 22 => Action::Member(MemberAction::BanAdd), |
| 81 | + 23 => Action::Member(MemberAction::BanRemove), |
| 82 | + 24 => Action::Member(MemberAction::Update), |
| 83 | + 25 => Action::Member(MemberAction::RoleUpdate), |
| 84 | + 26 => Action::Member(MemberAction::MemberMove), |
| 85 | + 27 => Action::Member(MemberAction::MemberDisconnect), |
| 86 | + 28 => Action::Member(MemberAction::BotAdd), |
| 87 | + 30 => Action::Role(RoleAction::Create), |
| 88 | + 31 => Action::Role(RoleAction::Update), |
| 89 | + 32 => Action::Role(RoleAction::Delete), |
| 90 | + 40 => Action::Invite(InviteAction::Create), |
| 91 | + 41 => Action::Invite(InviteAction::Update), |
| 92 | + 42 => Action::Invite(InviteAction::Delete), |
| 93 | + 50 => Action::Webhook(WebhookAction::Create), |
| 94 | + 51 => Action::Webhook(WebhookAction::Update), |
| 95 | + 52 => Action::Webhook(WebhookAction::Delete), |
| 96 | + 60 => Action::Emoji(EmojiAction::Create), |
| 97 | + 61 => Action::Emoji(EmojiAction::Update), |
| 98 | + 62 => Action::Emoji(EmojiAction::Delete), |
| 99 | + 72 => Action::Message(MessageAction::Delete), |
| 100 | + 73 => Action::Message(MessageAction::BulkDelete), |
| 101 | + 74 => Action::Message(MessageAction::Pin), |
| 102 | + 75 => Action::Message(MessageAction::Unpin), |
| 103 | + 80 => Action::Integration(IntegrationAction::Create), |
| 104 | + 81 => Action::Integration(IntegrationAction::Update), |
| 105 | + 82 => Action::Integration(IntegrationAction::Delete), |
| 106 | + 83 => Action::StageInstance(StageInstanceAction::Create), |
| 107 | + 84 => Action::StageInstance(StageInstanceAction::Update), |
| 108 | + 85 => Action::StageInstance(StageInstanceAction::Delete), |
| 109 | + 90 => Action::Sticker(StickerAction::Create), |
| 110 | + 91 => Action::Sticker(StickerAction::Update), |
| 111 | + 92 => Action::Sticker(StickerAction::Delete), |
| 112 | + 100 => Action::ScheduledEvent(ScheduledEventAction::Create), |
| 113 | + 101 => Action::ScheduledEvent(ScheduledEventAction::Update), |
| 114 | + 102 => Action::ScheduledEvent(ScheduledEventAction::Delete), |
| 115 | + 110 => Action::Thread(ThreadAction::Create), |
| 116 | + 111 => Action::Thread(ThreadAction::Update), |
| 117 | + 112 => Action::Thread(ThreadAction::Delete), |
| 118 | + 140 => Action::AutoMod(AutoModAction::RuleCreate), |
| 119 | + 141 => Action::AutoMod(AutoModAction::RuleUpdate), |
| 120 | + 142 => Action::AutoMod(AutoModAction::RuleDelete), |
| 121 | + 143 => Action::AutoMod(AutoModAction::BlockMessage), |
| 122 | + 144 => Action::AutoMod(AutoModAction::FlagToChannel), |
| 123 | + 145 => Action::AutoMod(AutoModAction::UserCommunicationDisabled), |
| 124 | + 150 => Action::CreatorMonetization(CreatorMonetizationAction::RequestCreated), |
| 125 | + 151 => Action::CreatorMonetization(CreatorMonetizationAction::TermsAccepted), |
| 126 | + 192 => Action::VoiceChannelStatus(VoiceChannelStatusAction::StatusUpdate), |
| 127 | + 193 => Action::VoiceChannelStatus(VoiceChannelStatusAction::StatusDelete), |
90 | 128 | _ => Action::Unknown(value),
|
91 | 129 | }
|
92 | 130 | }
|
|
0 commit comments