-
Notifications
You must be signed in to change notification settings - Fork 902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement user-installed integration #1625
base: dev
Are you sure you want to change the base?
Conversation
Implements the new integration context/types system Adds `Integration_Types` and `Contexts` to `lib\discordgo\structs.go`'s `Integration` struct Adds `IntegrationOwners` to `lib\discordgo\interactions.go`'s `Interaction` struct Adds `UserInstalledGuild` to `lib\dcmd\data.go`'s `Data` struct Implements the new `Integration_Types` and `Contexts` into `commands\slashcommands.go`'s `yagCommandToSlashCommand` function
Replaces integration with the proper word interaction according to documentation
lib/discordgo/interactions.go
Outdated
@@ -186,6 +186,8 @@ type Interaction struct { | |||
Data InteractionData `json:"data"` | |||
GuildID int64 `json:"guild_id,string"` | |||
ChannelID int64 `json:"channel_id,string"` | |||
// https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-authorizing-integration-owners-object | |||
IntegrationOwners map[string]interface{} `json:"authorizing_integration_owners"` // Left as interface due to discord being inconsistent, with the value being an int at some times and a string at others. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bwmarrin's dgo also struggles with this bug, their workaround currently is > bwmarrin/discordgo#1511
regarding that bug, maybe it would be a good thing to wait a little until discord/discord-api-docs#6730 is fixed
One thing I'd add is if interaction context is of type 2 |
While I do agree that there's no need to flood dms with interactions, I also think it would ruin the fun of users who want to use the bot in a GDM, as the type is |
There might be some way to check if the channel is a GDM, but I'd have to look further into the API, and I feel as though that would be out of scope for this PR anyways. |
I think Context field for type Interaction is in the scope of this PR. |
ok, got it working on my end, so that it goes Ephemeral for regular DMs and not for Group ones func YAGCommandMiddleware(inner dcmd.RunFunc) dcmd.RunFunc {
...
// this follows bwmarrin PR#1511 and not your interface, logic is the same
isUserInstalledGuild := data.SlashCommandTriggerData.Interaction.AuthorizingIntegrationOwners[discordgo.ApplicationIntegrationGuildInstall] == "" && data.SlashCommandTriggerData.Interaction.AuthorizingIntegrationOwners[discordgo.ApplicationIntegrationUserInstall] != ""
if yc.IsResponseEphemeral || (isUserInstalledGuild && data.SlashCommandTriggerData.Interaction.Context == discordgo.InteractionContextPrivateChannel && data.SlashCommandTriggerData.Interaction.Channel.Type != discordgo.ChannelTypeGroupDM) {
response.Data = &discordgo.InteractionResponseData{Flags: 64}
}
... |
Removes underscores from variables
Fixes a mistake made by blindly replacing all text
Pagination will probably need some degree of changes if a command with RunInDM enabled uses it anywhere (i.e. forex) |
yeah, even if you enable forex for DMs by setting guilID 0 for pagination function, problem is still that bot does not have access to that channel. |
Modifies `bot\paginatedmessages\paginatedinteractions.go`'s `CreatePaginatedMessage` function to accept `dcmd.Data` and respond to original interaction accordingly
What I did... it works I still don't see bigger reason for YAGPDB having it, for self-hosts it could be fun, but changing this much code for no good reason, I really don't know. |
Discord fixed discord/discord-api-docs#6730 |
In order for this to actually be used on a bot, the setting must be enabled in the installation panel.