【发布时间】:2021-06-24 11:48:51
【问题描述】:
刚接触编码,最近开始使用 JS 制作 discord 机器人。这是一个机器人,其中特定的 mp4 与特定的 sn-p 一起播放。
当我输入命令时,mp4 不发送,只是嵌入消息,我遇到了麻烦。基本上,如果我这样做-snip kratos,机器人会发送嵌入消息而不是 mp4。
这是我目前所拥有的:
const fs = require('fs');
const { Client, MessageAttachment } = require('discord.js');
const config = require('./config.json');
const { prefix, token } = require('./config.json');
const client = new Client();
client.commands = new Discord.Collection();```
And here are the command events:
``` client.on('message', message => {
if (message.content === `${prefix}snip kratos`) {
if (message.author.bot) return
const kratos = new Discord.MessageEmbed()
.setColor('#ffb638')
.setTitle('Kratos')
.setDescription('Sending 1 snippet(s)...')
.setTimestamp()
.setFooter('SkiBot');
message.channel.send(kratos);
client.on('message', message => {
if (message.content === `${prefix}snip kratos`) {
if (message.author.bot) return
const attachment = new MessageAttachment('./snippets/kratos/Kratos.mp4');
message.channel.send(attachment);
}
});
}
});
client.on('message', message => {
if (message.content === `${prefix}snip johnny bravo`) {
if (message.author.bot) return
const kratos = new Discord.MessageEmbed()
.setColor('#ffb638')
.setTitle('Johnny Bravo')
.setDescription('Sending 1 snippet(s)...')
.setTimestamp()
.setFooter('SkiBot');
message.channel.send(kratos);
client.on('message', message => {
if (message.content === `${prefix}snip johnny bravo`) {
if (message.author.bot) return
const attachment = new MessageAttachment('./snippets/Johnny_Bravo/Johnny_Bravo.mp4');
message.channel.send(attachment);
}
});
}
});```
【问题讨论】:
标签: javascript node.js discord.js