driedfxrn
driedfxrn
SIASapphire - Imagine a framework
Created by driedfxrn on 3/31/2024 in #discordjs-support
role not being given
3 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/28/2024 in #sapphire-support
Javascript
it makes my brain tingly
67 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/28/2024 in #sapphire-support
Javascript
i want to
67 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/28/2024 in #sapphire-support
Javascript
okay ill check it out
67 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/28/2024 in #sapphire-support
Javascript
hmm
67 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/28/2024 in #sapphire-support
Javascript
that's why i didnt use it
67 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/28/2024 in #sapphire-support
Javascript
from what i've heard
67 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/28/2024 in #sapphire-support
Javascript
outdated
67 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/30/2024 in #discordjs-support
Slash Command Error
it wasn't in the guide or anything
21 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/30/2024 in #discordjs-support
Slash Command Error
i passed in client myself
21 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/30/2024 in #discordjs-support
Slash Command Error
oke
21 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/30/2024 in #discordjs-support
Slash Command Error
this where i register the commands
const fs = require('node:fs')
const path = require('node:path')
const { REST } = require('@discordjs/rest')
const { Routes } = require('discord.js')
const { token, guildID, clientID} = require('discord.js')


function getFiles(dir){
const files = fr.readdirSync(dir, {
withFileypes: true
});

let commandFiles = {};

for(const file of files){
if(file.isDirectory()){
commandFiles = [
...commandFiles,
...getFiles(`${dir}/${file.name}`)
]
} else if(file.name.endsWith(".js")) {
commandFiles.push(`${dir}/${file.name}`)
}
}
return commandFiles;
}

let commands = [];
const commandFiles = getFiles('./commands')

for(const file of commandFiles){
const command = require(file)
commands.push(command.data.toJSON())
}

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

rest.put(Routes.applicationGuildCommands(clientID, guildID), { body: commands })
.then(() => console.log('Successfully registered application commands.'))
.catch(console.error)
const fs = require('node:fs')
const path = require('node:path')
const { REST } = require('@discordjs/rest')
const { Routes } = require('discord.js')
const { token, guildID, clientID} = require('discord.js')


function getFiles(dir){
const files = fr.readdirSync(dir, {
withFileypes: true
});

let commandFiles = {};

for(const file of files){
if(file.isDirectory()){
commandFiles = [
...commandFiles,
...getFiles(`${dir}/${file.name}`)
]
} else if(file.name.endsWith(".js")) {
commandFiles.push(`${dir}/${file.name}`)
}
}
return commandFiles;
}

let commands = [];
const commandFiles = getFiles('./commands')

for(const file of commandFiles){
const command = require(file)
commands.push(command.data.toJSON())
}

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

rest.put(Routes.applicationGuildCommands(clientID, guildID), { body: commands })
.then(() => console.log('Successfully registered application commands.'))
.catch(console.error)
21 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/30/2024 in #discordjs-support
Slash Command Error
ok
21 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/30/2024 in #discordjs-support
Slash Command Error
do you have any recommendations then
21 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/30/2024 in #discordjs-support
Slash Command Error
i plan on using sapphire after a bit of learning
21 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/30/2024 in #discordjs-support
Slash Command Error
no im new to the discord bot dev
21 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/30/2024 in #discordjs-support
Slash Command Error
oh wai
21 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/30/2024 in #discordjs-support
Slash Command Error
no bcuz in new
21 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/30/2024 in #discordjs-support
Slash Command Error
const {Client, Collection, GatewayIntentBits} = require('discord.js')
const fs = require('fs')
const path = require('node:path');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});

client.commands = getCommands('./commands');

module.exports = {
name: 'interactionCreate',
async execute(interaction) {
if (!interaction.isChatInputCommand()) return;

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

try {
if (interaction.replied) return;
command.execute(interaction);
} catch (error) {
console.error(error);
interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}}
};

// Functions
function getCommands(dir) {
let commands = new Collection();
const commandFiles = getFiles(dir);

for (const commandFile of commandFiles) {
const command = require("."+commandFile);
commands.set(command.data.toJSON().name, command);
}
return commands;
}

function getFiles(dir) {
const files = fs.readdirSync(dir, {
withFileTypes: true
});

let commandFiles = [];

for (const file of files) {
if (file.isDirectory()) {
commandFiles = [
...commandFiles,
...getFiles(`${dir}/${file.name}`)
];
} else if (file.name.endsWith(".js")) {
commandFiles.push(`${dir}/${file.name}`);
}
}
return commandFiles;
}
const {Client, Collection, GatewayIntentBits} = require('discord.js')
const fs = require('fs')
const path = require('node:path');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});

client.commands = getCommands('./commands');

module.exports = {
name: 'interactionCreate',
async execute(interaction) {
if (!interaction.isChatInputCommand()) return;

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

try {
if (interaction.replied) return;
command.execute(interaction);
} catch (error) {
console.error(error);
interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}}
};

// Functions
function getCommands(dir) {
let commands = new Collection();
const commandFiles = getFiles(dir);

for (const commandFile of commandFiles) {
const command = require("."+commandFile);
commands.set(command.data.toJSON().name, command);
}
return commands;
}

function getFiles(dir) {
const files = fs.readdirSync(dir, {
withFileTypes: true
});

let commandFiles = [];

for (const file of files) {
if (file.isDirectory()) {
commandFiles = [
...commandFiles,
...getFiles(`${dir}/${file.name}`)
];
} else if (file.name.endsWith(".js")) {
commandFiles.push(`${dir}/${file.name}`);
}
}
return commandFiles;
}
21 replies
SIASapphire - Imagine a framework
Created by driedfxrn on 3/28/2024 in #sapphire-support
Javascript
and i wanted to learn sapphire
67 replies