#Learning to code on my own.... Need some help with error handles

1 messages · Page 1 of 1 (latest)

fading vapor
#

module.exports = {
data: new SlashCommandBuilder()
.setName('ticket-setup')
.setDescription('Sets up the Ticket System for the server.')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addRoleOption(option =>
option.setName('role')
.setDescription('Role to mention in the ticket (Staff Role)')
.setRequired(true))
.addChannelOption(option =>
option.setName('category')
.setDescription('Category where the ticket channels will be created')
.setRequired(true)
.addChannelTypes(4) // GuildCategory
),
async run(interaction) {
const role = interaction.options.getRole('role');
const category = interaction.options.getChannel('category');

small scaffold
#

interaction.options is undefined. Perhaps the code that calls that method does not check if the interaction is a command?

fading vapor
#

In this scenario where woul you look to try and solve this issue?

small scaffold
#

I dont think the issue is with your command itself. Rather with your command handler. Could you share that?

fading vapor
#

// Initialize CommandHandler with client instance
new CommandHandler({
client,
commandsPath: path.join(__dirname, 'commands'),
eventsPath: path.join(__dirname, 'events'),
//testServer: 'TEST_SERVER_ID', // Replace with your server ID for guild-based commands (optional)
});

#

that is in my index.js file

small scaffold
#

Did you create that command handler?

fading vapor
#

no sir

small scaffold
#

Which one are you using

fading vapor
#

what do you mean if you dont mind me asking?

small scaffold
#

What command handler did you Install

fading vapor
#

djs

#

const { CommandHandler } = require('djs-commander');

small scaffold
#

djs-commander

#

Is the lib

fading vapor
#

"djs-commander": "^0.0.50",

small scaffold
#

2s

#

Okay first of all its deprecated meaning it no longer receives updates.

Other than that your run method is wrong.

It should be something along

async run: ({ interaction, client, handler }) => {
   // your code here
  }
#

According to what I found Here