如果我说得更具体一点,我的意思是如果我说 n!say(文本),机器人只会在频道中说(文本)。
答案 0 :(得分:0)
这是一个非常简单的方法, 当用户发送前缀和命令时,它只是将其拆分并返回消息。
const client = new Discord.Client();
// Set the prefix
const prefix = "!";
client.on("ready", () => {
console.log("I am ready!");
});
client.on("message", (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command == "say"){ // set the command
message.channel.send(args);
}
});
client.login("Bot Token Here");
这是取自 documentation。