简体   繁体   English

在 guildCreate discord.js 上创建频道

[英]Creating a channel on guildCreate discord.js

I'm trying to create a bot that will create a text channel when the bot joins the server.我正在尝试创建一个机器人,该机器人将在机器人加入服务器时创建一个文本通道。 The code I have so far is this but obviously message.guild won't work there.到目前为止我的代码是这样的,但显然 message.guild 在那里不起作用。 I can't find a work around any help will be appreciated:).我找不到任何帮助的工作将不胜感激:)。

client.on("guildCreate", () => {
console.log("Joined server!")

guild.channels.create("text-channel", {type: 'text'})

}) })

The guildCreate Event accepts a parameter which has type Guild , you can use it to get a reference to the guild guildCreate事件接受一个Guild类型的参数,您可以使用它来获取对公会的引用

client.on("guildCreate", guild => { 
  // code
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM