Skip to content

Commit

Permalink
update message types, added MessageType.System() and MessageType.Dele…
Browse files Browse the repository at this point in the history
…teable()
  • Loading branch information
topi314 committed Jun 19, 2022
1 parent 730bac6 commit 19534e8
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions discord/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ const (
MessageTypeChannelNameChange
MessageTypeChannelIconChange
ChannelPinnedMessage
MessageTypeGuildMemberJoin
MessageTypeUserPremiumGuildSubscription
MessageTypeUserPremiumGuildSubscriptionTier1
MMessageTypeUserPremiumGuildSubscriptionTier2
MessageTypeUserPremiumGuildSubscriptionTier3
MessageTypeUserJoin
MessageTypeGuildBoost
MessageTypeGuildBoostTier1
MessageTypeGuildBoostTier2
MessageTypeGuildBoostTier3
MessageTypeChannelFollowAdd
_
MessageTypeGuildDiscoveryDisqualified
MessageTypeGuildDiscoveryRequalified
MessageTypeGuildDiscoveryInitialWarning
MessageTypeGuildDiscoveryFinalWarning
MessageTypeGuildDiscoveryGracePeriodInitialWarning
MessageTypeGuildDiscoveryGracePeriodFinalWarning
MessageTypeThreadCreated
MessageTypeReply
MessageTypeSlashCommand
Expand All @@ -38,6 +38,28 @@ const (
MessageTypeContextMenuCommand
)

func (t MessageType) System() bool {
switch t {
case MessageTypeDefault, MessageTypeReply, MessageTypeSlashCommand, MessageTypeThreadStarterMessage, MessageTypeContextMenuCommand:
return false

default:
return true
}
}

func (t MessageType) Deleteable() bool {
switch t {
case MessageTypeRecipientAdd, MessageTypeRecipientRemove, MessageTypeCall,
MessageTypeChannelNameChange, MessageTypeChannelIconChange, MessageTypeGuildDiscoveryDisqualified,
MessageTypeGuildDiscoveryRequalified, MessageTypeGuildDiscoveryGracePeriodInitialWarning,
MessageTypeGuildDiscoveryGracePeriodFinalWarning, MessageTypeThreadStarterMessage:
return false
default:
return true
}
}

// Message is a struct for messages sent in discord text-based channels
type Message struct {
ID snowflake.ID `json:"id"`
Expand Down

0 comments on commit 19534e8

Please sign in to comment.