Are my slashcommands guild based or global?

When I use registerApplicationCommands (like shown in the picture) does that command get registered in a single guild or globally (in development environment)? and if it is registered globally, can I made it so it gets registered in a test guild only when NODE_ENV is dev?
No description
Solution:
global, and you can set guildIds in the second paramater of registerChatInputCommand, if you set it to an empty array or undefined then they're still global so just do a simple ternary check of process.env.NODE_ENV === 'development' ? 'myguildid' : undefined or leverage the same in Globally configuring guildIds if you want it to count for all commands
Sapphire Framework
Globally configuring guildIds | Sapphire
Previously at Registering Chat Input Commands - guildIds we covered how to register single commands
Jump to solution
8 Replies
Solution
Favna
Favna8mo ago
global, and you can set guildIds in the second paramater of registerChatInputCommand, if you set it to an empty array or undefined then they're still global so just do a simple ternary check of process.env.NODE_ENV === 'development' ? 'myguildid' : undefined or leverage the same in Globally configuring guildIds if you want it to count for all commands
Sapphire Framework
Globally configuring guildIds | Sapphire
Previously at Registering Chat Input Commands - guildIds we covered how to register single commands
Favna
Favna8mo ago
either way technically this should never be an issue because you should use different bot applications for dev and prod and you can just set your dev bot to not be invitable by others so you control in which guilds it is
A guy named Jensbot
after the builder's closing ) tag, you can use { guildIds: [] } to set a guild id for that command, no idea how to only allow it when node_env is dev though
Favna
Favna8mo ago
guildIds: process.env.NODE_ENV === 'development' ? ['myguildid'] : undefined
guildIds: process.env.NODE_ENV === 'development' ? ['myguildid'] : undefined
basic JS this is why this tag is so important:
Spinel
Spinel8mo ago
Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics: - Read and understand docs - Debug code - Syntax - NodeJS module system If you aren't sure that your understanding of JavaScript is truly good enough to make a bot, you should try to continue learning first. Here are good resources to learn both Javascript and NodeJS: - Codecademy: https://www.codecademy.com/learn/javascript - Udemy: https://www.udemy.com/javascript-essentials/ - Eloquent JavaScript, free book: http://eloquentjavascript.net/ - You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS - JavaScript Garden: https://bonsaiden.github.io/JavaScript-Garden/ - JavaScript reference/docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference - Nodeschool: https://nodeschool.io/ - Pluralsight: https://www.codeschool.com/courses/real-time-web-with-node-js Before you ask a question, you should ask these yourself: 1. Is this question related to JavaScript, or the library I am using? - If it is the library you are using, go to the proper server. You would get better answers there. 2. Have I tried to google and/or check StackOverflow? - Double-check that you can't find anywhere that can lead you to a solution online. 3. Have I tried to look on MDN or the library documentation? - You should always check documentation to make sure you aren't missing any details. 4. Does my question make enough sense so that people can understand it, and do they understand what I am trying to accomplish? - If no, revise your question. Give as much detail as possible. Include any error or code output that can help us help you. 5. Am I aware of what I am doing, and not just mindlessly copying and pasting? - If you are just copying and pasting code from a guide, you are not going to be able to solve anything. Make sure you understand the code you are writing.
A guy named Jensbot
ah didn't realize undefined would actually work there lmao
Favna
Favna8mo ago
guildIds: process.env.NODE_ENV === 'development' ? ['myguildid'] : []
guildIds: process.env.NODE_ENV === 'development' ? ['myguildid'] : []
this would also but explicitly setting undefined is the same as not adding the property at all
A guy named Jensbot
getting annoyed having to learn python and php ;-; my js knowledge is struggling
Want results from more Discord servers?
Add your server