ras
ras
Explore posts from servers
DIAdiscord.js - Imagine a boo! 👻
Created by ras on 2/1/2024 in #djs-questions
What's the preferred way of accessing collections in a command file?
right, that's if i attach it to the client, I meant when you said "or you b can get access to the collection (or the date of the database) within your indiv command handling". Sorry for the confusion
16 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ras on 2/1/2024 in #djs-questions
What's the preferred way of accessing collections in a command file?
Okay, thanks! I'll attach it to the client, that makes sense to me. Would accessing the collection within the command handling just be an import statement, or?
16 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ras on 2/1/2024 in #djs-questions
What's the preferred way of accessing collections in a command file?
I have an sqlite database for that
16 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ras on 2/1/2024 in #djs-questions
What's the preferred way of accessing collections in a command file?
just
const currency = new Collection()
const currency = new Collection()
in the main file where that try catch block from the top is
16 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ras on 2/1/2024 in #djs-questions
What's the preferred way of accessing collections in a command file?
I suppose I could also define it on the client object like the commands collection but I'm not sure what the right hing to do here is.
16 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ras on 2/1/2024 in #djs-questions
What's the preferred way of accessing collections in a command file?
import { SlashCommandBuilder } from 'discord.js'

export default {
data: new SlashCommandBuilder()
.setName('user')
.setDescription('Provides information about the user.'),
async execute(interaction, currency) {
const user = currency.get(interaction.member.id)
await interaction.reply(`${interaction.user.username} has ${user.balance}`)
}
}
import { SlashCommandBuilder } from 'discord.js'

export default {
data: new SlashCommandBuilder()
.setName('user')
.setDescription('Provides information about the user.'),
async execute(interaction, currency) {
const user = currency.get(interaction.member.id)
await interaction.reply(`${interaction.user.username} has ${user.balance}`)
}
}
16 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ras on 2/1/2024 in #djs-questions
What's the preferred way of accessing collections in a command file?
Yeah, if like if I was following the guide for making a currency system, except I wanted my commands to broken down into individual files. How would I access the collections defined to modify them from within that command file. Or is that not what you're asking?
16 replies