Wicked ↝ 💊Ⅶ✥
Wicked ↝ 💊Ⅶ✥
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 3/7/2024 in #djs-questions
"Started refreshing 0 application (/) commands."
Understood, I’ll try those edits and see if that fixes it. Thanks so much! :)
8 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 3/7/2024 in #djs-questions
"Started refreshing 0 application (/) commands."
Additionally, I've searched this server for answers related to the title of this post, and none of them have gotten me any further.
8 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 3/7/2024 in #djs-questions
"Started refreshing 0 application (/) commands."
This is my command handler code:
const { REST, Routes } = require('discord.js');
const fs = require('fs');

module.exports = (client) => {

const { cmds } = client;

client.cmdsHandler = async () => {
const cmdFolders = fs.readdirSync(`./src/cmds`)

for (const folder of cmdFolders) {

const cmdFiles = fs.readdirSync(`./src/cmds/${folder}`).filter(file => file.endsWith('.js'));

for (const file of cmdFiles) {

const cmd = require(`../../cmds/${folder}/${file}`);

cmds.set(cmd.data.name, cmd);

}

console.log(cmdFolders, cmdFiles);

};

const clientId = 'REDACTED';
const rest = new REST().setToken(process.env.token);

(async () => {
try {
const data = await rest.put(
Routes.applicationCommands(clientId, cmds)
);

console.log(`Started refreshing ${data.length} application (/) commands.`);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
console.error(error);
}
})();

}

};
const { REST, Routes } = require('discord.js');
const fs = require('fs');

module.exports = (client) => {

const { cmds } = client;

client.cmdsHandler = async () => {
const cmdFolders = fs.readdirSync(`./src/cmds`)

for (const folder of cmdFolders) {

const cmdFiles = fs.readdirSync(`./src/cmds/${folder}`).filter(file => file.endsWith('.js'));

for (const file of cmdFiles) {

const cmd = require(`../../cmds/${folder}/${file}`);

cmds.set(cmd.data.name, cmd);

}

console.log(cmdFolders, cmdFiles);

};

const clientId = 'REDACTED';
const rest = new REST().setToken(process.env.token);

(async () => {
try {
const data = await rest.put(
Routes.applicationCommands(clientId, cmds)
);

console.log(`Started refreshing ${data.length} application (/) commands.`);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
console.error(error);
}
})();

}

};
And this is what my console logs (as you can see, it includes the file paths that I mentioned before, so I know it's reading them alright):
[ 'utility' ] [ 'ping.js' ]
Started refreshing 0 application (/) commands.
Successfully reloaded 0 application (/) commands.
Lupin is open for business :)
[ 'utility' ] [ 'ping.js' ]
Started refreshing 0 application (/) commands.
Successfully reloaded 0 application (/) commands.
Lupin is open for business :)
8 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 2/3/2024 in #djs-questions
Making commands customizable by the guild members
Got it! :)
15 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 2/3/2024 in #djs-questions
Making commands customizable by the guild members
Understood. That makes a lot of sense actually, I'm not sure why I couldn't find that info anywhere online. Maybe I wasn't looking hard enough lol. Thanks so much for the help, it's much appreciated! :)
15 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 2/3/2024 in #djs-questions
Making commands customizable by the guild members
Thank you for responding and explaining! What I'm looking for is a way to allow guild members to create their own slash commands, if that's possible.
15 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 10/23/2022 in #djs-questions
TypeError - currency.set is not a function
will do, thank you for the help ^^
8 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 10/23/2022 in #djs-questions
TypeError - currency.set is not a function
export: module.exports = { addBalance, getBalance, currency }; imports: const currency = require('./currency');
8 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 10/23/2022 in #djs-questions
TypeError - currency.set is not a function
gotcha [email protected] Node.js v18.2.0 i defined it in a separate './currency.js' file, using const currency = new Collection(); and exported it from there, then required it in necessary files
8 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 10/23/2022 in #djs-questions
TypeError - currency.set is not a function
my node and npm version are the latest, as well
8 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 10/23/2022 in #djs-questions
TypeError - currency.set is not a function
this has me stumped. it was working perfectly about 15 minutes ago and i quite literally changed a bit of a message it was supposed to reply with, which somehow broke two whole commands- ;-;
8 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 10/23/2022 in #djs-questions
TypeError - currency.set is not a function
the error stack:
node:events:505
throw er; // Unhandled 'error' event
^

TypeError: currency.set is not a function
at C:\Users\Felix\BOTNM\index.js:41:39
at Array.forEach (<anonymous>)
at Client.<anonymous> (C:\Users\Felix\BOTNM\index.js:41:17)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:384:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
node:events:505
throw er; // Unhandled 'error' event
^

TypeError: currency.set is not a function
at C:\Users\Felix\BOTNM\index.js:41:39
at Array.forEach (<anonymous>)
at Client.<anonymous> (C:\Users\Felix\BOTNM\index.js:41:17)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:384:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
8 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 9/29/2022 in #djs-questions
[V 14.5.0] using the official DJS guide for a currency system, `getBalance` is giving me grief
ISSUE FIXED i'm actually not sure exactly what fixed it, but i added const currency = new Collection(); to the top of my index.js and then exported it after the Reflect.defineProperty functions and suddenly it started working?? i would give specific info if i knew what info to give, but that was apparently the catalyst. thank you for your help, Joe! <a:th_rainbowheart:1008940957556805752>
15 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 9/29/2022 in #djs-questions
[V 14.5.0] using the official DJS guide for a currency system, `getBalance` is giving me grief
the main difference between my code and the djs guide is that i'm using a command handler, so i've had to edit some parts of the code and move them to different files, but i'm not seeing anything i've actually left out. you're definitely right that i haven't passed in anything to the currency collection, however the guide itself doesn't add anything to it. i'll keep poking around the internet Thonk
15 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 9/29/2022 in #djs-questions
[V 14.5.0] using the official DJS guide for a currency system, `getBalance` is giving me grief
the bot has restarted a few times because i am still adding commands and such, so i wouldn't be surprised if that was the cause. i'm checking the djs guide to see if i missed what i should add to the collection
15 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 9/29/2022 in #djs-questions
[V 14.5.0] using the official DJS guide for a currency system, `getBalance` is giving me grief
gotcha, i've learned something new today :0 let me take a look around and see how i can fix that, i'll message again here if the issue persists. thank you for your time! /g
15 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 9/29/2022 in #djs-questions
[V 14.5.0] using the official DJS guide for a currency system, `getBalance` is giving me grief
i believe this is a djs issue but i could be wrong. here is the currency log: Collection(0) [Map] {}
15 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 9/29/2022 in #djs-questions
[V 14.5.0] using the official DJS guide for a currency system, `getBalance` is giving me grief
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('balance')
.setDescription("Check a user's balance!")
.addUserOption(option =>
option.setName('user')
.setDescription('the user whose balance you will check!')
.setRequired(false)),
async execute(interaction) {
const target = interaction.options.getUser('user') ?? interaction.user;
const { currency } = require('../index.js');
await interaction.reply(`${target.tag} has ${currency.getBalance(target.id)} <@&${1022710689279791134}>`);
},
};
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('balance')
.setDescription("Check a user's balance!")
.addUserOption(option =>
option.setName('user')
.setDescription('the user whose balance you will check!')
.setRequired(false)),
async execute(interaction) {
const target = interaction.options.getUser('user') ?? interaction.user;
const { currency } = require('../index.js');
await interaction.reply(`${target.tag} has ${currency.getBalance(target.id)} <@&${1022710689279791134}>`);
},
};
thank you for replying so quickly!
15 replies
DIAdiscord.js - Imagine an app
Created by Wicked ↝ 💊Ⅶ✥ on 9/29/2022 in #djs-questions
[V 14.5.0] using the official DJS guide for a currency system, `getBalance` is giving me grief
[email protected] node v18.2.0 yes, one sec!
15 replies