Discord js创建不和谐类别
Discord js creating discord category
我正在尝试使用 Discord Bot 在 Discord 服务器上创建一个类别,但我无法在互联网。我还看了"discord.js.org"。然后我认为没有任何可能这样做。那么有什么办法可以在discord服务器上做一个分类吗?
您需要使用.createChannel
方法,然后输入“类别”作为频道类型
<guild>.createChannel("NAME OF THE CHANNEL", "category")
我建议使用 promise,因为它会为您的代码增加很多功能和安全性
guild.createChannel('new-category', {
type: 'category',
permissionsOverwrites: [{
id: guild.id,
deny: ['MANAGE_MESSAGES'],
allow: ['SEND_MESSAGES']
}]
})
.then(console.log)
.catch(console.error);
这允许您创建具有权限的频道并实际处理任何错误,例如频道已经存在或您的机器人无法创建所述频道导致其分配的权限。
这是正确的方法。
创建频道的示例
guild.createChannel('new-general', { type: 'text' })
.then(console.log)
.catch(console.error);
v12:
message.guild.channels.create('Category', { type: 'category' });
我做了一个命令代码供你使用。修改并使用。
if(message.content === `${prefix}create-channel`) {
message.guild.createChannel('name', {
//Channel type (text || voice || category)
type: 'text',
permissionsOverwrites: [{
id: guild.id,
deny: [],
allow: ['SEND_MESSAGES']
}]
})
.catch(console.error);
}
discordjs v13 需要 GUILD_CATEGORY 而不仅仅是“类别”
message.guild.channels.create("Name", { type: "GUILD_CATEGORY" });
我正在尝试使用 Discord Bot 在 Discord 服务器上创建一个类别,但我无法在互联网。我还看了"discord.js.org"。然后我认为没有任何可能这样做。那么有什么办法可以在discord服务器上做一个分类吗?
您需要使用.createChannel
方法,然后输入“类别”作为频道类型
<guild>.createChannel("NAME OF THE CHANNEL", "category")
我建议使用 promise,因为它会为您的代码增加很多功能和安全性
guild.createChannel('new-category', {
type: 'category',
permissionsOverwrites: [{
id: guild.id,
deny: ['MANAGE_MESSAGES'],
allow: ['SEND_MESSAGES']
}]
})
.then(console.log)
.catch(console.error);
这允许您创建具有权限的频道并实际处理任何错误,例如频道已经存在或您的机器人无法创建所述频道导致其分配的权限。
这是正确的方法。
创建频道的示例
guild.createChannel('new-general', { type: 'text' })
.then(console.log)
.catch(console.error);
v12:
message.guild.channels.create('Category', { type: 'category' });
我做了一个命令代码供你使用。修改并使用。
if(message.content === `${prefix}create-channel`) {
message.guild.createChannel('name', {
//Channel type (text || voice || category)
type: 'text',
permissionsOverwrites: [{
id: guild.id,
deny: [],
allow: ['SEND_MESSAGES']
}]
})
.catch(console.error);
}
discordjs v13 需要 GUILD_CATEGORY 而不仅仅是“类别”
message.guild.channels.create("Name", { type: "GUILD_CATEGORY" });