Örneğin !aktiflik dediğimde bir mesaj yollicak ve sunucuda aktif olarak kaç kişi olduğunu göstercek. Kodum burada:
JavaScript:
const { Client, GatewayIntentBits, Partials, REST, Routes, ActivityType, EmbedBuilder } = require('discord.js');
const { token, botID } = require('./config.json');
const client = new Client({ intents: 7796});
const commands = [
{
name: 'test',
description: 'test'
},
{
name: 'test2',
description: 'test2'
},
];
const rest = new REST({version: '10'}).setToken(token);
(async () => {
try {
await rest.put(Routes.applicationCommands(botID), { body: commands })
console.log('Komutlar Yüklendi ✅');
} catch (error){
console.log(error);
}
})();
client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === 'test'){
await interaction.reply({ content: 'test.', ephemeral: false})
};
if (interaction.commandName === 'test2'){
await interaction.reply({ content: 'test2', ephemeral: false})
};
});
client.login(token).then(() => {
console.log('${client.user.username} ismi ile giriş yaptım! 🤖');
client.user.setStatus('idle');
client.user.setActivity({ name: '/yardım', type: ActivityType.Watching});
}).catch((err) => console.log(err));