安装机器人时如何创建频道?
How make channel when bot installed?
我想在安装机器人时创建频道。
如果新用户登录到 discord 服务器,他应该会看到 bot 的频道,并且应该向该频道发送一些消息。
我这样试过:
client.on("ready", (message) => {
let guild = message.guild;
guild.channels
.create("nft-checking", { reason: "Needed a cool new channel" })
.then(console.log)
.catch(console.error);
}
但是在on ready事件中使用公会出现了一些错误。
要创建一个频道,您必须先准确指定服务器,如下所示:
client.guilds.cache.get("id of your server")
.channels.create("test", { type : "GUILD_TEXT", topic : "Some cool channel"})
.then(console.log)
.catch(console.error)
我想在安装机器人时创建频道。 如果新用户登录到 discord 服务器,他应该会看到 bot 的频道,并且应该向该频道发送一些消息。 我这样试过:
client.on("ready", (message) => {
let guild = message.guild;
guild.channels
.create("nft-checking", { reason: "Needed a cool new channel" })
.then(console.log)
.catch(console.error);
}
但是在on ready事件中使用公会出现了一些错误。
要创建一个频道,您必须先准确指定服务器,如下所示:
client.guilds.cache.get("id of your server")
.channels.create("test", { type : "GUILD_TEXT", topic : "Some cool channel"})
.then(console.log)
.catch(console.error)