How to make slash commands work globally (in other servers and in dms where bot is not presentt
What do I do in my code to make it work? I have tried everything but the slash command does not work no matter what I do. I am using instaloader that is using a python script (isnt in the JS code, the js code only handles command).
27 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by staffHere is the code, what do i do to make Slash commands work globally
i have tried what i could do,but it doesnt workj
that problem has to do with how you deploy your commands
not how you handle them
so the issue is within your python script
ask in the support for that library or whatever you're using
this isn't djs related
No no im askin how ot make the slash command work in dms and other servers, like for app.commands
same answer
How tho? because the script doesnt have anythin to do with the discord.js?
all it does is grabs the url
which is given by the bot.js script
please check
only takes the url
you said that you used instaloader
Yeah thats for the python script, i was jus tellin what the program does
what im askin help for is
how to make slash commands work globally
I have no idea what that is, I assumed that was for loading your commands
in dms, other servers
how are you loading your commands?
how are you deploying your commands then
try {
// Register the slash command globally
await client.application.commands.create(
new SlashCommandBuilder()
.setName('video')
.setDescription('Get the video from an Instagram or TikTok post')
.addStringOption(option =>
option.setName('url')
.setDescription('The URL of the Instagram or TikTok post')
.setRequired(true)
)
);
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
yes i have those settings set on the bot on the discord developer portal
its not enough to set them on discord developer protal. you need to set them when deploying ur commands
:method: SlashCommandBuilder#setIntegrationTypes()
@1.9.0
Sets the integration types of this command.have u done the other things like the interaction endpoint?
the api endpoint is called by djs in his code
hm
the problem is with his data
as Retro said
.setContexts([0, 1]) // 0 = Guild, 1 = BotDM // Allow the slash command to work in both guilds and DMs
.setIntegrationTypes([0,1]) // Enable integration as a slash command globally
is this how you do it?
@Retro
Check the url of the docs
But yes that is how you do it but use enums that discord.js exports instead of magic numbers
Also the maximum for context is array of size 3. Guild, dm and guild your bot has not been invited to
thank you sir, it worked
thank you @Retro @Ame @Abs
oops
@𝑨𝒃𝒔𝒐𝒍𝒖𝒕𝒆 𝑪𝒂𝒓𝒏𝒂𝒈𝒆