defaultChannel()
已弃用,没有其他选择。
您需要指定发送消息的通道,但由于某些服务器具有唯一的通道名称,因此无法正常工作。。。除非它们都有相同的通道名称,并且保持不变(一些PEEP更改了general的名称)。
好我为它编写了一个代码(如果频道名称为“general”,则有效)
if (command === "sendguildmessages") {
if (message.author.id === "231956829159161856") {
try {
let toSay = "messageToSend"
this.client.guilds.map((guild) => {
let found = 0
guild.channels.map((c) => {
if (found === 0) {
if (c.type === "text") {
if (c.permissionsFor(this.client.user).has("VIEW_CHANNEL") === true) {
if (c.permissionsFor(this.client.user).has("SEND_MESSAGES") === true) {
c.send(toSay);
found = 1;
}
}
}
}
});
});
}
catch (err) {
console.log("Could not send message to a (few) guild(s)!");
}
} else {
message.reply("You cant do that!")
}
}
摘自:
https://github.com/itsYuuki/SmoreBot/blob/master/commands/control/gann.js