Artix.
Artix.
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
its good thx
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
I will listen to your advice I will try to work on it again
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
hmmm
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
Yesterday I didn't have the problem and I don't fully understand why.
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
and yep yes I haven't used it interactionCreate but it works normally
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
client.commands = new Collection();

const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

const commands = [];

for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
client.commands.set(command.data.name, command);
commands.push(command.data.toJSON());
}

// Fonction pour déployer les commandes
const deployCommands = async () => {
const rest = new REST({ version: '10' }).setToken(token);
try {
console.log('Déploiement des commandes en cours...');

if (guildId) {
await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
console.log('Commandes spécifiques au serveur déployées avec succès.');
console.log(`Commandes chargées : ${client.commands.map(cmd => cmd.data.name).join(', ')}`);
} else {
await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log('Commandes globales déployées avec succès.');
}
} catch (error) {
console.error('Erreur lors du déploiement des commandes :', error);
}
};
client.commands = new Collection();

const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

const commands = [];

for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
client.commands.set(command.data.name, command);
commands.push(command.data.toJSON());
}

// Fonction pour déployer les commandes
const deployCommands = async () => {
const rest = new REST({ version: '10' }).setToken(token);
try {
console.log('Déploiement des commandes en cours...');

if (guildId) {
await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
console.log('Commandes spécifiques au serveur déployées avec succès.');
console.log(`Commandes chargées : ${client.commands.map(cmd => cmd.data.name).join(', ')}`);
} else {
await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log('Commandes globales déployées avec succès.');
}
} catch (error) {
console.error('Erreur lors du déploiement des commandes :', error);
}
};
All for my command collection
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
here
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
how so ?
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
hmmm ok
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
My index.js
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
// STARBOARD

client.on('messageReactionAdd', async (reaction, user) => {
if (reaction.partial) await reaction.fetch();
if (user.bot) return;

const { message } = reaction;

if (user.id === message.author.id && reaction.emoji.name === '⭐') {
return await reaction.users.remove(user.id);
}

if (reaction.emoji.name === '⭐' && reaction.count >= 3) {
const starboardChannel = client.channels.cache.get(starboardChannelId);
if (!starboardChannel) return console.log('Channel introuvable.');

const messageLink = `https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.id}`;

const embed = new EmbedBuilder()
.setColor('#FFD700')
.setAuthor({ name: "⭐ Starboard ⭐ " + "@" + message.author.tag, iconURL: message.author.displayAvatarURL() })
.setDescription(`${message.content || 'Aucun message.'}\n\n[➡️ Message original](${messageLink})`)
.setTimestamp(message.createdTimestamp)
.setFooter({ text: `⭐ ${reaction.count} | Message ID: ${message.id}` });

if (message.attachments.size > 0) {
const attachment = message.attachments.first();
if (attachment.contentType.startsWith('image/')) {
embed.setImage(attachment.url);
}
}

await starboardChannel.send({ embeds: [embed] });
}
});

// Suppression lien discord

client.on('messageCreate', async (message) => {
if (message.author.bot) return;

const inviteRegex = /discord\.gg\/\w+|discordapp\.com\/invite\/\w+/i;

if (inviteRegex.test(message.content)) {
try {
await message.delete();

const warnsFilePath = path.join(__dirname, 'warns.json');
const warnsData = fs.existsSync(warnsFilePath) ? JSON.parse(fs.readFileSync(warnsFilePath, 'utf8')) : {};

const userId = message.author.id;
if (!warnsData[userId]) {
warnsData[userId] = [];
}
const newWarnId = warnsData[userId].length + 1;

warnsData[userId].push({
id: newWarnId,
reason: 'Lien discord',
timestamp: new Date().toISOString(),
messageContent: message.content
});

fs.writeFileSync(warnsFilePath, JSON.stringify(warnsData, null, 2));

console.log(`Warn ajouté ${message.author.tag} ID: ${newWarnId}`);
} catch (error) {
console.error('Erreur:', error);
}
}
});

client.login(token);
// STARBOARD

client.on('messageReactionAdd', async (reaction, user) => {
if (reaction.partial) await reaction.fetch();
if (user.bot) return;

const { message } = reaction;

if (user.id === message.author.id && reaction.emoji.name === '⭐') {
return await reaction.users.remove(user.id);
}

if (reaction.emoji.name === '⭐' && reaction.count >= 3) {
const starboardChannel = client.channels.cache.get(starboardChannelId);
if (!starboardChannel) return console.log('Channel introuvable.');

const messageLink = `https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.id}`;

const embed = new EmbedBuilder()
.setColor('#FFD700')
.setAuthor({ name: "⭐ Starboard ⭐ " + "@" + message.author.tag, iconURL: message.author.displayAvatarURL() })
.setDescription(`${message.content || 'Aucun message.'}\n\n[➡️ Message original](${messageLink})`)
.setTimestamp(message.createdTimestamp)
.setFooter({ text: `⭐ ${reaction.count} | Message ID: ${message.id}` });

if (message.attachments.size > 0) {
const attachment = message.attachments.first();
if (attachment.contentType.startsWith('image/')) {
embed.setImage(attachment.url);
}
}

await starboardChannel.send({ embeds: [embed] });
}
});

// Suppression lien discord

client.on('messageCreate', async (message) => {
if (message.author.bot) return;

const inviteRegex = /discord\.gg\/\w+|discordapp\.com\/invite\/\w+/i;

if (inviteRegex.test(message.content)) {
try {
await message.delete();

const warnsFilePath = path.join(__dirname, 'warns.json');
const warnsData = fs.existsSync(warnsFilePath) ? JSON.parse(fs.readFileSync(warnsFilePath, 'utf8')) : {};

const userId = message.author.id;
if (!warnsData[userId]) {
warnsData[userId] = [];
}
const newWarnId = warnsData[userId].length + 1;

warnsData[userId].push({
id: newWarnId,
reason: 'Lien discord',
timestamp: new Date().toISOString(),
messageContent: message.content
});

fs.writeFileSync(warnsFilePath, JSON.stringify(warnsData, null, 2));

console.log(`Warn ajouté ${message.author.tag} ID: ${newWarnId}`);
} catch (error) {
console.error('Erreur:', error);
}
}
});

client.login(token);
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
const { Client, GatewayIntentBits, Collection, REST, Routes, EmbedBuilder } = require('discord.js');
const fs = require('fs');
const path = require('path');
const { token, clientId, guildId, starboardChannelId } = require('./config.json');

// Création du client Discord
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
]
});

client.commands = new Collection();

const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

const commands = [];

for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
client.commands.set(command.data.name, command);
commands.push(command.data.toJSON());
}

// Fonction pour déployer les commandes
const deployCommands = async () => {
const rest = new REST({ version: '10' }).setToken(token);
try {
console.log('Déploiement des commandes en cours...');

if (guildId) {
await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
console.log('Commandes spécifiques au serveur déployées avec succès.');
console.log(`Commandes chargées : ${client.commands.map(cmd => cmd.data.name).join(', ')}`);
} else {
await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log('Commandes globales déployées avec succès.');
}
} catch (error) {
console.error('Erreur lors du déploiement des commandes :', error);
}
};

client.once('ready', async () => {
console.log(`Bot connecté en tant que ${client.user.tag}`);
await deployCommands();
});
const { Client, GatewayIntentBits, Collection, REST, Routes, EmbedBuilder } = require('discord.js');
const fs = require('fs');
const path = require('path');
const { token, clientId, guildId, starboardChannelId } = require('./config.json');

// Création du client Discord
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
]
});

client.commands = new Collection();

const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

const commands = [];

for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
client.commands.set(command.data.name, command);
commands.push(command.data.toJSON());
}

// Fonction pour déployer les commandes
const deployCommands = async () => {
const rest = new REST({ version: '10' }).setToken(token);
try {
console.log('Déploiement des commandes en cours...');

if (guildId) {
await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
console.log('Commandes spécifiques au serveur déployées avec succès.');
console.log(`Commandes chargées : ${client.commands.map(cmd => cmd.data.name).join(', ')}`);
} else {
await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log('Commandes globales déployées avec succès.');
}
} catch (error) {
console.error('Erreur lors du déploiement des commandes :', error);
}
};

client.once('ready', async () => {
console.log(`Bot connecté en tant que ${client.user.tag}`);
await deployCommands();
});
26 replies
DIAdiscord.js - Imagine an app
Created by Artix. on 9/1/2024 in #djs-questions
Aplication doesn't respond
26 replies