Doraa
Doraa
DIAdiscord.js - Imagine an app
Created by </JustTheDev> on 3/20/2024 in #djs-questions
Premium only command
what's your issue there ?
9 replies
DIAdiscord.js - Imagine an app
Created by </JustTheDev> on 3/20/2024 in #djs-questions
Premium only command
you can then do a script to add/remove users if they are not premium anymore
9 replies
DIAdiscord.js - Imagine an app
Created by </JustTheDev> on 3/20/2024 in #djs-questions
Premium only command
instead of doing True or false for each user
9 replies
DIAdiscord.js - Imagine an app
Created by </JustTheDev> on 3/20/2024 in #djs-questions
Premium only command
guess you can just add users ids to a premiumUsers.json and check on your .run() if the user is inside the file, i think it's the easiest way but there is probably a better way to do that
9 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
thanks @joe376 too
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
thanks !
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
My bad, that was just a scope error
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
oh i see where the problem is, it is only for commands that didnt have any option
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
i really don't understand
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
guess it is not from that
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
so i changed and it is still the same
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
i didnt have any error
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
const fs = require('fs');

module.exports = async bot => {
fs.readdirSync('./Commandes').filter(f => f.endsWith('.js')).forEach(async file =>{
let command = require(`../Commandes/${file}`);
if (!command.name || typeof command.name !== "string") throw new TypeError(`${file} n'a pas de nom ou le nom n'est pas une chaîne de caractères`)
bot.commands.set(command.name, command);
console.log(`Commande chargée: ${command.name} avec succes !`);
})
}
const fs = require('fs');

module.exports = async bot => {
fs.readdirSync('./Commandes').filter(f => f.endsWith('.js')).forEach(async file =>{
let command = require(`../Commandes/${file}`);
if (!command.name || typeof command.name !== "string") throw new TypeError(`${file} n'a pas de nom ou le nom n'est pas une chaîne de caractères`)
bot.commands.set(command.name, command);
console.log(`Commande chargée: ${command.name} avec succes !`);
})
}
and the method i use to check all commands files
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
const Discord = require('discord.js');

module.exports = {
name: "ping",
description: "Obtenez le ping/la latence du bot",
dm: true,
category: "Informations",
permission: "Aucune",
usage: "/ping",

async run(bot, message) {
let pingEmbed = new Discord.EmbedBuilder()
.setAuthor({ name: message.user.username, iconURL: message.user.displayAvatarURL({ dynamic: true }) })
.setDescription(`Ping : \`${bot.ws.ping}ms\``)
.setColor('Green')
await message.reply({embeds: [pingEmbed]});
}
}
const Discord = require('discord.js');

module.exports = {
name: "ping",
description: "Obtenez le ping/la latence du bot",
dm: true,
category: "Informations",
permission: "Aucune",
usage: "/ping",

async run(bot, message) {
let pingEmbed = new Discord.EmbedBuilder()
.setAuthor({ name: message.user.username, iconURL: message.user.displayAvatarURL({ dynamic: true }) })
.setDescription(`Ping : \`${bot.ws.ping}ms\``)
.setColor('Green')
await message.reply({embeds: [pingEmbed]});
}
}
This is one of the command that didnt show up, but it show as loaded in my console
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
this one
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
const Discord = require("discord.js")
const { REST } = require("@discordjs/rest")
const { Routes } = require("discord.js")

module.exports = async bot => {

let commands = []

bot.commands.forEach(async command => {

let slashcommand = new Discord.SlashCommandBuilder()
.setName(command.name)
.setDescription(command.description)
.setDMPermission(command.dm)
.setDefaultMemberPermissions(command.permission === "Aucune" ? null : command.permission)

if(command.options?.length >= 1 ){
for(let i = 0; i < command.options.length; i++) {
console.log(command)
if (command.name === "say") {
if (i === 0) {
slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length)}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required).addChoices(...command.options[0].choices))
}
else {
slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length)}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required))
}
}
else {
slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length)}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required))
}
}
await commands.push(slashcommand)
}
})

const rest = new REST({version: "10"}).setToken(bot.token)

await rest.put(Routes.applicationCommands(bot.user.id), {body: commands})
console.log("les slashcommandes sont créées avec succès !")
}
const Discord = require("discord.js")
const { REST } = require("@discordjs/rest")
const { Routes } = require("discord.js")

module.exports = async bot => {

let commands = []

bot.commands.forEach(async command => {

let slashcommand = new Discord.SlashCommandBuilder()
.setName(command.name)
.setDescription(command.description)
.setDMPermission(command.dm)
.setDefaultMemberPermissions(command.permission === "Aucune" ? null : command.permission)

if(command.options?.length >= 1 ){
for(let i = 0; i < command.options.length; i++) {
console.log(command)
if (command.name === "say") {
if (i === 0) {
slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length)}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required).addChoices(...command.options[0].choices))
}
else {
slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length)}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required))
}
}
else {
slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length)}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required))
}
}
await commands.push(slashcommand)
}
})

const rest = new REST({version: "10"}).setToken(bot.token)

await rest.put(Routes.applicationCommands(bot.user.id), {body: commands})
console.log("les slashcommandes sont créées avec succès !")
}
17 replies
DIAdiscord.js - Imagine an app
Created by Doraa on 4/13/2023 in #djs-questions
Problem with the loading of 3 commands
Yes, all my others commands work, and they use the same method to load
17 replies