I am coding a discord bot. The commands I'm having issues with is temprole and kick.
The ping command seems to work fine.
main.js
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '-';
const fs = require('fs');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once('ready', () => {
console.log('Bot is online!');
});
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if (command == 'ping') {
client.commands.get('ping').execute(message, args);
} else if (command == 'temprole') {
client.commands.get('temprole').execute(message, args);
}
});
client.login('token')
temprole.js
module.exports = {
name: 'youtube',
description: "give the member a temprole",
execute(message, args) {
if (message.member.roles.cache.has('798180573998612512')) {
} else {
message.channel.send('You dont have access to this command!')
}
}
}
kick.js
module.exports = {
name: 'kick',
description: "This command kicks a member!",
execute(messages, args) {
const member = message.mentions.users.first();
if (member) {
const memberTarger = message.guild.members.cache.get(member.id);
memberTarger.kick();
message.channel, send('User has been kicked');
} else {
message.channel.send('You coundt kick that member');
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…