events.go 3.6 KB

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