eventhandlers.go 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. // Code generated by \"eventhandlers\"; DO NOT EDIT
  2. // See events.go
  3. package discordgo
  4. // Following are all the event types.
  5. // Event type values are used to match the events returned by Discord.
  6. // EventTypes surrounded by __ are synthetic and are internal to DiscordGo.
  7. const (
  8. channelCreateEventType = "CHANNEL_CREATE"
  9. channelDeleteEventType = "CHANNEL_DELETE"
  10. channelPinsUpdateEventType = "CHANNEL_PINS_UPDATE"
  11. channelUpdateEventType = "CHANNEL_UPDATE"
  12. connectEventType = "__CONNECT__"
  13. disconnectEventType = "__DISCONNECT__"
  14. eventEventType = "__EVENT__"
  15. guildBanAddEventType = "GUILD_BAN_ADD"
  16. guildBanRemoveEventType = "GUILD_BAN_REMOVE"
  17. guildCreateEventType = "GUILD_CREATE"
  18. guildDeleteEventType = "GUILD_DELETE"
  19. guildEmojisUpdateEventType = "GUILD_EMOJIS_UPDATE"
  20. guildIntegrationsUpdateEventType = "GUILD_INTEGRATIONS_UPDATE"
  21. guildMemberAddEventType = "GUILD_MEMBER_ADD"
  22. guildMemberRemoveEventType = "GUILD_MEMBER_REMOVE"
  23. guildMemberUpdateEventType = "GUILD_MEMBER_UPDATE"
  24. guildMembersChunkEventType = "GUILD_MEMBERS_CHUNK"
  25. guildRoleCreateEventType = "GUILD_ROLE_CREATE"
  26. guildRoleDeleteEventType = "GUILD_ROLE_DELETE"
  27. guildRoleUpdateEventType = "GUILD_ROLE_UPDATE"
  28. guildUpdateEventType = "GUILD_UPDATE"
  29. messageAckEventType = "MESSAGE_ACK"
  30. messageCreateEventType = "MESSAGE_CREATE"
  31. messageDeleteEventType = "MESSAGE_DELETE"
  32. messageDeleteBulkEventType = "MESSAGE_DELETE_BULK"
  33. messageReactionAddEventType = "MESSAGE_REACTION_ADD"
  34. messageReactionRemoveEventType = "MESSAGE_REACTION_REMOVE"
  35. messageReactionRemoveAllEventType = "MESSAGE_REACTION_REMOVE_ALL"
  36. messageUpdateEventType = "MESSAGE_UPDATE"
  37. presenceUpdateEventType = "PRESENCE_UPDATE"
  38. presencesReplaceEventType = "PRESENCES_REPLACE"
  39. rateLimitEventType = "__RATE_LIMIT__"
  40. readyEventType = "READY"
  41. relationshipAddEventType = "RELATIONSHIP_ADD"
  42. relationshipRemoveEventType = "RELATIONSHIP_REMOVE"
  43. resumedEventType = "RESUMED"
  44. typingStartEventType = "TYPING_START"
  45. userGuildSettingsUpdateEventType = "USER_GUILD_SETTINGS_UPDATE"
  46. userNoteUpdateEventType = "USER_NOTE_UPDATE"
  47. userSettingsUpdateEventType = "USER_SETTINGS_UPDATE"
  48. userUpdateEventType = "USER_UPDATE"
  49. voiceServerUpdateEventType = "VOICE_SERVER_UPDATE"
  50. voiceStateUpdateEventType = "VOICE_STATE_UPDATE"
  51. webhooksUpdateEventType = "WEBHOOKS_UPDATE"
  52. )
  53. // channelCreateEventHandler is an event handler for ChannelCreate events.
  54. type channelCreateEventHandler func(*Session, *ChannelCreate)
  55. // Type returns the event type for ChannelCreate events.
  56. func (eh channelCreateEventHandler) Type() string {
  57. return channelCreateEventType
  58. }
  59. // New returns a new instance of ChannelCreate.
  60. func (eh channelCreateEventHandler) New() interface{} {
  61. return &ChannelCreate{}
  62. }
  63. // Handle is the handler for ChannelCreate events.
  64. func (eh channelCreateEventHandler) Handle(s *Session, i interface{}) {
  65. if t, ok := i.(*ChannelCreate); ok {
  66. eh(s, t)
  67. }
  68. }
  69. // channelDeleteEventHandler is an event handler for ChannelDelete events.
  70. type channelDeleteEventHandler func(*Session, *ChannelDelete)
  71. // Type returns the event type for ChannelDelete events.
  72. func (eh channelDeleteEventHandler) Type() string {
  73. return channelDeleteEventType
  74. }
  75. // New returns a new instance of ChannelDelete.
  76. func (eh channelDeleteEventHandler) New() interface{} {
  77. return &ChannelDelete{}
  78. }
  79. // Handle is the handler for ChannelDelete events.
  80. func (eh channelDeleteEventHandler) Handle(s *Session, i interface{}) {
  81. if t, ok := i.(*ChannelDelete); ok {
  82. eh(s, t)
  83. }
  84. }
  85. // channelPinsUpdateEventHandler is an event handler for ChannelPinsUpdate events.
  86. type channelPinsUpdateEventHandler func(*Session, *ChannelPinsUpdate)
  87. // Type returns the event type for ChannelPinsUpdate events.
  88. func (eh channelPinsUpdateEventHandler) Type() string {
  89. return channelPinsUpdateEventType
  90. }
  91. // New returns a new instance of ChannelPinsUpdate.
  92. func (eh channelPinsUpdateEventHandler) New() interface{} {
  93. return &ChannelPinsUpdate{}
  94. }
  95. // Handle is the handler for ChannelPinsUpdate events.
  96. func (eh channelPinsUpdateEventHandler) Handle(s *Session, i interface{}) {
  97. if t, ok := i.(*ChannelPinsUpdate); ok {
  98. eh(s, t)
  99. }
  100. }
  101. // channelUpdateEventHandler is an event handler for ChannelUpdate events.
  102. type channelUpdateEventHandler func(*Session, *ChannelUpdate)
  103. // Type returns the event type for ChannelUpdate events.
  104. func (eh channelUpdateEventHandler) Type() string {
  105. return channelUpdateEventType
  106. }
  107. // New returns a new instance of ChannelUpdate.
  108. func (eh channelUpdateEventHandler) New() interface{} {
  109. return &ChannelUpdate{}
  110. }
  111. // Handle is the handler for ChannelUpdate events.
  112. func (eh channelUpdateEventHandler) Handle(s *Session, i interface{}) {
  113. if t, ok := i.(*ChannelUpdate); ok {
  114. eh(s, t)
  115. }
  116. }
  117. // connectEventHandler is an event handler for Connect events.
  118. type connectEventHandler func(*Session, *Connect)
  119. // Type returns the event type for Connect events.
  120. func (eh connectEventHandler) Type() string {
  121. return connectEventType
  122. }
  123. // Handle is the handler for Connect events.
  124. func (eh connectEventHandler) Handle(s *Session, i interface{}) {
  125. if t, ok := i.(*Connect); ok {
  126. eh(s, t)
  127. }
  128. }
  129. // disconnectEventHandler is an event handler for Disconnect events.
  130. type disconnectEventHandler func(*Session, *Disconnect)
  131. // Type returns the event type for Disconnect events.
  132. func (eh disconnectEventHandler) Type() string {
  133. return disconnectEventType
  134. }
  135. // Handle is the handler for Disconnect events.
  136. func (eh disconnectEventHandler) Handle(s *Session, i interface{}) {
  137. if t, ok := i.(*Disconnect); ok {
  138. eh(s, t)
  139. }
  140. }
  141. // eventEventHandler is an event handler for Event events.
  142. type eventEventHandler func(*Session, *Event)
  143. // Type returns the event type for Event events.
  144. func (eh eventEventHandler) Type() string {
  145. return eventEventType
  146. }
  147. // Handle is the handler for Event events.
  148. func (eh eventEventHandler) Handle(s *Session, i interface{}) {
  149. if t, ok := i.(*Event); ok {
  150. eh(s, t)
  151. }
  152. }
  153. // guildBanAddEventHandler is an event handler for GuildBanAdd events.
  154. type guildBanAddEventHandler func(*Session, *GuildBanAdd)
  155. // Type returns the event type for GuildBanAdd events.
  156. func (eh guildBanAddEventHandler) Type() string {
  157. return guildBanAddEventType
  158. }
  159. // New returns a new instance of GuildBanAdd.
  160. func (eh guildBanAddEventHandler) New() interface{} {
  161. return &GuildBanAdd{}
  162. }
  163. // Handle is the handler for GuildBanAdd events.
  164. func (eh guildBanAddEventHandler) Handle(s *Session, i interface{}) {
  165. if t, ok := i.(*GuildBanAdd); ok {
  166. eh(s, t)
  167. }
  168. }
  169. // guildBanRemoveEventHandler is an event handler for GuildBanRemove events.
  170. type guildBanRemoveEventHandler func(*Session, *GuildBanRemove)
  171. // Type returns the event type for GuildBanRemove events.
  172. func (eh guildBanRemoveEventHandler) Type() string {
  173. return guildBanRemoveEventType
  174. }
  175. // New returns a new instance of GuildBanRemove.
  176. func (eh guildBanRemoveEventHandler) New() interface{} {
  177. return &GuildBanRemove{}
  178. }
  179. // Handle is the handler for GuildBanRemove events.
  180. func (eh guildBanRemoveEventHandler) Handle(s *Session, i interface{}) {
  181. if t, ok := i.(*GuildBanRemove); ok {
  182. eh(s, t)
  183. }
  184. }
  185. // guildCreateEventHandler is an event handler for GuildCreate events.
  186. type guildCreateEventHandler func(*Session, *GuildCreate)
  187. // Type returns the event type for GuildCreate events.
  188. func (eh guildCreateEventHandler) Type() string {
  189. return guildCreateEventType
  190. }
  191. // New returns a new instance of GuildCreate.
  192. func (eh guildCreateEventHandler) New() interface{} {
  193. return &GuildCreate{}
  194. }
  195. // Handle is the handler for GuildCreate events.
  196. func (eh guildCreateEventHandler) Handle(s *Session, i interface{}) {
  197. if t, ok := i.(*GuildCreate); ok {
  198. eh(s, t)
  199. }
  200. }
  201. // guildDeleteEventHandler is an event handler for GuildDelete events.
  202. type guildDeleteEventHandler func(*Session, *GuildDelete)
  203. // Type returns the event type for GuildDelete events.
  204. func (eh guildDeleteEventHandler) Type() string {
  205. return guildDeleteEventType
  206. }
  207. // New returns a new instance of GuildDelete.
  208. func (eh guildDeleteEventHandler) New() interface{} {
  209. return &GuildDelete{}
  210. }
  211. // Handle is the handler for GuildDelete events.
  212. func (eh guildDeleteEventHandler) Handle(s *Session, i interface{}) {
  213. if t, ok := i.(*GuildDelete); ok {
  214. eh(s, t)
  215. }
  216. }
  217. // guildEmojisUpdateEventHandler is an event handler for GuildEmojisUpdate events.
  218. type guildEmojisUpdateEventHandler func(*Session, *GuildEmojisUpdate)
  219. // Type returns the event type for GuildEmojisUpdate events.
  220. func (eh guildEmojisUpdateEventHandler) Type() string {
  221. return guildEmojisUpdateEventType
  222. }
  223. // New returns a new instance of GuildEmojisUpdate.
  224. func (eh guildEmojisUpdateEventHandler) New() interface{} {
  225. return &GuildEmojisUpdate{}
  226. }
  227. // Handle is the handler for GuildEmojisUpdate events.
  228. func (eh guildEmojisUpdateEventHandler) Handle(s *Session, i interface{}) {
  229. if t, ok := i.(*GuildEmojisUpdate); ok {
  230. eh(s, t)
  231. }
  232. }
  233. // guildIntegrationsUpdateEventHandler is an event handler for GuildIntegrationsUpdate events.
  234. type guildIntegrationsUpdateEventHandler func(*Session, *GuildIntegrationsUpdate)
  235. // Type returns the event type for GuildIntegrationsUpdate events.
  236. func (eh guildIntegrationsUpdateEventHandler) Type() string {
  237. return guildIntegrationsUpdateEventType
  238. }
  239. // New returns a new instance of GuildIntegrationsUpdate.
  240. func (eh guildIntegrationsUpdateEventHandler) New() interface{} {
  241. return &GuildIntegrationsUpdate{}
  242. }
  243. // Handle is the handler for GuildIntegrationsUpdate events.
  244. func (eh guildIntegrationsUpdateEventHandler) Handle(s *Session, i interface{}) {
  245. if t, ok := i.(*GuildIntegrationsUpdate); ok {
  246. eh(s, t)
  247. }
  248. }
  249. // guildMemberAddEventHandler is an event handler for GuildMemberAdd events.
  250. type guildMemberAddEventHandler func(*Session, *GuildMemberAdd)
  251. // Type returns the event type for GuildMemberAdd events.
  252. func (eh guildMemberAddEventHandler) Type() string {
  253. return guildMemberAddEventType
  254. }
  255. // New returns a new instance of GuildMemberAdd.
  256. func (eh guildMemberAddEventHandler) New() interface{} {
  257. return &GuildMemberAdd{}
  258. }
  259. // Handle is the handler for GuildMemberAdd events.
  260. func (eh guildMemberAddEventHandler) Handle(s *Session, i interface{}) {
  261. if t, ok := i.(*GuildMemberAdd); ok {
  262. eh(s, t)
  263. }
  264. }
  265. // guildMemberRemoveEventHandler is an event handler for GuildMemberRemove events.
  266. type guildMemberRemoveEventHandler func(*Session, *GuildMemberRemove)
  267. // Type returns the event type for GuildMemberRemove events.
  268. func (eh guildMemberRemoveEventHandler) Type() string {
  269. return guildMemberRemoveEventType
  270. }
  271. // New returns a new instance of GuildMemberRemove.
  272. func (eh guildMemberRemoveEventHandler) New() interface{} {
  273. return &GuildMemberRemove{}
  274. }
  275. // Handle is the handler for GuildMemberRemove events.
  276. func (eh guildMemberRemoveEventHandler) Handle(s *Session, i interface{}) {
  277. if t, ok := i.(*GuildMemberRemove); ok {
  278. eh(s, t)
  279. }
  280. }
  281. // guildMemberUpdateEventHandler is an event handler for GuildMemberUpdate events.
  282. type guildMemberUpdateEventHandler func(*Session, *GuildMemberUpdate)
  283. // Type returns the event type for GuildMemberUpdate events.
  284. func (eh guildMemberUpdateEventHandler) Type() string {
  285. return guildMemberUpdateEventType
  286. }
  287. // New returns a new instance of GuildMemberUpdate.
  288. func (eh guildMemberUpdateEventHandler) New() interface{} {
  289. return &GuildMemberUpdate{}
  290. }
  291. // Handle is the handler for GuildMemberUpdate events.
  292. func (eh guildMemberUpdateEventHandler) Handle(s *Session, i interface{}) {
  293. if t, ok := i.(*GuildMemberUpdate); ok {
  294. eh(s, t)
  295. }
  296. }
  297. // guildMembersChunkEventHandler is an event handler for GuildMembersChunk events.
  298. type guildMembersChunkEventHandler func(*Session, *GuildMembersChunk)
  299. // Type returns the event type for GuildMembersChunk events.
  300. func (eh guildMembersChunkEventHandler) Type() string {
  301. return guildMembersChunkEventType
  302. }
  303. // New returns a new instance of GuildMembersChunk.
  304. func (eh guildMembersChunkEventHandler) New() interface{} {
  305. return &GuildMembersChunk{}
  306. }
  307. // Handle is the handler for GuildMembersChunk events.
  308. func (eh guildMembersChunkEventHandler) Handle(s *Session, i interface{}) {
  309. if t, ok := i.(*GuildMembersChunk); ok {
  310. eh(s, t)
  311. }
  312. }
  313. // guildRoleCreateEventHandler is an event handler for GuildRoleCreate events.
  314. type guildRoleCreateEventHandler func(*Session, *GuildRoleCreate)
  315. // Type returns the event type for GuildRoleCreate events.
  316. func (eh guildRoleCreateEventHandler) Type() string {
  317. return guildRoleCreateEventType
  318. }
  319. // New returns a new instance of GuildRoleCreate.
  320. func (eh guildRoleCreateEventHandler) New() interface{} {
  321. return &GuildRoleCreate{}
  322. }
  323. // Handle is the handler for GuildRoleCreate events.
  324. func (eh guildRoleCreateEventHandler) Handle(s *Session, i interface{}) {
  325. if t, ok := i.(*GuildRoleCreate); ok {
  326. eh(s, t)
  327. }
  328. }
  329. // guildRoleDeleteEventHandler is an event handler for GuildRoleDelete events.
  330. type guildRoleDeleteEventHandler func(*Session, *GuildRoleDelete)
  331. // Type returns the event type for GuildRoleDelete events.
  332. func (eh guildRoleDeleteEventHandler) Type() string {
  333. return guildRoleDeleteEventType
  334. }
  335. // New returns a new instance of GuildRoleDelete.
  336. func (eh guildRoleDeleteEventHandler) New() interface{} {
  337. return &GuildRoleDelete{}
  338. }
  339. // Handle is the handler for GuildRoleDelete events.
  340. func (eh guildRoleDeleteEventHandler) Handle(s *Session, i interface{}) {
  341. if t, ok := i.(*GuildRoleDelete); ok {
  342. eh(s, t)
  343. }
  344. }
  345. // guildRoleUpdateEventHandler is an event handler for GuildRoleUpdate events.
  346. type guildRoleUpdateEventHandler func(*Session, *GuildRoleUpdate)
  347. // Type returns the event type for GuildRoleUpdate events.
  348. func (eh guildRoleUpdateEventHandler) Type() string {
  349. return guildRoleUpdateEventType
  350. }
  351. // New returns a new instance of GuildRoleUpdate.
  352. func (eh guildRoleUpdateEventHandler) New() interface{} {
  353. return &GuildRoleUpdate{}
  354. }
  355. // Handle is the handler for GuildRoleUpdate events.
  356. func (eh guildRoleUpdateEventHandler) Handle(s *Session, i interface{}) {
  357. if t, ok := i.(*GuildRoleUpdate); ok {
  358. eh(s, t)
  359. }
  360. }
  361. // guildUpdateEventHandler is an event handler for GuildUpdate events.
  362. type guildUpdateEventHandler func(*Session, *GuildUpdate)
  363. // Type returns the event type for GuildUpdate events.
  364. func (eh guildUpdateEventHandler) Type() string {
  365. return guildUpdateEventType
  366. }
  367. // New returns a new instance of GuildUpdate.
  368. func (eh guildUpdateEventHandler) New() interface{} {
  369. return &GuildUpdate{}
  370. }
  371. // Handle is the handler for GuildUpdate events.
  372. func (eh guildUpdateEventHandler) Handle(s *Session, i interface{}) {
  373. if t, ok := i.(*GuildUpdate); ok {
  374. eh(s, t)
  375. }
  376. }
  377. // messageAckEventHandler is an event handler for MessageAck events.
  378. type messageAckEventHandler func(*Session, *MessageAck)
  379. // Type returns the event type for MessageAck events.
  380. func (eh messageAckEventHandler) Type() string {
  381. return messageAckEventType
  382. }
  383. // New returns a new instance of MessageAck.
  384. func (eh messageAckEventHandler) New() interface{} {
  385. return &MessageAck{}
  386. }
  387. // Handle is the handler for MessageAck events.
  388. func (eh messageAckEventHandler) Handle(s *Session, i interface{}) {
  389. if t, ok := i.(*MessageAck); ok {
  390. eh(s, t)
  391. }
  392. }
  393. // messageCreateEventHandler is an event handler for MessageCreate events.
  394. type messageCreateEventHandler func(*Session, *MessageCreate)
  395. // Type returns the event type for MessageCreate events.
  396. func (eh messageCreateEventHandler) Type() string {
  397. return messageCreateEventType
  398. }
  399. // New returns a new instance of MessageCreate.
  400. func (eh messageCreateEventHandler) New() interface{} {
  401. return &MessageCreate{}
  402. }
  403. // Handle is the handler for MessageCreate events.
  404. func (eh messageCreateEventHandler) Handle(s *Session, i interface{}) {
  405. if t, ok := i.(*MessageCreate); ok {
  406. eh(s, t)
  407. }
  408. }
  409. // messageDeleteEventHandler is an event handler for MessageDelete events.
  410. type messageDeleteEventHandler func(*Session, *MessageDelete)
  411. // Type returns the event type for MessageDelete events.
  412. func (eh messageDeleteEventHandler) Type() string {
  413. return messageDeleteEventType
  414. }
  415. // New returns a new instance of MessageDelete.
  416. func (eh messageDeleteEventHandler) New() interface{} {
  417. return &MessageDelete{}
  418. }
  419. // Handle is the handler for MessageDelete events.
  420. func (eh messageDeleteEventHandler) Handle(s *Session, i interface{}) {
  421. if t, ok := i.(*MessageDelete); ok {
  422. eh(s, t)
  423. }
  424. }
  425. // messageDeleteBulkEventHandler is an event handler for MessageDeleteBulk events.
  426. type messageDeleteBulkEventHandler func(*Session, *MessageDeleteBulk)
  427. // Type returns the event type for MessageDeleteBulk events.
  428. func (eh messageDeleteBulkEventHandler) Type() string {
  429. return messageDeleteBulkEventType
  430. }
  431. // New returns a new instance of MessageDeleteBulk.
  432. func (eh messageDeleteBulkEventHandler) New() interface{} {
  433. return &MessageDeleteBulk{}
  434. }
  435. // Handle is the handler for MessageDeleteBulk events.
  436. func (eh messageDeleteBulkEventHandler) Handle(s *Session, i interface{}) {
  437. if t, ok := i.(*MessageDeleteBulk); ok {
  438. eh(s, t)
  439. }
  440. }
  441. // messageReactionAddEventHandler is an event handler for MessageReactionAdd events.
  442. type messageReactionAddEventHandler func(*Session, *MessageReactionAdd)
  443. // Type returns the event type for MessageReactionAdd events.
  444. func (eh messageReactionAddEventHandler) Type() string {
  445. return messageReactionAddEventType
  446. }
  447. // New returns a new instance of MessageReactionAdd.
  448. func (eh messageReactionAddEventHandler) New() interface{} {
  449. return &MessageReactionAdd{}
  450. }
  451. // Handle is the handler for MessageReactionAdd events.
  452. func (eh messageReactionAddEventHandler) Handle(s *Session, i interface{}) {
  453. if t, ok := i.(*MessageReactionAdd); ok {
  454. eh(s, t)
  455. }
  456. }
  457. // messageReactionRemoveEventHandler is an event handler for MessageReactionRemove events.
  458. type messageReactionRemoveEventHandler func(*Session, *MessageReactionRemove)
  459. // Type returns the event type for MessageReactionRemove events.
  460. func (eh messageReactionRemoveEventHandler) Type() string {
  461. return messageReactionRemoveEventType
  462. }
  463. // New returns a new instance of MessageReactionRemove.
  464. func (eh messageReactionRemoveEventHandler) New() interface{} {
  465. return &MessageReactionRemove{}
  466. }
  467. // Handle is the handler for MessageReactionRemove events.
  468. func (eh messageReactionRemoveEventHandler) Handle(s *Session, i interface{}) {
  469. if t, ok := i.(*MessageReactionRemove); ok {
  470. eh(s, t)
  471. }
  472. }
  473. // messageReactionRemoveAllEventHandler is an event handler for MessageReactionRemoveAll events.
  474. type messageReactionRemoveAllEventHandler func(*Session, *MessageReactionRemoveAll)
  475. // Type returns the event type for MessageReactionRemoveAll events.
  476. func (eh messageReactionRemoveAllEventHandler) Type() string {
  477. return messageReactionRemoveAllEventType
  478. }
  479. // New returns a new instance of MessageReactionRemoveAll.
  480. func (eh messageReactionRemoveAllEventHandler) New() interface{} {
  481. return &MessageReactionRemoveAll{}
  482. }
  483. // Handle is the handler for MessageReactionRemoveAll events.
  484. func (eh messageReactionRemoveAllEventHandler) Handle(s *Session, i interface{}) {
  485. if t, ok := i.(*MessageReactionRemoveAll); ok {
  486. eh(s, t)
  487. }
  488. }
  489. // messageUpdateEventHandler is an event handler for MessageUpdate events.
  490. type messageUpdateEventHandler func(*Session, *MessageUpdate)
  491. // Type returns the event type for MessageUpdate events.
  492. func (eh messageUpdateEventHandler) Type() string {
  493. return messageUpdateEventType
  494. }
  495. // New returns a new instance of MessageUpdate.
  496. func (eh messageUpdateEventHandler) New() interface{} {
  497. return &MessageUpdate{}
  498. }
  499. // Handle is the handler for MessageUpdate events.
  500. func (eh messageUpdateEventHandler) Handle(s *Session, i interface{}) {
  501. if t, ok := i.(*MessageUpdate); ok {
  502. eh(s, t)
  503. }
  504. }
  505. // presenceUpdateEventHandler is an event handler for PresenceUpdate events.
  506. type presenceUpdateEventHandler func(*Session, *PresenceUpdate)
  507. // Type returns the event type for PresenceUpdate events.
  508. func (eh presenceUpdateEventHandler) Type() string {
  509. return presenceUpdateEventType
  510. }
  511. // New returns a new instance of PresenceUpdate.
  512. func (eh presenceUpdateEventHandler) New() interface{} {
  513. return &PresenceUpdate{}
  514. }
  515. // Handle is the handler for PresenceUpdate events.
  516. func (eh presenceUpdateEventHandler) Handle(s *Session, i interface{}) {
  517. if t, ok := i.(*PresenceUpdate); ok {
  518. eh(s, t)
  519. }
  520. }
  521. // presencesReplaceEventHandler is an event handler for PresencesReplace events.
  522. type presencesReplaceEventHandler func(*Session, *PresencesReplace)
  523. // Type returns the event type for PresencesReplace events.
  524. func (eh presencesReplaceEventHandler) Type() string {
  525. return presencesReplaceEventType
  526. }
  527. // New returns a new instance of PresencesReplace.
  528. func (eh presencesReplaceEventHandler) New() interface{} {
  529. return &PresencesReplace{}
  530. }
  531. // Handle is the handler for PresencesReplace events.
  532. func (eh presencesReplaceEventHandler) Handle(s *Session, i interface{}) {
  533. if t, ok := i.(*PresencesReplace); ok {
  534. eh(s, t)
  535. }
  536. }
  537. // rateLimitEventHandler is an event handler for RateLimit events.
  538. type rateLimitEventHandler func(*Session, *RateLimit)
  539. // Type returns the event type for RateLimit events.
  540. func (eh rateLimitEventHandler) Type() string {
  541. return rateLimitEventType
  542. }
  543. // Handle is the handler for RateLimit events.
  544. func (eh rateLimitEventHandler) Handle(s *Session, i interface{}) {
  545. if t, ok := i.(*RateLimit); ok {
  546. eh(s, t)
  547. }
  548. }
  549. // readyEventHandler is an event handler for Ready events.
  550. type readyEventHandler func(*Session, *Ready)
  551. // Type returns the event type for Ready events.
  552. func (eh readyEventHandler) Type() string {
  553. return readyEventType
  554. }
  555. // New returns a new instance of Ready.
  556. func (eh readyEventHandler) New() interface{} {
  557. return &Ready{}
  558. }
  559. // Handle is the handler for Ready events.
  560. func (eh readyEventHandler) Handle(s *Session, i interface{}) {
  561. if t, ok := i.(*Ready); ok {
  562. eh(s, t)
  563. }
  564. }
  565. // relationshipAddEventHandler is an event handler for RelationshipAdd events.
  566. type relationshipAddEventHandler func(*Session, *RelationshipAdd)
  567. // Type returns the event type for RelationshipAdd events.
  568. func (eh relationshipAddEventHandler) Type() string {
  569. return relationshipAddEventType
  570. }
  571. // New returns a new instance of RelationshipAdd.
  572. func (eh relationshipAddEventHandler) New() interface{} {
  573. return &RelationshipAdd{}
  574. }
  575. // Handle is the handler for RelationshipAdd events.
  576. func (eh relationshipAddEventHandler) Handle(s *Session, i interface{}) {
  577. if t, ok := i.(*RelationshipAdd); ok {
  578. eh(s, t)
  579. }
  580. }
  581. // relationshipRemoveEventHandler is an event handler for RelationshipRemove events.
  582. type relationshipRemoveEventHandler func(*Session, *RelationshipRemove)
  583. // Type returns the event type for RelationshipRemove events.
  584. func (eh relationshipRemoveEventHandler) Type() string {
  585. return relationshipRemoveEventType
  586. }
  587. // New returns a new instance of RelationshipRemove.
  588. func (eh relationshipRemoveEventHandler) New() interface{} {
  589. return &RelationshipRemove{}
  590. }
  591. // Handle is the handler for RelationshipRemove events.
  592. func (eh relationshipRemoveEventHandler) Handle(s *Session, i interface{}) {
  593. if t, ok := i.(*RelationshipRemove); ok {
  594. eh(s, t)
  595. }
  596. }
  597. // resumedEventHandler is an event handler for Resumed events.
  598. type resumedEventHandler func(*Session, *Resumed)
  599. // Type returns the event type for Resumed events.
  600. func (eh resumedEventHandler) Type() string {
  601. return resumedEventType
  602. }
  603. // New returns a new instance of Resumed.
  604. func (eh resumedEventHandler) New() interface{} {
  605. return &Resumed{}
  606. }
  607. // Handle is the handler for Resumed events.
  608. func (eh resumedEventHandler) Handle(s *Session, i interface{}) {
  609. if t, ok := i.(*Resumed); ok {
  610. eh(s, t)
  611. }
  612. }
  613. // typingStartEventHandler is an event handler for TypingStart events.
  614. type typingStartEventHandler func(*Session, *TypingStart)
  615. // Type returns the event type for TypingStart events.
  616. func (eh typingStartEventHandler) Type() string {
  617. return typingStartEventType
  618. }
  619. // New returns a new instance of TypingStart.
  620. func (eh typingStartEventHandler) New() interface{} {
  621. return &TypingStart{}
  622. }
  623. // Handle is the handler for TypingStart events.
  624. func (eh typingStartEventHandler) Handle(s *Session, i interface{}) {
  625. if t, ok := i.(*TypingStart); ok {
  626. eh(s, t)
  627. }
  628. }
  629. // userGuildSettingsUpdateEventHandler is an event handler for UserGuildSettingsUpdate events.
  630. type userGuildSettingsUpdateEventHandler func(*Session, *UserGuildSettingsUpdate)
  631. // Type returns the event type for UserGuildSettingsUpdate events.
  632. func (eh userGuildSettingsUpdateEventHandler) Type() string {
  633. return userGuildSettingsUpdateEventType
  634. }
  635. // New returns a new instance of UserGuildSettingsUpdate.
  636. func (eh userGuildSettingsUpdateEventHandler) New() interface{} {
  637. return &UserGuildSettingsUpdate{}
  638. }
  639. // Handle is the handler for UserGuildSettingsUpdate events.
  640. func (eh userGuildSettingsUpdateEventHandler) Handle(s *Session, i interface{}) {
  641. if t, ok := i.(*UserGuildSettingsUpdate); ok {
  642. eh(s, t)
  643. }
  644. }
  645. // userNoteUpdateEventHandler is an event handler for UserNoteUpdate events.
  646. type userNoteUpdateEventHandler func(*Session, *UserNoteUpdate)
  647. // Type returns the event type for UserNoteUpdate events.
  648. func (eh userNoteUpdateEventHandler) Type() string {
  649. return userNoteUpdateEventType
  650. }
  651. // New returns a new instance of UserNoteUpdate.
  652. func (eh userNoteUpdateEventHandler) New() interface{} {
  653. return &UserNoteUpdate{}
  654. }
  655. // Handle is the handler for UserNoteUpdate events.
  656. func (eh userNoteUpdateEventHandler) Handle(s *Session, i interface{}) {
  657. if t, ok := i.(*UserNoteUpdate); ok {
  658. eh(s, t)
  659. }
  660. }
  661. // userSettingsUpdateEventHandler is an event handler for UserSettingsUpdate events.
  662. type userSettingsUpdateEventHandler func(*Session, *UserSettingsUpdate)
  663. // Type returns the event type for UserSettingsUpdate events.
  664. func (eh userSettingsUpdateEventHandler) Type() string {
  665. return userSettingsUpdateEventType
  666. }
  667. // New returns a new instance of UserSettingsUpdate.
  668. func (eh userSettingsUpdateEventHandler) New() interface{} {
  669. return &UserSettingsUpdate{}
  670. }
  671. // Handle is the handler for UserSettingsUpdate events.
  672. func (eh userSettingsUpdateEventHandler) Handle(s *Session, i interface{}) {
  673. if t, ok := i.(*UserSettingsUpdate); ok {
  674. eh(s, t)
  675. }
  676. }
  677. // userUpdateEventHandler is an event handler for UserUpdate events.
  678. type userUpdateEventHandler func(*Session, *UserUpdate)
  679. // Type returns the event type for UserUpdate events.
  680. func (eh userUpdateEventHandler) Type() string {
  681. return userUpdateEventType
  682. }
  683. // New returns a new instance of UserUpdate.
  684. func (eh userUpdateEventHandler) New() interface{} {
  685. return &UserUpdate{}
  686. }
  687. // Handle is the handler for UserUpdate events.
  688. func (eh userUpdateEventHandler) Handle(s *Session, i interface{}) {
  689. if t, ok := i.(*UserUpdate); ok {
  690. eh(s, t)
  691. }
  692. }
  693. // voiceServerUpdateEventHandler is an event handler for VoiceServerUpdate events.
  694. type voiceServerUpdateEventHandler func(*Session, *VoiceServerUpdate)
  695. // Type returns the event type for VoiceServerUpdate events.
  696. func (eh voiceServerUpdateEventHandler) Type() string {
  697. return voiceServerUpdateEventType
  698. }
  699. // New returns a new instance of VoiceServerUpdate.
  700. func (eh voiceServerUpdateEventHandler) New() interface{} {
  701. return &VoiceServerUpdate{}
  702. }
  703. // Handle is the handler for VoiceServerUpdate events.
  704. func (eh voiceServerUpdateEventHandler) Handle(s *Session, i interface{}) {
  705. if t, ok := i.(*VoiceServerUpdate); ok {
  706. eh(s, t)
  707. }
  708. }
  709. // voiceStateUpdateEventHandler is an event handler for VoiceStateUpdate events.
  710. type voiceStateUpdateEventHandler func(*Session, *VoiceStateUpdate)
  711. // Type returns the event type for VoiceStateUpdate events.
  712. func (eh voiceStateUpdateEventHandler) Type() string {
  713. return voiceStateUpdateEventType
  714. }
  715. // New returns a new instance of VoiceStateUpdate.
  716. func (eh voiceStateUpdateEventHandler) New() interface{} {
  717. return &VoiceStateUpdate{}
  718. }
  719. // Handle is the handler for VoiceStateUpdate events.
  720. func (eh voiceStateUpdateEventHandler) Handle(s *Session, i interface{}) {
  721. if t, ok := i.(*VoiceStateUpdate); ok {
  722. eh(s, t)
  723. }
  724. }
  725. // webhooksUpdateEventHandler is an event handler for WebhooksUpdate events.
  726. type webhooksUpdateEventHandler func(*Session, *WebhooksUpdate)
  727. // Type returns the event type for WebhooksUpdate events.
  728. func (eh webhooksUpdateEventHandler) Type() string {
  729. return webhooksUpdateEventType
  730. }
  731. // New returns a new instance of WebhooksUpdate.
  732. func (eh webhooksUpdateEventHandler) New() interface{} {
  733. return &WebhooksUpdate{}
  734. }
  735. // Handle is the handler for WebhooksUpdate events.
  736. func (eh webhooksUpdateEventHandler) Handle(s *Session, i interface{}) {
  737. if t, ok := i.(*WebhooksUpdate); ok {
  738. eh(s, t)
  739. }
  740. }
  741. func handlerForInterface(handler interface{}) EventHandler {
  742. switch v := handler.(type) {
  743. case func(*Session, interface{}):
  744. return interfaceEventHandler(v)
  745. case func(*Session, *ChannelCreate):
  746. return channelCreateEventHandler(v)
  747. case func(*Session, *ChannelDelete):
  748. return channelDeleteEventHandler(v)
  749. case func(*Session, *ChannelPinsUpdate):
  750. return channelPinsUpdateEventHandler(v)
  751. case func(*Session, *ChannelUpdate):
  752. return channelUpdateEventHandler(v)
  753. case func(*Session, *Connect):
  754. return connectEventHandler(v)
  755. case func(*Session, *Disconnect):
  756. return disconnectEventHandler(v)
  757. case func(*Session, *Event):
  758. return eventEventHandler(v)
  759. case func(*Session, *GuildBanAdd):
  760. return guildBanAddEventHandler(v)
  761. case func(*Session, *GuildBanRemove):
  762. return guildBanRemoveEventHandler(v)
  763. case func(*Session, *GuildCreate):
  764. return guildCreateEventHandler(v)
  765. case func(*Session, *GuildDelete):
  766. return guildDeleteEventHandler(v)
  767. case func(*Session, *GuildEmojisUpdate):
  768. return guildEmojisUpdateEventHandler(v)
  769. case func(*Session, *GuildIntegrationsUpdate):
  770. return guildIntegrationsUpdateEventHandler(v)
  771. case func(*Session, *GuildMemberAdd):
  772. return guildMemberAddEventHandler(v)
  773. case func(*Session, *GuildMemberRemove):
  774. return guildMemberRemoveEventHandler(v)
  775. case func(*Session, *GuildMemberUpdate):
  776. return guildMemberUpdateEventHandler(v)
  777. case func(*Session, *GuildMembersChunk):
  778. return guildMembersChunkEventHandler(v)
  779. case func(*Session, *GuildRoleCreate):
  780. return guildRoleCreateEventHandler(v)
  781. case func(*Session, *GuildRoleDelete):
  782. return guildRoleDeleteEventHandler(v)
  783. case func(*Session, *GuildRoleUpdate):
  784. return guildRoleUpdateEventHandler(v)
  785. case func(*Session, *GuildUpdate):
  786. return guildUpdateEventHandler(v)
  787. case func(*Session, *MessageAck):
  788. return messageAckEventHandler(v)
  789. case func(*Session, *MessageCreate):
  790. return messageCreateEventHandler(v)
  791. case func(*Session, *MessageDelete):
  792. return messageDeleteEventHandler(v)
  793. case func(*Session, *MessageDeleteBulk):
  794. return messageDeleteBulkEventHandler(v)
  795. case func(*Session, *MessageReactionAdd):
  796. return messageReactionAddEventHandler(v)
  797. case func(*Session, *MessageReactionRemove):
  798. return messageReactionRemoveEventHandler(v)
  799. case func(*Session, *MessageReactionRemoveAll):
  800. return messageReactionRemoveAllEventHandler(v)
  801. case func(*Session, *MessageUpdate):
  802. return messageUpdateEventHandler(v)
  803. case func(*Session, *PresenceUpdate):
  804. return presenceUpdateEventHandler(v)
  805. case func(*Session, *PresencesReplace):
  806. return presencesReplaceEventHandler(v)
  807. case func(*Session, *RateLimit):
  808. return rateLimitEventHandler(v)
  809. case func(*Session, *Ready):
  810. return readyEventHandler(v)
  811. case func(*Session, *RelationshipAdd):
  812. return relationshipAddEventHandler(v)
  813. case func(*Session, *RelationshipRemove):
  814. return relationshipRemoveEventHandler(v)
  815. case func(*Session, *Resumed):
  816. return resumedEventHandler(v)
  817. case func(*Session, *TypingStart):
  818. return typingStartEventHandler(v)
  819. case func(*Session, *UserGuildSettingsUpdate):
  820. return userGuildSettingsUpdateEventHandler(v)
  821. case func(*Session, *UserNoteUpdate):
  822. return userNoteUpdateEventHandler(v)
  823. case func(*Session, *UserSettingsUpdate):
  824. return userSettingsUpdateEventHandler(v)
  825. case func(*Session, *UserUpdate):
  826. return userUpdateEventHandler(v)
  827. case func(*Session, *VoiceServerUpdate):
  828. return voiceServerUpdateEventHandler(v)
  829. case func(*Session, *VoiceStateUpdate):
  830. return voiceStateUpdateEventHandler(v)
  831. case func(*Session, *WebhooksUpdate):
  832. return webhooksUpdateEventHandler(v)
  833. }
  834. return nil
  835. }
  836. func init() {
  837. registerInterfaceProvider(channelCreateEventHandler(nil))
  838. registerInterfaceProvider(channelDeleteEventHandler(nil))
  839. registerInterfaceProvider(channelPinsUpdateEventHandler(nil))
  840. registerInterfaceProvider(channelUpdateEventHandler(nil))
  841. registerInterfaceProvider(guildBanAddEventHandler(nil))
  842. registerInterfaceProvider(guildBanRemoveEventHandler(nil))
  843. registerInterfaceProvider(guildCreateEventHandler(nil))
  844. registerInterfaceProvider(guildDeleteEventHandler(nil))
  845. registerInterfaceProvider(guildEmojisUpdateEventHandler(nil))
  846. registerInterfaceProvider(guildIntegrationsUpdateEventHandler(nil))
  847. registerInterfaceProvider(guildMemberAddEventHandler(nil))
  848. registerInterfaceProvider(guildMemberRemoveEventHandler(nil))
  849. registerInterfaceProvider(guildMemberUpdateEventHandler(nil))
  850. registerInterfaceProvider(guildMembersChunkEventHandler(nil))
  851. registerInterfaceProvider(guildRoleCreateEventHandler(nil))
  852. registerInterfaceProvider(guildRoleDeleteEventHandler(nil))
  853. registerInterfaceProvider(guildRoleUpdateEventHandler(nil))
  854. registerInterfaceProvider(guildUpdateEventHandler(nil))
  855. registerInterfaceProvider(messageAckEventHandler(nil))
  856. registerInterfaceProvider(messageCreateEventHandler(nil))
  857. registerInterfaceProvider(messageDeleteEventHandler(nil))
  858. registerInterfaceProvider(messageDeleteBulkEventHandler(nil))
  859. registerInterfaceProvider(messageReactionAddEventHandler(nil))
  860. registerInterfaceProvider(messageReactionRemoveEventHandler(nil))
  861. registerInterfaceProvider(messageReactionRemoveAllEventHandler(nil))
  862. registerInterfaceProvider(messageUpdateEventHandler(nil))
  863. registerInterfaceProvider(presenceUpdateEventHandler(nil))
  864. registerInterfaceProvider(presencesReplaceEventHandler(nil))
  865. registerInterfaceProvider(readyEventHandler(nil))
  866. registerInterfaceProvider(relationshipAddEventHandler(nil))
  867. registerInterfaceProvider(relationshipRemoveEventHandler(nil))
  868. registerInterfaceProvider(resumedEventHandler(nil))
  869. registerInterfaceProvider(typingStartEventHandler(nil))
  870. registerInterfaceProvider(userGuildSettingsUpdateEventHandler(nil))
  871. registerInterfaceProvider(userNoteUpdateEventHandler(nil))
  872. registerInterfaceProvider(userSettingsUpdateEventHandler(nil))
  873. registerInterfaceProvider(userUpdateEventHandler(nil))
  874. registerInterfaceProvider(voiceServerUpdateEventHandler(nil))
  875. registerInterfaceProvider(voiceStateUpdateEventHandler(nil))
  876. registerInterfaceProvider(webhooksUpdateEventHandler(nil))
  877. }