Commit Graph

251 Commits

Author SHA1 Message Date
diamondburned b6f6372816
Fix up naming and minor fixes 2022-09-21 13:10:59 -07:00
Sven Wiltink b7421315ea Add Tag and TagID for forum capabilities 2022-09-21 15:08:17 +00:00
diamondburned 75ff7342b1
api: Add InteractionHandlerFunc 2022-08-23 13:42:29 -07:00
diamondburned 9e9f90a652
webhook: Add missing Content-Type for Pong 2022-08-22 14:43:49 -07:00
diamondburned 22e8d607ad
api: Fix InteractionServer's writeError 2022-08-22 03:21:12 -07:00
diamondburned 17c26bf488
webhook: Add InteractionServer
This commit adds Interaction webhook server support directly into the
library.

Bots can now support both receiving events through the Discord gateway
and the Interaction webhook handler within the same library.
2022-08-22 02:18:00 -07:00
diamondburned a25b21d020
api: omitempty InteractionResponseData.Choices 2022-08-22 02:08:28 -07:00
diamondburned a1334c45f4
api: Revert "Revert 'Add FollowUpInteraction'"
This reverts commit 96b8e2b8e5.

The commit that is being reverted was created on the wrong commit.
2022-08-21 00:58:57 -07:00
diamondburned 96b8e2b8e5
api: Revert "Add FollowUpInteraction"
This reverts commit 2aaa2002d8.

The initial goal of this addition is to be used for interaction
followups, but the interaction event already comes with the application
ID.

The addition was also not done properly, and no invalidation on event is
done.
2022-08-20 16:15:50 -07:00
diamondburned 2aaa2002d8
api: Add FollowUpInteraction
Deprecate CreateInteractionFollowup in favor of FollowUpInteraction
because it has a shorter and more concise name.
2022-08-20 16:06:33 -07:00
diamondburned 6412cf74ff
api: Add and deprecate EphemeralResponse
Follow-up to previous commit.
2022-08-18 23:25:13 -07:00
diamondburned 530f0c5622
api: add and deprecate InteractionResponseFlags
This commit builds upon eb579c8, which deprecates the type in favor of
an existing one. It adds code that preserves backwards compatibility.
2022-08-18 23:22:40 -07:00
Samuel Hernandez eb579c8e94 api: remove InteractionResponseFlags in favor of discord.MessageFlags
See docs:
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-messages

This is an API change. Use the following commands to update your
projects:

	$ gofmt -w -r 'api.InteractionResponseFlags -> discord.MessageFlags'
	$ gofmt -w -r 'api.EphemeralResponse -> discord.EphemeralMessage'
2022-08-18 22:57:40 -07:00
twoscott 33fbc1a1a2 api: Allow all types for api choices 2022-06-05 17:56:52 -07:00
Juby210 4b6bc657dc
discord: Add permission fields to Command (#326)
* api/discord: add DefaultMemberPermissions and DMPermission to commands
* api/discord: invert DMPermission to match NoDefaultPermission
2022-05-08 03:33:56 -07:00
Neo f5f46f5fd4 api: Add localization fields to Application Command creation data 2022-04-12 08:39:44 -07:00
diamondburned f249715c9d
discord: Add localization to Application Commands (#322)
* discord: Add localization to Application Commands
* discord: Created Language type and renamed field.
* discord: Added comments
* api: Add *Client.WithLocale
* discord: Use StringLocales, tweak naming

Co-authored-by: Neo <65282986+Neoration@users.noreply.github.com>
2022-04-11 21:30:25 -07:00
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 30c63e66d1
discord: Ack.Token nullable 2022-04-02 21:55:26 -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
diamondburned 209e6282b0
api: Add NullImage 2022-02-17 13:05:15 -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 a159ba1c52 api: Add RTCRegionID for ModifyChannelData 2022-01-18 21:35:55 -08:00
PL Pery 11432e426c
discord: Correct BulkOverwriteGuildCommands parameters (#301) 2022-01-03 13:38:38 -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 5c88317130
api: Fix CreateInteractionFollowup return 2021-11-23 22:53:27 -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
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 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 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 53c72c1e16 option: Move conflicting types into package discord 2021-08-30 13:23:43 -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
Maximilian von Lindern b61179d188 api: Remove Client.Kick and rename .KickWithReason to .Kick 2021-08-18 11:31:16 -07:00
rigormorrtiss b253a5659b
discord: Add Invitable field for threads (#268) 2021-08-16 22:37:33 -07:00
Maximilian von Lindern 525e8d527b api: More multiple embed support for send functions (#266)
* api: Adapt Client.EditMessage, SendEmbedReply, and SendMessageReply to take in
  multiple embeds

* api: Fix incorrect use of Client.EditMessage

* api: Make EditMessage omit empty content or embeds from payload
2021-08-16 02:26:25 -07:00
Maximilian von Lindern 19335e5050 api: Pointerize return types for consistency
Pointerize Client.Command, .GuildCommand, .CommandPermissions, and .EditCommandPermissions for consistency
2021-08-15 12:29:30 -07:00
Maximilian von Lindern 244570c280
api: Add support for the X-Audit-Log-Reason header (#259)
* api: add support for the X-Audit-Log-Reason header

* api: inline reason parameter, where data struct has a single field
2021-08-15 18:33:33 +02:00
Nat dbfc49fb08
API: Fix Client.{Guild,}Command() (#264) 2021-08-14 22:27:22 -07:00
Maximilian von Lindern 955bb2aad2
api: Make some InteractionResponseData fields nullable (#256)
* api: make InteractionResponseData.Content, .Embeds, and .Components nullable

* Fix examples

* Remove test code

* fix commands example
2021-08-08 13:20:54 -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
diamondburned d4c66d4971 api: Omitted SearchData redundant option type 2021-06-26 17:04:00 -07:00
samhza 7bc2be1498
api: Add search endpoint (#236)
Co-authored-by: Terra Brown <superloach42@gmail.com>
2021-06-25 12:29:14 -07:00
samhza 354199383a
api: Remove Client.SendText (#234)
SendMessage(a, b) is equivalent to SendText(a, b) so SendText is
redundant.

Programs using SendText can be updated with

    $ gofmt -r 'c.SendText(a, b) -> c.SendMessage(a, b)' -w .
2021-06-22 17:48:16 -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
Hamza Ali 134f49d00f discord: Add Flags field to InteractionResponseData 2021-06-14 15:23:08 -07:00
diamondburned 68313eb872 discord: Fix Channel not unmarshaling 2021-06-14 15:23:08 -07:00