events.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. "READY": Ready{},
  37. "USER_UPDATE": UserUpdate{},
  38. "USER_SETTINGS_UPDATE": UserSettingsUpdate{},
  39. "USER_GUILD_SETTINGS_UPDATE": UserGuildSettingsUpdate{},
  40. "TYPING_START": TypingStart{},
  41. "VOICE_SERVER_UPDATE": VoiceServerUpdate{},
  42. "VOICE_STATE_UPDATE": VoiceStateUpdate{},
  43. }
  44. // Connect is an empty struct for an event.
  45. type Connect struct{}
  46. // Disconnect is an empty struct for an event.
  47. type Disconnect struct{}
  48. // MessageCreate is a wrapper struct for an event.
  49. type MessageCreate struct {
  50. *Message
  51. }
  52. // MessageUpdate is a wrapper struct for an event.
  53. type MessageUpdate struct {
  54. *Message
  55. }
  56. // MessageDelete is a wrapper struct for an event.
  57. type MessageDelete struct {
  58. *Message
  59. }
  60. // ChannelCreate is a wrapper struct for an event.
  61. type ChannelCreate struct {
  62. *Channel
  63. }
  64. // ChannelUpdate is a wrapper struct for an event.
  65. type ChannelUpdate struct {
  66. *Channel
  67. }
  68. // ChannelDelete is a wrapper struct for an event.
  69. type ChannelDelete struct {
  70. *Channel
  71. }
  72. // GuildCreate is a wrapper struct for an event.
  73. type GuildCreate struct {
  74. *Guild
  75. }
  76. // GuildUpdate is a wrapper struct for an event.
  77. type GuildUpdate struct {
  78. *Guild
  79. }
  80. // GuildDelete is a wrapper struct for an event.
  81. type GuildDelete struct {
  82. *Guild
  83. }
  84. // GuildBanAdd is a wrapper struct for an event.
  85. type GuildBanAdd struct {
  86. *GuildBan
  87. }
  88. // GuildBanRemove is a wrapper struct for an event.
  89. type GuildBanRemove struct {
  90. *GuildBan
  91. }
  92. // GuildMemberAdd is a wrapper struct for an event.
  93. type GuildMemberAdd struct {
  94. *Member
  95. }
  96. // GuildMemberUpdate is a wrapper struct for an event.
  97. type GuildMemberUpdate struct {
  98. *Member
  99. }
  100. // GuildMemberRemove is a wrapper struct for an event.
  101. type GuildMemberRemove struct {
  102. *Member
  103. }
  104. // GuildRoleCreate is a wrapper struct for an event.
  105. type GuildRoleCreate struct {
  106. *GuildRole
  107. }
  108. // GuildRoleUpdate is a wrapper struct for an event.
  109. type GuildRoleUpdate struct {
  110. *GuildRole
  111. }
  112. // VoiceStateUpdate is a wrapper struct for an event.
  113. type VoiceStateUpdate struct {
  114. *VoiceState
  115. }
  116. // UserUpdate is a wrapper struct for an event.
  117. type UserUpdate struct {
  118. *UserUpdate
  119. }
  120. // UserSettingsUpdate is a map for an event.
  121. type UserSettingsUpdate map[string]interface{}
  122. // UserGuildSettingsUpdate is a map for an event.
  123. type UserGuildSettingsUpdate struct {
  124. *UserGuildSettings
  125. }