arikawa/discord
diamondburned 17b9c73ce3
gateway: Refactor for a better concurrent API
This commit refactors the whole package gateway as well as utils/ws
(formerly utils/wsutil) and voice/voicegateway. The new refactor
utilizes a design pattern involving a concurrent loop and an arriving
event channel.

An additional change was made to the way gateway events are typed.
Before, pretty much any type will satisfy a gateway event type, since
the actual type was just interface{}. The new refactor defines a
concrete interface that events can implement:

    type Event interface {
        Op() OpCode
        EventType() EventType
    }

Using this interface, the user can easily add custom gateway events
independently of the library without relying on string maps. This adds a
lot of type safety into the library and makes type-switching on Event
types much more reasonable.

Gateway error callbacks are also almost entirely removed in favor of
custom gateway events. A catch-all can easily be added like this:

    s.AddHandler(func(err error) {
        log.Println("gateway error:, err")
    })
2021-11-25 14:46:41 -08:00
..
application.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
auditlog.go *: Migrated Go Modules to v3 2021-06-01 19:59:01 -07:00
channel.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
command.go discord: Add helper functions for creating commands and options 2021-11-18 15:15:03 -08:00
component.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
discord.go Discord: optimize struct sizes; add missing fields 2020-11-22 09:16:24 -08:00
emoji.go discord: Emoji methods use IsUnicode() 2021-05-29 14:16:44 -07:00
guild.go discord: Fix json tag for Guild.Features (#283) 2021-10-04 23:22:27 -07:00
guild_consts.go api: Threads (#257) 2021-08-08 13:19:15 -07:00
interaction.go discord: Use json.Unmarshal instead for CommandInteractionOption (#292) 2021-11-13 15:18:52 -08:00
invite.go Discord: fix #83 2020-05-17 10:34:47 -07:00
message.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
message_embed.go option: Move conflicting types into package discord 2021-08-30 13:23:43 -07:00
permission.go discord: Update to match current API docs (#277) 2021-09-23 21:37:50 -07:00
snowflake.go gateway: Refactor for a better concurrent API 2021-11-25 14:46:41 -08:00
snowflake_test.go Discord: Uint64 typed Snowflakes (#132) 2020-07-29 16:58:33 -07:00
snowflake_types.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
stage.go discord/api: Add StageInstances 2021-05-29 22:17:39 -07:00
time.go discord: Add VoiceState.SelfVideo; fixes #287 2021-10-30 16:43:28 -07:00
url.go Discord: fix typo 2020-05-15 22:13:15 +02:00
user.go discord: Minor comment tweaks 2021-11-16 14:36:07 -08:00
voice.go discord: Add VoiceState.SelfVideo; fixes #287 2021-10-30 16:43:28 -07:00
webhook.go discord: Add missing webhook fields (#250) 2021-08-02 16:14:34 -07:00