我正在尝试向机器人日志/快照发送消息,当有人说“ zsnipe”时,我想知道如何使“ zsnipe”成为命令,但该命令不起作用,我在做错什么吗?这是代码:
bot.on('messageDelete', message => {
const embed8 = new Discord.MessageEmbed()
.setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.avatarURL({dynamic : true}))
.setDescription(message.content)
if (message.content === 'zsnipe'){
message.channel.send(embed8)
}
})
您的帮助将不胜感激!
答案 0 :(得分:0)
这是一些代码,用于将最后删除的消息保存在频道中,并在有人说出zsnipe
时允许对其进行检索。
警告: 如果漫游器重新启动,则删除的消息将丢失。
const deletedMessages = new Discord.Collection();
bot.on('message', async message => {
if (message.author.bot) return;
const args = message.content.trim().split(/\s+/g);
const command = args.shift().toLowerCase();
switch (command) {
case 'zsnipe':
const msg = deletedMessages.get(message.channel.id);
if (!msg) return message.reply('could not find any deleted messages in this channel.');
const embed = new Discord.MessageEmbed()
.setAuthor(msg.author.tag, msg.author.avatarURL({ dynamic: true }))
.setDescription(msg.content);
message.channel.send(embed).catch(err => console.error(err));
break;
});
bot.on('messageDelete', message => {
deletedMessages.set(message.channel.id, message);
});