1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-13 02:12:49 +00:00
arikawa/gateway/events_map.go
diamondburned 6ef093eb98 Gateway: Refactor, v8 user struct updates
This commit refactored several structures from package discord to be in
package gateway. Those structures are mostly presence ones, which per
official documentation has a lot more to do with the Gateway API than
the REST API or anything else.

This commit also renamed several global variables to have a more
consistent and obvious name.

As of v8, the user API has had a lot of minor and some major changes,
especially regarding its Ready event API. The most significant change is
the addition of the ReadySupplemental event as well as several changes
to the Ready field itself.

All of these changes above are breaking, and they have already broken
the state package. These breaking changes will be addressed in other
packages by the next commit.
2020-11-28 17:22:03 -08:00

75 lines
3.8 KiB
Go

package gateway
// Event is any event struct. They have an "Event" suffixed to them.
type Event = interface{}
// EventCreator maps an event type string to a constructor.
var EventCreator = map[string]func() Event{
"HELLO": func() Event { return new(HelloEvent) },
"READY": func() Event { return new(ReadyEvent) },
"READY_SUPPLEMENTAL": func() Event { return new(ReadySupplementalEvent) },
"RESUMED": func() Event { return new(ResumedEvent) },
"INVALID_SESSION": func() Event { return new(InvalidSessionEvent) },
"CHANNEL_CREATE": func() Event { return new(ChannelCreateEvent) },
"CHANNEL_UPDATE": func() Event { return new(ChannelUpdateEvent) },
"CHANNEL_DELETE": func() Event { return new(ChannelDeleteEvent) },
"CHANNEL_PINS_UPDATE": func() Event { return new(ChannelPinsUpdateEvent) },
"CHANNEL_UNREAD_UPDATE": func() Event { return new(ChannelUnreadUpdateEvent) },
"GUILD_CREATE": func() Event { return new(GuildCreateEvent) },
"GUILD_UPDATE": func() Event { return new(GuildUpdateEvent) },
"GUILD_DELETE": func() Event { return new(GuildDeleteEvent) },
"GUILD_BAN_ADD": func() Event { return new(GuildBanAddEvent) },
"GUILD_BAN_REMOVE": func() Event { return new(GuildBanRemoveEvent) },
"GUILD_EMOJIS_UPDATE": func() Event { return new(GuildEmojisUpdateEvent) },
"GUILD_INTEGRATIONS_UPDATE": func() Event { return new(GuildIntegrationsUpdateEvent) },
"GUILD_MEMBER_ADD": func() Event { return new(GuildMemberAddEvent) },
"GUILD_MEMBER_REMOVE": func() Event { return new(GuildMemberRemoveEvent) },
"GUILD_MEMBER_UPDATE": func() Event { return new(GuildMemberUpdateEvent) },
"GUILD_MEMBERS_CHUNK": func() Event { return new(GuildMembersChunkEvent) },
"GUILD_MEMBER_LIST_UPDATE": func() Event { return new(GuildMemberListUpdate) },
"GUILD_ROLE_CREATE": func() Event { return new(GuildRoleCreateEvent) },
"GUILD_ROLE_UPDATE": func() Event { return new(GuildRoleUpdateEvent) },
"GUILD_ROLE_DELETE": func() Event { return new(GuildRoleDeleteEvent) },
"INVITE_CREATE": func() Event { return new(InviteCreateEvent) },
"INVITE_DELETE": func() Event { return new(InviteDeleteEvent) },
"MESSAGE_CREATE": func() Event { return new(MessageCreateEvent) },
"MESSAGE_UPDATE": func() Event { return new(MessageUpdateEvent) },
"MESSAGE_DELETE": func() Event { return new(MessageDeleteEvent) },
"MESSAGE_DELETE_BULK": func() Event { return new(MessageDeleteBulkEvent) },
"MESSAGE_REACTION_ADD": func() Event { return new(MessageReactionAddEvent) },
"MESSAGE_REACTION_REMOVE": func() Event { return new(MessageReactionRemoveEvent) },
"MESSAGE_REACTION_REMOVE_ALL": func() Event { return new(MessageReactionRemoveAllEvent) },
"MESSAGE_REACTION_REMOVE_EMOJI": func() Event { return new(MessageReactionRemoveEmojiEvent) },
"MESSAGE_ACK": func() Event { return new(MessageAckEvent) },
"PRESENCE_UPDATE": func() Event { return new(PresenceUpdateEvent) },
"PRESENCES_REPLACE": func() Event { return new(PresencesReplaceEvent) },
"SESSIONS_REPLACE": func() Event { return new(SessionsReplaceEvent) },
"TYPING_START": func() Event { return new(TypingStartEvent) },
"VOICE_STATE_UPDATE": func() Event { return new(VoiceStateUpdateEvent) },
"VOICE_SERVER_UPDATE": func() Event { return new(VoiceServerUpdateEvent) },
"WEBHOOKS_UPDATE": func() Event { return new(WebhooksUpdateEvent) },
"USER_UPDATE": func() Event { return new(UserUpdateEvent) },
"USER_SETTINGS_UPDATE": func() Event { return new(UserSettingsUpdateEvent) },
"USER_GUILD_SETTINGS_UPDATE": func() Event { return new(UserGuildSettingsUpdateEvent) },
"USER_NOTE_UPDATE": func() Event { return new(UserNoteUpdateEvent) },
"RELATIONSHIP_ADD": func() Event { return new(RelationshipAddEvent) },
"RELATIONSHIP_REMOVE": func() Event { return new(RelationshipRemoveEvent) },
}