1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-14 02:42:51 +00:00
Commit graph

854 commits

Author SHA1 Message Date
diamondburned 054f4de0e1 state: Add NewWithIdentifier 2021-12-14 13:49:34 -08:00
diamondburned 54cadd2f45 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-12-14 13:49:34 -08:00
diamondburned 07a2c407e0
discord: Fix incorrect Min/Max fields in command.go 2021-12-02 13:21:47 -08:00
diamondburned 172d448e74
discord: Add {Min,Max} into {Integer,Number}Option 2021-12-01 12:11:59 -08:00
diamondburned 7af6e23569
utils/httputil: Fix build error from previous commit 2021-11-29 12:41:13 -08:00
diamondburned 1e14369fc0
utils/httputil: HTTPError print JSON error if possible 2021-11-29 12:28:51 -08:00
diamondburned 8d78221de0
discord: Improve union interface documentation; fix *Option JSON 2021-11-25 15:02:24 -08:00
diamondburned 5c88317130
api: Fix CreateInteractionFollowup return 2021-11-23 22:53:27 -08:00
Samuel Hernandez c3b7383b77 discord: Add helper functions for creating commands and options 2021-11-18 15:15:03 -08:00
Samuel Hernandez 9edf2f9565 discord: Remove Choice types except for String, Integer, and Number
Choices are only valid for StringOptions, IntegerOptions, and
NumberOptions, so get rid of the invalid fields.
2021-11-18 15:15:03 -08:00
diamondburned 6d89542403
utils: Remove unused json.AlwaysString 2021-11-16 14:36:41 -08:00
diamondburned e6be4a3fab
discord: Minor comment tweaks 2021-11-16 14:36:07 -08:00
Tadeo Kondrak 9289303255 examples: Add autocomplete example 2021-11-15 14:30:48 -08:00
Tadeo Kondrak 2ec0e6b011
discord: Use json.Unmarshal instead for CommandInteractionOption (#292)
This ensures valid JSON strings are processed using the JSON rules, not
the Go rules.
2021-11-13 15:18:52 -08:00
Tadeo Kondrak c98e2f8730 discord: Add Options field to AutocompleteOption
This is used for subcommands.
2021-11-13 13:45:26 -08:00
diamondburned 331ec59dec discord: Refactor interactions and components
This commit gets rid of contain-it-all structs and instead opt for
interface union types containing underlying concrete types with no
overloading.

The code is much more verbose by doing this, but the API is much nicer
to use. The only disadvantage in that regard is the interface assertion
being too verbose and risky for users at times.
2021-11-12 11:38:36 -08:00
diamondburned 8abd5bc86e
readme: Fix bot import path 2021-11-09 18:30:58 -08:00
diamondburned 5c6d0f8977
example: Fix CI for previous rename 2021-11-09 16:02:27 -08:00
diamondburned 1b154cb65f
example: Rename _example to 0-examples
This commit renames the examples folder so gopls can pick it up.
2021-11-09 15:56:51 -08:00
Hamza Ali 6fba21d704
api: Implement autocomplete components 2021-11-09 14:49:21 -08:00
Hamza Ali 028a341597
*: Update go dependencies 2021-11-09 14:49:18 -08:00
diamondburned 123f8bc41f
voice: Fix init inconsistencies
This commit fixes a few subtle bugs in the voice package. It slightly
refactors the connecting and reconnecting of voice sessions.
2021-11-04 14:21:46 -07:00
diamondburned accb2fc52b
example/undeleter: Fix AddSyncHandler 2021-11-03 15:43:07 -07:00
diamondburned 477695f2e6
readme: Fix build badge 2021-11-03 15:42:37 -07:00
diamondburned 0d13edc8fd
gateway: Add ClientState and Capabilities for Identify
This commit preps the gateway for user account usage.
2021-11-03 15:29:29 -07:00
diamondburned efde3f4ea6
state, handler: Refactor state storage and sync handlers
This commit refactors a lot of packages.

It refactors the handler package, removing the Synchronous field and
replacing it the AddSyncHandler API, which allows each handler to
control whether or not it should be ran synchronously independent of
other handlers. This is useful for libraries that need to guarantee the
incoming order of events.

It also refactors the store interfaces to accept more interfaces. This
is to make the API more consistent as well as reducing potential useless
copies. The public-facing state API should still be the same, so this
change will mostly concern users with their own store implementations.

Several miscellaneous functions (such as a few in package gateway) were
modified to be more suitable to other packages, but those functions
should rarely ever be used, anyway.

Several tests are also fixed within this commit, namely fixing state's
intents bug.
2021-11-03 15:16:02 -07:00
diamondburned 7f4daccd2d
shard: Separate state's cabinet, fix return bugs
This commit makes it so that all sharded state.State instances will have
its own cabinet store on construction. This ensures that when a State is
reconnected, a Ready event won't wipe the cabinet for all other states.

This commit also fixes a bug with the Shard() and FromGuildID() getters.
2021-10-31 13:10:34 -07:00
diamondburned e8131db8df
discord: Add VoiceState.SelfVideo; fixes #287 2021-10-30 16:43:28 -07:00
Maximilian von Lindern 528281b739
gateway: Fix Context overwrite in Gateway.Open (#285)
* Gateway: Fix Gateway.Open overwriting the context argument

* WSUtil: Remove max context timeout in Websocket.Dial

* WSUtil: Use Websocket.Timeout if a no-deadline context is given to .Dial

* WSUtil: Add doc to Websocket.Timeout clarifying that it must not be changed after use
2021-10-20 15:06:06 -07:00
Nat 918cce64e9
discord: Fix json tag for Guild.Features (#283) 2021-10-04 23:22:27 -07:00
samhza bfb644c124
api: Add CurrentApplication (#282)
* discord/api: support fetching bot's Application

* Update api/application.go

Co-authored-by: diamondburned <diamond@arikawa-hi.me>

Co-authored-by: diamondburned <diamond@arikawa-hi.me>
2021-10-03 13:31:48 -07:00
starshines 8ea320ccb9
discord: Add ChannelType field to CommandOption (#279)
* discord: add ChannelType field to CommandOption

* preallocate option.ChannelTypes

Co-authored-by: diamondburned <diamond@arikawa-hi.me>

Co-authored-by: diamondburned <diamond@arikawa-hi.me>
2021-09-28 14:12:04 -07:00
starshines ca70e0cca9
discord: Add per-guild avatars, ModifyMe -> ModifyCurrentUser (#278)
* v3: discord, api, gateway: add per-guild avatars

* api: rename ModifyMe to ModifyCurrentUser
2021-09-28 11:46:36 -07:00
diamondburned 95231f5772
CI: Update dismock 2021-09-23 22:28:02 -07:00
samhza e203e31ab3
discord: Update to match current API docs (#277)
* discord: update permission constants

* discord: update MessageType constants, add ephemeral field to Attachment

Renamed ApplicationCommandMessage to ChatInputCommandMessage and add
ContextMenuCommand. Add the ephemeral field to Attachment.

* discord: add version field to Command

* gateway: remove ApplicationCommandUpdateEvent

52f1824451
2021-09-23 21:37:50 -07:00
Maximilian von Lindern 5d2d39d422
gateway: Fix typo in GuildEmojisUpdateEvent.Emojis JSON tag (#276) 2021-09-22 10:57:14 -07:00
diamondburned b2e852d140
bot: Fix previous breaking change 2021-09-22 10:56:40 -07:00
diamondburned 76c25835b7
bot: Move bot to utils 2021-09-18 00:39:34 -07:00
diamondburned 76ec9cd43d discord: Fix InteractionOption.String 2021-09-09 21:12:22 -07:00
samhza 4023a58f67
gateway: Change type of IdentifyData.Intents to option.Uint (#275) 2021-09-09 18:45:08 -07:00
samhza dc92845315
discord: move Interaction over; update api.CommandCreateData (#274)
- Moved gateway.InteractionCreateData to discord.Interaction, now
gateway.InteractionCreateData is a struct that wraps
discord.Interaction.
- Split InteractionData into CommandInteractionData and
ComponentInteractionData.
- Renamed ButtonInteraction to ComponentInteraction.
- Updated api.CommandCreateData to add new fields.
- Update Component types' Type() methods to pointer receivers.
2021-09-09 16:06:44 -07:00
Maximilian von Lindern 02712516e3 discord: Change type of SelectComponent.MinValues to option.Int 2021-08-30 13:23:43 -07:00
Maximilian von Lindern 53c72c1e16 option: Move conflicting types into package discord 2021-08-30 13:23:43 -07:00
Maximilian von Lindern 2647267460
discord: Fix style issues (#272)
* Discord: Fix comment style issues

* Discord: use URL type alias for URls instead of string
2021-08-30 13:15:59 -07:00
Maximilian von Lindern f334491dee
api: Mutate validated embeds from discord.Embed.Validate (#271) 2021-08-24 11:23:49 -07:00
rigormorrtiss 1e9eb4a473
api: *Client.ActiveThreads returns ActiveThreads struct (#270)
* v3: api: *Client.ActiveThreads returns ActiveThread struct

* Apply suggestions
2021-08-20 02:27:53 -07:00
diamondburned 64bd519156 state: Store Threads as channels 2021-08-19 20:58:38 -07:00
Maximilian von Lindern b61179d188 api: Remove Client.Kick and rename .KickWithReason to .Kick 2021-08-18 11:31:16 -07:00
rigormorrtiss eece98903a
discord: Add Banner & Accent fields to User (#267)
* feat(discord): add banner & accent_color field to User struct

* feat(discord): use type Color (uint32) for User.AccentColor

* discord: change field name to Accent
2021-08-16 23:48:36 -07:00
rigormorrtiss b253a5659b
discord: Add Invitable field for threads (#268) 2021-08-16 22:37:33 -07:00