目前,我的bot将接受使用!wts命令的任何消息,并将消息镜像到指定的通道(在代码中设置)。
如果消息包含" UK8“,它将被发送到UK8通道,或者如果它包含" UK3.5”,它将被发送到UK3.5通道,因此它将查找关键字并将消息分配给相应的通道(而不是像我所做的那样对其进行硬编码)。
我刚刚开始学习不一致的botting,所以我很感谢大家的帮助。
这是我到目前为止所知道的:
client.on('message', message => {
if (message.author.bot) return undefined //bot does not reply to itself
let msg = message.content.toLowerCase()
let args = message.content
.slice(prefix.length)
.trim()
.split(' ') //arguments
let command = args.shift().toLowerCase() //shifts args to lower case letters
if (command === 'wts') {
let say = args.join(' ') //space
//message.delete() - remove // if you want to have each message deleted
const generalChannel = message.guild.channels.cache.get('793494585123465875')
generalChannel.send(message.author.toString() + ": " + say)
}发布于 2020-12-30 10:41:00
let nameChannel = "";
if(say.includes("uk8")){
nameChannel = "UK8";
}else if(say.includes("uk3.5")){
nameChannel = "uk3.5";
}else{
nameChannel = "defaultChannel";
}
const selectedChannel = client.channels.cache.find(channel => channel.name === nameChannel );
selectedChannel.send(say)https://stackoverflow.com/questions/65499951
复制相似问题