events.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. package discordgo
  2. // eventToInterface is a mapping of Discord WSAPI events to their
  3. // DiscordGo event container.
  4. // Each Discord WSAPI event maps to a unique interface.
  5. // Use Session.AddHandler with one of these types to handle that
  6. // type of event.
  7. // eg:
  8. // Session.AddHandler(func(s *discordgo.Session, m *discordgo.MessageCreate) {
  9. // })
  10. //
  11. // or:
  12. // Session.AddHandler(func(s *discordgo.Session, m *discordgo.PresenceUpdate) {
  13. // })
  14. var eventToInterface = map[string]interface{}{
  15. "CHANNEL_CREATE": ChannelCreate{},
  16. "CHANNEL_UPDATE": ChannelUpdate{},
  17. "CHANNEL_DELETE": ChannelDelete{},
  18. "GUILD_CREATE": GuildCreate{},
  19. "GUILD_UPDATE": GuildUpdate{},
  20. "GUILD_DELETE": GuildDelete{},
  21. "GUILD_BAN_ADD": GuildBanAdd{},
  22. "GUILD_BAN_REMOVE": GuildBanRemove{},
  23. "GUILD_MEMBER_ADD": GuildMemberAdd{},
  24. "GUILD_MEMBER_UPDATE": GuildMemberUpdate{},
  25. "GUILD_MEMBER_REMOVE": GuildMemberRemove{},
  26. "GUILD_ROLE_CREATE": GuildRoleCreate{},
  27. "GUILD_ROLE_UPDATE": GuildRoleUpdate{},
  28. "GUILD_ROLE_DELETE": GuildRoleDelete{},
  29. "GUILD_INTEGRATIONS_UPDATE": GuildIntegrationsUpdate{},
  30. "GUILD_EMOJIS_UPDATE": GuildEmojisUpdate{},
  31. "MESSAGE_ACK": MessageAck{},
  32. "MESSAGE_CREATE": MessageCreate{},
  33. "MESSAGE_UPDATE": MessageUpdate{},
  34. "MESSAGE_DELETE": MessageDelete{},
  35. "PRESENCE_UPDATE": PresenceUpdate{},
  36. "PRESENCES_REPLACE": PresencesReplace{},
  37. "READY": Ready{},
  38. "USER_UPDATE": UserUpdate{},
  39. "USER_SETTINGS_UPDATE": UserSettingsUpdate{},
  40. "USER_GUILD_SETTINGS_UPDATE": UserGuildSettingsUpdate{},
  41. "TYPING_START": TypingStart{},
  42. "VOICE_SERVER_UPDATE": VoiceServerUpdate{},
  43. "VOICE_STATE_UPDATE": VoiceStateUpdate{},
  44. }
  45. // Connect is an empty struct for an event.
  46. type Connect struct{}
  47. // Disconnect is an empty struct for an event.
  48. type Disconnect struct{}
  49. // MessageCreate is a wrapper struct for an event.
  50. type MessageCreate struct {
  51. *Message
  52. }
  53. // MessageUpdate is a wrapper struct for an event.
  54. type MessageUpdate struct {
  55. *Message
  56. }
  57. // MessageDelete is a wrapper struct for an event.
  58. type MessageDelete struct {
  59. *Message
  60. }
  61. // ChannelCreate is a wrapper struct for an event.
  62. type ChannelCreate struct {
  63. *Channel
  64. }
  65. // ChannelUpdate is a wrapper struct for an event.
  66. type ChannelUpdate struct {
  67. *Channel
  68. }
  69. // ChannelDelete is a wrapper struct for an event.
  70. type ChannelDelete struct {
  71. *Channel
  72. }
  73. // GuildCreate is a wrapper struct for an event.
  74. type GuildCreate struct {
  75. *Guild
  76. }
  77. // GuildUpdate is a wrapper struct for an event.
  78. type GuildUpdate struct {
  79. *Guild
  80. }
  81. // GuildDelete is a wrapper struct for an event.
  82. type GuildDelete struct {
  83. *Guild
  84. }
  85. // GuildBanAdd is a wrapper struct for an event.
  86. type GuildBanAdd struct {
  87. *GuildBan
  88. }
  89. // GuildBanRemove is a wrapper struct for an event.
  90. type GuildBanRemove struct {
  91. *GuildBan
  92. }
  93. // GuildMemberAdd is a wrapper struct for an event.
  94. type GuildMemberAdd struct {
  95. *Member
  96. }
  97. // GuildMemberUpdate is a wrapper struct for an event.
  98. type GuildMemberUpdate struct {
  99. *Member
  100. }
  101. // GuildMemberRemove is a wrapper struct for an event.
  102. type GuildMemberRemove struct {
  103. *Member
  104. }
  105. // GuildRoleCreate is a wrapper struct for an event.
  106. type GuildRoleCreate struct {
  107. *GuildRole
  108. }
  109. // GuildRoleUpdate is a wrapper struct for an event.
  110. type GuildRoleUpdate struct {
  111. *GuildRole
  112. }
  113. // PresencesReplace is an array of Presences for an event.
  114. type PresencesReplace []*Presence
  115. // VoiceStateUpdate is a wrapper struct for an event.
  116. type VoiceStateUpdate struct {
  117. *VoiceState
  118. }
  119. // UserUpdate is a wrapper struct for an event.
  120. type UserUpdate struct {
  121. *UserUpdate
  122. }
  123. // UserSettingsUpdate is a map for an event.
  124. type UserSettingsUpdate map[string]interface{}
  125. // UserGuildSettingsUpdate is a map for an event.
  126. type UserGuildSettingsUpdate struct {
  127. *UserGuildSettings
  128. }