-
Notifications
You must be signed in to change notification settings - Fork 412
feat: user-installables #1532
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
Open
retrouser955
wants to merge
57
commits into
abalabahaha:dev
Choose a base branch
from
retrouser955:dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: user-installables #1532
Changes from 55 commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
1ce9f24
Add user commands
retrouser955 e4de85c
assign contexts to application command constructor
retrouser955 6473441
add context type to commandinteraction
retrouser955 431381d
Add context constants
retrouser955 743ac7e
Format: ApplicationCommandContextType
retrouser955 d58b66c
add testing for user installable
retrouser955 b5f05a3
Fix: user installables not registering properly
retrouser955 7247cbf
Add integration_types to ApplicationCommandCreateOptions type
retrouser955 8c0f31b
make the example more verbose
retrouser955 d15710d
add a warning to the example
retrouser955 0295152
chore: lint
retrouser955 f1f4733
Update typings to be optional
retrouser955 df8a692
Update index.d.ts
retrouser955 bdf0330
chore: lint
retrouser955 5b500ea
Merge branch 'dev' of https://github.com/retrouser955/eris into dev
retrouser955 b052b0f
alphabetical order
retrouser955 c0c23d9
remove spacing
retrouser955 1a81f4b
fix: spacing yet again
retrouser955 8e566bf
Fix: Missing guild prop && Chore: lint
retrouser955 19ac5e6
remove magic number
retrouser955 0c8a24a
update types
retrouser955 2afdb14
sort properties
retrouser955 ac00f71
Use a Guild instance
retrouser955 1cc3695
enhance user command example
a5fd831
fix: Guild not in cache on user-installables
retrouser955 62c2f9a
wrote guild assignment more efficiently
retrouser955 5d5a5ff
chore: lint
retrouser955 5bc39b4
Merge branch 'dev' of https://github.com/abalabahaha/eris into 1532
bsian03 adfa5af
lint
bsian03 03badc8
fix(typings): Type mismatch between discord and lib
retrouser955 164dab6
Merge branch 'dev' of https://github.com/retrouser955/eris into dev
retrouser955 f212f2f
chore(add types)
retrouser955 fd9abb1
chore(format)
retrouser955 89689e8
Merge branch 'abalabahaha:dev' into dev
retrouser955 ed04a28
no constructor for autocomplete
retrouser955 89ea9d1
assign only data.guild
retrouser955 7fd0d80
revert
retrouser955 e661cda
Merge branch 'erisdev' into 1532
bsian03 0533eaf
add authorizingIntegrationOwners
retrouser955 d2e05fb
Merge branch 'dev' of https://github.com/retrouser955/eris into dev
retrouser955 1fa31d3
chore(lint) && integration_types_configuration
retrouser955 f22ad92
add install params and custom install url
retrouser955 49fbb92
Merge branch 'dev' into dev
retrouser955 391188a
chore(lint): dts
retrouser955 3cb938f
deprecate `<Message>.interaction`
retrouser955 545fb50
feat(interaction metadata): Init types
retrouser955 dce393c
chore(lint)
retrouser955 3bb0f7c
update types
retrouser955 155f669
updated message interaction metadata
retrouser955 9f47191
docs: add jsdoc
retrouser955 aefd654
docs(jsdoc): Complete types
retrouser955 8fd9f8a
chore: lint
retrouser955 498393d
fix(docs): readd user to interactionMetadata
retrouser955 239bf73
fix(interactionMetadata): parse model submit correctly
retrouser955 a7c1777
fix(interactionMetadata): Parse modelsubmit correct
retrouser955 1a10aeb
Merge branch 'dev' into dev
bsian03 092107e
copilot fixes
bsian03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| const Eris = require("eris"); | ||
|
|
||
| const Constants = Eris.Constants; | ||
|
|
||
| const bot = new Eris.Client("Bot token", { | ||
| intents: [], | ||
| }); | ||
|
|
||
| bot.on("ready", async () => { | ||
| console.log("connected!"); | ||
| bot.createCommand({ | ||
| type: Constants.ApplicationCommandTypes.CHAT_INPUT, | ||
| name: "ping", | ||
| description: "Reply with pong", | ||
| options: [], | ||
| /* The following 2 lines set the state of the application command as both user installable and guild installable */ | ||
| contexts: [ | ||
| Constants.ApplicationCommandContextType.GUILD, | ||
| Constants.ApplicationCommandContextType.BOT_DM, | ||
| Constants.ApplicationCommandContextType.PRIVATE, | ||
| ], | ||
| integrationTypes: [ | ||
| Constants.ApplicationCommandIntegrationTypes.GUILD_INSTALL, | ||
| Constants.ApplicationCommandIntegrationTypes.USER_INSTALL, | ||
| ], | ||
| }); | ||
| }); | ||
|
|
||
| bot.on("interactionCreate", (interaction) => { | ||
| if (interaction instanceof Eris.CommandInteraction) { | ||
| if (interaction.data.name === "ping") { | ||
| let where = ""; | ||
| /** | ||
| * <CommandInteraction>.context includes information of where the command was executed. | ||
| * if <CommandInteraction>.context matches ... | ||
| * Constants.ApplicationCommandContextType.GUILD it means it is executed from a server | ||
| * Constants.ApplicationCommandContextType.BOT_DM it means it is executed from the bot's DM | ||
| * Constants.ApplicationCommandContextType.PRIVATE it means it is executed as a user installable | ||
| * | ||
| * Incase of BOT_DM and PRIVATE, the CommandInteraction will lose all its guild related properties such as the guild information and member data | ||
| */ | ||
| const context = interaction.context; | ||
|
|
||
| // Check where the command is sent from. | ||
| // Keep in mind, context will be the same for commands that are ran as user-installables and guild-invited bots unless user-installables are ran in DMs or are sent in the bot's DMs | ||
| if (context === Constants.ApplicationCommandContextType.GUILD) { | ||
| where = "as a server interaction."; | ||
| } else if (context === Constants.ApplicationCommandContextType.BOT_DM) { | ||
| where = "as a bot DM interaction."; | ||
| } else if (context === Constants.ApplicationCommandContextType.PRIVATE) { | ||
| where = "as a private interaction (user installable)."; | ||
| } else { | ||
| where = "as a server interaction."; | ||
| } | ||
|
|
||
| interaction.createMessage(`🏓 pong ${where}`); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| bot.connect(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.