NNKtv28
NNKtv28
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
+ the ticket thing is optional and i wanted to add it as an extra for the client
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
the rest of the commands work fine
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
cause i can take it, and thats the only command thats giving me issues
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
pls dont delete this channel cause i will need it in the future withon 2 weeks
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
i got 2 weeks to finish this bot or im screwed
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
ima continue with other commands and leave the ticket thing for when i finish the commands cause i dont want to spend more time than i need to on a single command
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
and due to that the button interaction wasnt going through
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
cause i understood that the line
//if (!interaction.isCommand()) return;
//if (!interaction.isCommand()) return;
was the one stopping the button interactions cause they werent command interactions
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
alright then my brain is not braining, ima head to bed and hope i can get it right tomorrow
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
cause tecnically the button interaction is not a command interaction so it made sense in my head to remove it
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
ik but i tryed it and it worked perfectly
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
i commented the 1 line you told me and now the ping button works 😄
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
No description
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
ohh okay
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
so interactionCreate can only handle 1 interaction type?
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
ohhh alright
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
this is the interactionCreate.js code:
const { Events, WebhookClient } = require("discord.js");
const { errorWebhookURL } = require('../config.json');
const webhook = new WebhookClient({ url: errorWebhookURL });

module.exports = {
name: Events.InteractionCreate,
once: false,
async execute(interaction) {
if (!interaction.isCommand()) return;

const command = interaction.client.commands.get(interaction.commandName);

// If the command doesn't exist, log it and return.
if (!command) {
console.error(`No command matching "${interaction.commandName}" was found. Make sure the file exists.`);
await webhook.send(`No command matching "${interaction.commandName}" was found. Make sure the file exists.`);
return;
}

try {
await command.execute(interaction);
} catch (error) {
console.error(`Error while executing "${interaction.commandName}" command:`, error);

await interaction.reply({
content: "There was an error while executing this command. Our team has been notified.",
ephemeral: true,
});

// You can also log the error to a dedicated error channel or service for further debugging.
// Example: bot.channels.cache.get('error-channel-id').send(`Error while executing "${interaction.commandName}" command: ${error}`);
}

// ticket creation interaction
if (interaction.customId === "ticket_create") {
try {
await ticketEvent.execute(interaction);
} catch (error) {
console.error(`Error while handling ticket creation:`, error);
await interaction.reply({
content: "There was an error while handling your ticket creation. Our team has been notified.",
ephemeral: true,
});
}
}
},
};
const { Events, WebhookClient } = require("discord.js");
const { errorWebhookURL } = require('../config.json');
const webhook = new WebhookClient({ url: errorWebhookURL });

module.exports = {
name: Events.InteractionCreate,
once: false,
async execute(interaction) {
if (!interaction.isCommand()) return;

const command = interaction.client.commands.get(interaction.commandName);

// If the command doesn't exist, log it and return.
if (!command) {
console.error(`No command matching "${interaction.commandName}" was found. Make sure the file exists.`);
await webhook.send(`No command matching "${interaction.commandName}" was found. Make sure the file exists.`);
return;
}

try {
await command.execute(interaction);
} catch (error) {
console.error(`Error while executing "${interaction.commandName}" command:`, error);

await interaction.reply({
content: "There was an error while executing this command. Our team has been notified.",
ephemeral: true,
});

// You can also log the error to a dedicated error channel or service for further debugging.
// Example: bot.channels.cache.get('error-channel-id').send(`Error while executing "${interaction.commandName}" command: ${error}`);
}

// ticket creation interaction
if (interaction.customId === "ticket_create") {
try {
await ticketEvent.execute(interaction);
} catch (error) {
console.error(`Error while handling ticket creation:`, error);
await interaction.reply({
content: "There was an error while handling your ticket creation. Our team has been notified.",
ephemeral: true,
});
}
}
},
};
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
this is what the rest of commands looks like
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
for example this deposit.js:
const { SlashCommandBuilder } = require("discord.js");
const BalanceModel = require("../../models/balance"); // Import your Balance model

module.exports = {
data: new SlashCommandBuilder()
.setName('deposit')
.setDescription("Deposit money from your cash balance into the bank.")
.addIntegerOption((option) =>
option.setName("amount").setDescription("The amount to deposit into the bank.").setRequired(true)
)
.setDMPermission(false),

async execute(interaction) {
await interaction.deferReply({ ephemeral: true });

const user = interaction.user;
const amount = interaction.options.getInteger("amount");

try {
// Check if the user's balance exists in the database
let userBalance = await BalanceModel.findOne({
where: { user_id: user.id },
});

if (!userBalance) {
userBalance = await BalanceModel.create({
user_id: user.id,
user_balance_cash: 0,
user_balance_bank: 0,
});
}

// Check if the user has enough cash to deposit
if (userBalance.user_balance_cash < amount) {
return interaction.editReply("You don't have enough cash to deposit that amount.");
}

// Deposit the money into the bank and deduct it from cash balance
userBalance.user_balance_cash -= amount;
userBalance.user_balance_bank += amount;

// Save the updated balance
await userBalance.save();

interaction.editReply(`You successfully deposited ${amount}$ into the bank.`);
} catch (error) {
console.error(error);
interaction.editReply("An error occurred while processing your deposit.");
}
},
};
const { SlashCommandBuilder } = require("discord.js");
const BalanceModel = require("../../models/balance"); // Import your Balance model

module.exports = {
data: new SlashCommandBuilder()
.setName('deposit')
.setDescription("Deposit money from your cash balance into the bank.")
.addIntegerOption((option) =>
option.setName("amount").setDescription("The amount to deposit into the bank.").setRequired(true)
)
.setDMPermission(false),

async execute(interaction) {
await interaction.deferReply({ ephemeral: true });

const user = interaction.user;
const amount = interaction.options.getInteger("amount");

try {
// Check if the user's balance exists in the database
let userBalance = await BalanceModel.findOne({
where: { user_id: user.id },
});

if (!userBalance) {
userBalance = await BalanceModel.create({
user_id: user.id,
user_balance_cash: 0,
user_balance_bank: 0,
});
}

// Check if the user has enough cash to deposit
if (userBalance.user_balance_cash < amount) {
return interaction.editReply("You don't have enough cash to deposit that amount.");
}

// Deposit the money into the bank and deduct it from cash balance
userBalance.user_balance_cash -= amount;
userBalance.user_balance_bank += amount;

// Save the updated balance
await userBalance.save();

interaction.editReply(`You successfully deposited ${amount}$ into the bank.`);
} catch (error) {
console.error(error);
interaction.editReply("An error occurred while processing your deposit.");
}
},
};
303 replies
DIAdiscord.js - Imagine an app
Created by NNKtv28 on 9/27/2023 in #djs-questions
How can i setup a ticket system with a parent category?
and thats all
303 replies