Unfragender | Jonas
Unfragender | Jonas
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
(Kick_Members) permission
No description
28 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
(Kick_Members) permission
FROM THIS
28 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
(Kick_Members) permission
No description
28 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
(Kick_Members) permission
I'm not having a hard time, I've tried the methods the guide gave me, but there are always errors
28 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
(Kick_Members) permission
Bro, I've tried a lot of methods that don't help. Besides, I have no idea how to do it like you told me. I've written to my friend several times, who has been programming JS for years, and even he doesn't really have a clue
28 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
Thank you very much! :D
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
It works!
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
Okay
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
That means?
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
ok
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
I took it from the guide.
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
I have no idea what I should change in the code.
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
But i have no idea
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
Yes..
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
Yes
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
Which script do you need so that you can help me?#
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

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

if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}

try {
await command.execute(interaction);
} catch (error) {
console.error(error);

if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
} else {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
});

const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));

for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);

if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}

client.login(token);
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

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

if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}

try {
await command.execute(interaction);
} catch (error) {
console.error(error);

if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
} else {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
});

const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));

for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);

if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}

client.login(token);
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
index.js:
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();

client.once(Events.ClientReady, () => {
console.log(`Ready! Logged in as ${client.user.tag}`);
client.user.setPresence({ activities: [{ name: 'Minecraft' }], status: 'idle' });
});

const commandsPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(commandsPath);

for (const folder of commandFolders) {
const folderPath = path.join(commandsPath, folder);
const commandFiles = fs.readdirSync(folderPath).filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
const filePath = path.join(folderPath, file);
const command = require(filePath);

if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();

client.once(Events.ClientReady, () => {
console.log(`Ready! Logged in as ${client.user.tag}`);
client.user.setPresence({ activities: [{ name: 'Minecraft' }], status: 'idle' });
});

const commandsPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(commandsPath);

for (const folder of commandFolders) {
const folderPath = path.join(commandsPath, folder);
const commandFiles = fs.readdirSync(folderPath).filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
const filePath = path.join(folderPath, file);
const command = require(filePath);

if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
user.js:
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('user')
.setDescription('Provides information about the user.'),
async execute(interaction) {
// interaction.user is the object representing the User who ran the command
// interaction.member is the GuildMember object, which represents the user in the specific guild
await interaction.reply(`This command was run by ${interaction.user.username}, who joined on ${interaction.member.joinedAt}.`);
},
};
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('user')
.setDescription('Provides information about the user.'),
async execute(interaction) {
// interaction.user is the object representing the User who ran the command
// interaction.member is the GuildMember object, which represents the user in the specific guild
await interaction.reply(`This command was run by ${interaction.user.username}, who joined on ${interaction.member.joinedAt}.`);
},
};
27 replies
DIAdiscord.js - Imagine an app
Created by Unfragender | Jonas on 11/9/2023 in #djs-questions
Unknown Interaction
Despite an error being registered, the command is executed.
27 replies