#help needed

1 messages · Page 1 of 1 (latest)

queen vapor
#

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 .setRequiredPermissions([permissions.FLAGS.BAN_MEMBERS])

tardy cairn
weary silo
#

permissions.FLAGS.BAN_MEMBERS is discord.js v13, Sapphire v4 and upwards require v14.

tardy cairn
#

also i think it is

#

permissions.Flags

queen vapor
weary silo
#

PermissionsFlagsBits.BanMember

queen vapor
#

ok thanks!

tardy cairn
#

@weary silo where was the djs docs search command

weary silo
#

It’s much shorter to use the enum directly

weary silo
queen vapor
# weary silo It’s much shorter to use the enum directly

now this error ```the command application command registry for command "ban" at path "/home/runner/bot/commands/ban.js" ReferenceError: PermissionsFlagsBits is not defined
at /home/runner/bot/commands/ban.js:27:34
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)

queen vapor
weary silo
#

Or discord-api-types/v10

tardy cairn
#

add this to the top

#

(and yes they use cjs kyra)

weary silo
#

I know, I saw cjs in the error stack

queen vapor
#

now this error [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 'BanMember') at /home/runner/bot/commands/ban.js:26:55 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:10: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)

weary silo
#

Ok, what version of discord.js do you have installed?

#

And @sapphire/framework while we’re at it

queen vapor
#
  "name": "nodejs",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@sapphire/framework": "^5.2.1",
    "@types/node": "^18.0.6",
    "discord-api-types": "^0.37.79",
    "discord.js": "^14.15.2"
  }
}```
#

see

weary silo
#

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

queen vapor
#

ok

tardy cairn
#

there was a mistake

#

my apologies from kyra's side

queen vapor
# tardy cairn its PermissionsFlagsBits.BanMembers
    at /home/runner/bot/commands/ban.js:26:34
    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:10: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)```

now this error
weary silo
#

Show your code please

queen vapor
#
const { EmbedBuilder, PermissionsFlagsBits } = require("discord.js");

class BanCommand extends Command {
  constructor(context, options) {
    super(context, { ...options });
  }

  registerApplicationCommands(registry) {
    registry.registerChatInputCommand((builder) =>
      builder
        .setName("ban")
        .setDescription("Ban a member from the server")
        .addUserOption((option) =>
          option
            .setName("member")
            .setDescription("The member to ban")
            .setRequired(true),
        )
        .addStringOption((option) =>
          option
            .setName("reason")
            .setDescription("The reason for the ban (optional)")
            .setRequired(false),
        )
        .setRequiredPermissions([PermissionFlagsBits.BanMembers])
    );
  }
tardy cairn
tardy cairn
queen vapor
tardy cairn
#

PermissionsFlagsBits.BanMembers

queen vapor
#
    at /home/runner/bot/commands/ban.js:26:34
    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:10: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)```

now this error
tardy cairn
#

good lord

weary silo
#

Permissions

tardy cairn
pure talon
#

Import it if not defined

queen vapor
tardy cairn
#

🤦‍♂️

queen vapor
queen vapor
weary silo
#

Singular Permission

tardy cairn
#
const { Command } = require("@sapphire/framework");
const { EmbedBuilder, PermissionFlagsBits } = require("discord.js");

class BanCommand extends Command {
  constructor(context, options) {
    super(context, { ...options });
  }

  registerApplicationCommands(registry) {
    registry.registerChatInputCommand((builder) =>
      builder
        .setName("ban")
        .setDescription("Ban a member from the server")
        .addUserOption((option) =>
          option
            .setName("member")
            .setDescription("The member to ban")
            .setRequired(true),
        )
        .addStringOption((option) =>
          option
            .setName("reason")
            .setDescription("The reason for the ban (optional)")
            .setRequired(false),
        )
        .setRequiredPermissions([PermissionFlagsBits.BanMembers])
    );
  }
#

use this code @queen vapor

weary silo
#

Looks good

queen vapor
# weary silo Looks good
[INFO] ApplicationCommandRegistries: Initializing...
[ERROR] Encountered error while handling the command application command registry for command "ban" at path "/home/runner/bot/commands/ban.js" TypeError: builder.setName(...).setDescription(...).addUserOption(...).addStringOption(...).setRequiredPermissions is not a function
    at /home/runner/bot/commands/ban.js:26:10
    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:10: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)
[INFO] ApplicationCommandRegistries: Took 5ms to initialize.

this error now
queen vapor
#

now this error```Ready! Logged in as Soda#5947
[INFO] ApplicationCommandRegistries: Initializing...
[ERROR] Encountered error while handling the command application command registry for command "ban" at path "/home/runner/bot/commands/ban.js" CombinedError (4)
Received one or more errors

1 ValidationError > s.nullish
| Expected undefined or null
|
| Received:
| | [ {} ]

2 ValidationError > s.bigint
| Expected a bigint primitive
|
| Received:
| | [ {} ]

3 ValidationError > s.number
| Expected a number primitive
|
| Received:
| | [ {} ]

4 ValidationError > s.string
| Expected a string primitive
|
| Received:
| | [ {} ]

at _UnionValidator.handle (/home/runner/bot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1854:23)
at _UnionValidator.parse (/home/runner/bot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:939:90)
at validateDefaultMemberPermissions (/home/runner/bot/node_modules/@discordjs/builders/dist/index.js:1639:36)
at MixedClass.setDefaultMemberPermissions (/home/runner/bot/node_modules/@discordjs/builders/dist/index.js:1796:29)
at /home/runner/bot/commands/ban.js:26:10
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:10: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)

[INFO] ApplicationCommandRegistries: Took 3ms to initialize.```

#

@weary silo ^

weary silo
#

We can't handhold you on every single step, please read the docs

sick berry
queen vapor
#
[INFO] ApplicationCommandRegistries: Initializing...
[ERROR] Encountered error while handling the command application command registry for command "ban" at path "/home/runner/bot/commands/ban.js" CombinedError (4)
  Received one or more errors

  1 ValidationError > s.nullish
  |   Expected undefined or null
  | 
  |   Received:
  |   | [ {} ]

  2 ValidationError > s.bigint
  |   Expected a bigint primitive
  | 
  |   Received:
  |   | [ {} ]

  3 ValidationError > s.number
  |   Expected a number primitive
  | 
  |   Received:
  |   | [ {} ]

  4 ValidationError > s.string
  |   Expected a string primitive
  | 
  |   Received:
  |   | [ {} ]

    at _UnionValidator.handle (/home/runner/bot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1854:23)
    at _UnionValidator.parse (/home/runner/bot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:939:90)
    at validateDefaultMemberPermissions (/home/runner/bot/node_modules/@discordjs/builders/dist/index.js:1639:36)
    at MixedClass.setDefaultMemberPermissions (/home/runner/bot/node_modules/@discordjs/builders/dist/index.js:1796:29)
    at /home/runner/bot/commands/ban.js:26:10
    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:10: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)
[INFO] ApplicationCommandRegistries: Took 4ms to initialize.
#

can help in error

#

plz

sick berry
#

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.

lost baneBOT
#

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:

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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
cunning etherBOT
tardy cairn
#

@sick berry you might need to reconsider the marked solution 💀

sick berry
#

lol... cant. @left wing any particular reason for that btw?

tardy cairn
#

that feature would be so helpful tbh

queen vapor