Commit Graph

202 Commits

Author SHA1 Message Date
ItsLychee 92897b4fc3
discord: Support guild Scheduled Events (#319)
* implement the gateway side of guild scheduled event
* Add proper punctuation to each docstring
* Fix UserAdd and UserRemove events
* Add MANAGE_EVENTS permission
* Implement the API-side of scheduled events
* Add ScheduledEvent method
* Cleanup
2022-04-02 22:36:45 -07:00
diamondburned 406171d7a9
discord: Deprecate MemberColor
Also fix State failing to fill up GuildID fields in Messages().
2022-04-01 04:42:23 -07:00
diamondburned 0cc36ee51e
discord: Add Color.String 2022-03-31 11:46:45 -07:00
diamondburned eae129c928
discord: MemberColor return bool 2022-03-31 11:42:22 -07:00
diamondburned eec8fcf719
discord: Clarify that IsNull isn't useful 2022-03-15 13:37:35 -07:00
Ven c0bfc217ca
discord: Add Icon/Emoji & Tags to Role (#313)
* discord: Add Icon/Emoji & Tags to Role
* oops :P
* Add Icon/Emoji to api/role
* Fix doc
* Fixes
2022-02-17 18:07:03 -08:00
Tyler Stuyfzand 6dc189519c
discord: Add Type to CommandInteractionOption (#312) 2022-02-13 22:40:26 -08:00
Tyler Stuyfzand c5f8fff98f
discord: Add Autocomplete flag to some options (#311)
* Add Autocomplete flags to Number and Integer options
* Add autocomplete warning for choices
2022-02-13 22:39:32 -08:00
ItsLychee d6bc738e50
discord: Modal interaction support (#310)
* Support modal interactions along with the TextInput component

* Replace ModalInteraction with Modal to prevent confusion

* Fix the required field from not being used correctly

* PR Fixes
2022-02-13 19:15:28 -08:00
diamondburned 3fe7fbc24b
discord: Add StickerItem, fix Sticker.TagList 2022-01-29 03:38:10 -08:00
PL Pery 9cd0c7ed28
discord: Add CommandInteractionOptions (#300)
* feat: Find method on options

* doc comment
2022-01-03 13:37:18 -08:00
diamondburned bfd668ff99
discord: Fix unmarshaling PingInteraction 2022-01-02 23:55:57 -08:00
diamondburned c14e68ac77
discord: Add missing NumberOption MarshalJSON 2021-12-29 11:10:59 -08:00
diamondburned 5c4a989746
discord: Add CommandInteraction.Resolved 2021-12-27 15:10:09 -08:00
starshines bc8a2b0cae
discord: Add timeouts (#299) 2021-12-20 15:56:11 -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 8d78221de0
discord: Improve union interface documentation; fix *Option JSON 2021-11-25 15:02:24 -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 e6be4a3fab
discord: Minor comment tweaks 2021-11-16 14:36:07 -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
Hamza Ali 6fba21d704
api: Implement autocomplete components 2021-11-09 14:49:21 -08:00
diamondburned e8131db8df
discord: Add VoiceState.SelfVideo; fixes #287 2021-10-30 16:43:28 -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
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
diamondburned 76ec9cd43d discord: Fix InteractionOption.String 2021-09-09 21:12:22 -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
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
rigormorrtiss e97dcb750c
discord: Add omitempty option to Attachment.ContentType (#263) 2021-08-12 11:45:48 -07:00
Juby210 21888dcfc2
discord: Add missing ContentType to Attachment (#262) 2021-08-11 18:16:50 -07:00
starshines f7880b91ee
discord: Add select component type (#260) 2021-08-10 14:02:30 -07:00
Maximilian von Lindern c00567599b
api: Threads (#257)
* api/gateway: Implement threads

* discord/api: rename PermissionOverwrites fields to Overwrites

* discord: rename Minutes to ArchiveDuration

* discord: Rename ArchiveDuration constants

Co-authored-by: diamondburned <datutbrus@gmail.com>
2021-08-08 13:19:15 -07:00
Maximilian von Lindern 101fe46313
api: Add missing slash command endpoints (#252)
* api: add missing slash command endpoints
* fix examples
* api: Remove Original prefix from Client.OriginalInteractionResponse,
  EditOriginalResponse, and DeleteOriginalResponse
2021-08-03 11:44:20 -07:00
Starshine System 127c6776ac discord: add missing command option types 2021-08-03 09:07:09 -07:00
rigormorrtiss 2fe1150d01
discord: Update Sticker struct, add missing fields (#251)
* Update Sticker struct & add missing fields

* Remove PreviewAsset field from Sticker

Co-authored-by: Maximilian von Lindern <maximilian.v.lindern@gmail.com>

* Update discord/message.go

Co-authored-by: Maximilian von Lindern <maximilian.v.lindern@gmail.com>

* Change Sticker.User type to *User

Co-authored-by: Maximilian von Lindern <maximilian.v.lindern@gmail.com>

* Update discord/message.go

Co-authored-by: Maximilian von Lindern <maximilian.v.lindern@gmail.com>

* Sticker types start from 0

Co-authored-by: Maximilian von Lindern <maximilian.v.lindern@gmail.com>

* Change Sticker.SortValue type to *int

Co-authored-by: Maximilian von Lindern <maximilian.v.lindern@gmail.com>

* Remove extra space

* Un-ignore Sticker.Tags field

Co-authored-by: Maximilian von Lindern <maximilian.v.lindern@gmail.com>

Co-authored-by: Maximilian von Lindern <maximilian.v.lindern@gmail.com>
2021-08-02 16:16:06 -07:00
Maximilian von Lindern ce4bd67f17
discord: Add missing webhook fields (#250)
* discord: add missing webhook fields
* discord: add missing ,omitempty tags on Webhook
* discord: add missing ,omitempty tags on Webhook
2021-08-02 16:14:34 -07:00
Starshine System 9651328b74
discord: Raise embed description limit to 4096 characters (#243) 2021-07-11 13:19:54 -07:00
samhza 1b12057e51
discord: Make OverboundError.Error() have a pointer receiver (#232) 2021-06-18 00:15:02 -07:00
samhza 37b8871c65
api: Update sending/editing messages for v9 (#230)
api.{Send,Edit}MessageData and their equivalents in package api/webhook
have been updated to add some fields added in Discord API v9.
(webhook.Client).EditMessage now also returns a message, because that
endpoint returns a message on success.
2021-06-17 23:32:11 -07:00