这是我的两个代码,它们位于单独的文件夹中,我尝试的是嵌入中的消息可以与我的前缀一起使用,但是当我使用此命令时,我放在它后面的字母,数字或符号无关紧要,因为无论前缀如何,命令都是相同的执行。{ "token": "(my token)", "prefix": "-"}const { Client, MessageEmbed } = require ("discord.js");const client = new Client();const MessageAttachment = require("discord.js");const config = require("./config.json");const Discord = require('discord.js');const bot = new Discord.Client();let prefix = config.prefix;/////////////////BOT///////////////////function doKissAction() { var rand = [ 'https://media2.giphy.com/media/G3va31oEEnIkM/giphy.gif', 'https://media.tenor.com/images/fbb2b4d5c673ffcf8ec35e4652084c2a/tenor.gif', 'https://media.giphy.com/media/ZRSGWtBJG4Tza/giphy.gif', 'https://media.giphy.com/media/oHZPerDaubltu/giphy.gif', 'https://acegif.com/wp-content/uploads/anime-kiss-m.gif', 'https://media.giphy.com/media/bm2O3nXTcKJeU/giphy.gif', 'https://media.giphy.com/media/nyGFcsP0kAobm/giphy.gif', 'https://media0.giphy.com/media/KH1CTZtw1iP3W/source.gif' ]; return rand[Math.floor(Math.random() * rand.length)];}client.on('message', message => { let args = message.content.substring(prefix.length).split(" "); switch (args[0]) { case 'kiss':if(!args[1] ) { message.channel.send('¡Necesitas a alguien a quien besar!');} else { const personTagged = message.mentions.members.first(); const acceptedEmbed = new Discord.MessageEmbed() .setTitle(':sparkles: :heart: ¡Que romantico! :heart: :sparkles: ') .setImage(doKissAction()) .setColor(0xF086FF) .setDescription('`' + message.author.username + '`' + ' ha besado a ' + '`' + personTagged.displayName + '`') message.channel.send(acceptedEmbed); // personTagged.send();} break; }})
1 回答

人到中年有点甜
TA贡献1895条经验 获得超7个赞
问题是你没有检查它是否以前缀开头,你只是删除了前缀
let args = message.content.split(" ");
let commandName = args[0];
if(!commandName.startsWith(prefix)) return;
commandName = commandName.slice(prefix.length);
switch(commandName) {
case 'kick': {
//..code
}
}
添加回答
举报
0/150
提交
取消