help needed
ializing...
[ERROR] Encountered error while handling the command application command registry for command "ban" at path "/home/runner/bot/commands/ban.js" TypeError: Cannot read properties of undefined (reading 'FLAGS')
at /home/runner/bot/commands/ban.js:27:46
at Object.normalizeChatInputCommand (/home/runner/bot/node_modules/@sapphire/framework/dist/cjs/lib/utils/application-commands/normalizeInputs.cjs:30:5)
at _ApplicationCommandRegistry.registerChatInputCommand (/home/runner/bot/node_modules/@sapphire/framework/dist/cjs/lib/utils/application-commands/ApplicationCommandRegistry.cjs:65:43)
at BanCommand.registerApplicationCommands (/home/runner/bot/commands/ban.js:11:14)
at Object.handleRegistryAPICalls (/home/runner/bot/node_modules/@sapphire/framework/dist/cjs/lib/utils/application-commands/ApplicationCommandRegistries.cjs:63:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _CoreListener.run (/home/runner/bot/node_modules/@sapphire/framework/dist/cjs/listeners/CoreReady.cjs:16:5)
at async Object.fromAsync (/home/runner/bot/node_modules/@sapphire/result/dist/cjs/index.cjs:619:22)
at async _CoreListener._run (/home/runner/bot/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:22)
at async _CoreListener._runOnce (/home/runner/bot/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:31:5) THIS ERROR
in this
55 Replies
i want to see what exactly "permissions" is in your code
ok
permissions.FLAGS.BAN_MEMBERS
is discord.js v13, Sapphire v4 and upwards require v14.also i think it is
permissions.Flags
so what to give in there?
.setRequiredPermissions([permissions.FLAGS.BAN_MEMBERS])
PermissionsFlagsBits.BanMember
ok thanks!
discord.js
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
@kyra 🩵🩷🤍🩷🩵 where was the djs docs search command
It’s much shorter to use the enum directly
Uhh I think @Favna removed it from Spinel in favour of using the djs docs bot directly
now this error
you have to import it
Import it from
discord.js
what permissions?
Or
discord-api-types/v10
const { PermissionsFlagsBits } = require('discord.js')
add this to the top
(and yes they use cjs kyra)
I know, I saw
cjs
in the error stacknow this error
Ok, what version of discord.js do you have installed?
And @sapphire/framework while we’re at it
v14
see
You can remove the discord-api-types dependency, it’s re-exported by discord.js
Installing it without extra (and slightly more advanced steps) would install a version not compatible with discord.js
ok
so how to resolve the error
its PermissionsFlagsBits.BanMembers
there was a mistake
my apologies from kyra's side
now this error
i edited it pal
Show your code please
kyra its fixed
@PHI
still error
PermissionsFlagsBits.BanMembers
now this error
good lord
Permissions
.
Import it if not defined
how to
🤦♂️
@Priyam see code imported already
@Priyam see code imported already see
use this code @PHI
Looks good
It's
setDefaultMemberPermissions
, not setRequiredPermissions
Please read the docs in https://sapphirejs.dev and https://discord.js.org as well as the guides:
- https://sapphirejs.dev/docs/Guide/commands/application-commands/what-are-application-commands
- https://discordjs.guidenow this error
@kyra 🩵🩷🤍🩷🩵 ^
We can't handhold you on every single step, please read the docs
ok
Correct because souji has access to the doc search dB so it's much better
@UndiedGFX
can help in error
plz
This is where this tag applies, also Kyra already answered that. We can't handhold you every step. At that point we might as well write the bot for you as a paid service.
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.
Solution
alright
@Favna you might need to reconsider the marked solution 💀
lol... cant. @Rhys any particular reason for that btw?
that feature would be so helpful tbh
not helpful at all