Discord.js Bot上线,但嵌入式系统赢了';不要发表意见分歧
我是编程新手,通过看一些教程开始制作discord机器人。我想机器人DM的不和谐嵌入到用户谁键入“-买”在一个文本频道。运行代码时,bot联机并运行“your bot name is online!”但不发送DM。我将非常感谢任何帮助。谢谢Discord.js Bot上线,但嵌入式系统赢了';不要发表意见分歧,discord.js,Discord.js,我是编程新手,通过看一些教程开始制作discord机器人。我想机器人DM的不和谐嵌入到用户谁键入“-买”在一个文本频道。运行代码时,bot联机并运行“your bot name is online!”但不发送DM。我将非常感谢任何帮助。谢谢 const Discord = require('discord.js'); const client = new Discord.Client(); const prefix = '-'; client.once('ready', () =>
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '-';
client.once('ready', () => {
console.log('your bot name is online!');
});
client.on('message', message =>{
if(message.author.client) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLocaleLowerCase();
if(command === 'buy'){
const testEmbed = new Discord.MessageEmbed()
.setColor(0x7f03fc)
.setTitle('test embeddy')
.setDescription('test description woo')
.setFooter('this is the footer')
try {
message.author.send(testEmbed);
} catch {
message.reply('Sorry I cannot message you! Check if your DMs are public!')
}
}
});
client.login('');
令牌不是问题所在,我删除了它,以便可以在此处上传
消息。author.client
返回bot客户端,而它不返回布尔值。所以你的机器人被封锁了。尝试删除该代码并编写message.author.bot
,如果消息作者是bot用户,则返回布尔值。它会工作。消息.author.client返回bot客户端,但不返回布尔值。所以你的机器人被封锁了。尝试删除该代码并编写message.author.bot
,如果消息作者是bot用户,则返回布尔值。会有用的。谢谢您的接受!如果我的答案有帮助,请投票(???)谢谢接受!如果我的答案有帮助,请向上投票(?)