AzcenD
AzcenD
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
the support for it is clearly bigger
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
I guess i will just learn some basic Javascript instead
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
where can i find those
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
c++ was my first language i used to learn basic programming and making game in UE and c# to make games in unity
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
I have played around with c++ and c# earlier
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
no i have not used javascript earlier
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
And how do i pass it into the file?
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
how do i import the already initialized client
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
i just looked at the guide and their was a new client there as well
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
yeah missed that
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
oh
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
hello.js
const { AutoModerationActionExecution } = require("discord.js");

const {SlashCommandBuilder} = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('hello')
.setDescription('Says hello to someone')
.addUserOption(option =>
option
.setName('user')
.setDescription('The use to say hello to')
.setRequired(false)
),

async execute(interaction) {
const user = interaction.options.getUser("user") || interaction.user;
interaction.reply(`Hello ${interaction.user.username}!`)
}
}
const { AutoModerationActionExecution } = require("discord.js");

const {SlashCommandBuilder} = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('hello')
.setDescription('Says hello to someone')
.addUserOption(option =>
option
.setName('user')
.setDescription('The use to say hello to')
.setRequired(false)
),

async execute(interaction) {
const user = interaction.options.getUser("user") || interaction.user;
interaction.reply(`Hello ${interaction.user.username}!`)
}
}
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
ready.js
module.exports = {
name: 'ready',
once: true,

async execute(client) {
console.log(`Logged in as ${client.user.username}`);
}
}
module.exports = {
name: 'ready',
once: true,

async execute(client) {
console.log(`Logged in as ${client.user.username}`);
}
}
32 replies
DIAdiscord.js - Imagine an app
Created by AzcenD on 6/19/2024 in #djs-questions
The application did not respond
interactionCtreate.js
const {Client, Collection, GatewayIntentBits} = require('discord.js');
const fs = require('node:fs');
const client = new Client({intents: [GatewayIntentBits.Guilds]});

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;
} catch (error) {
console.error(error);
}

command.execute(interaction);
}
}

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('node:fs');
const client = new Client({intents: [GatewayIntentBits.Guilds]});

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;
} catch (error) {
console.error(error);
}

command.execute(interaction);
}
}

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;
}
32 replies