如何创建文本频道
How to create a text channel
最近在做一个discord bot,想在玩家输入命令后做一个频道>report [Tag] [Reason]
。
这是我尝试过的两种方法(一种来自以前的 Whosebug 问题,但对我不起作用):
function makeChannel(message){
var server = message.guild;
var name = message.author.username;
server.createChannel(name, "text");
}
然后我尝试了我自己的版本,看看我是否可以做到:
var name = message.author.username;
let reportchannel = server.createChannel(name, "text");
message.createChannel(reportchannel);
但是都没有用,我很想得到帮助!
感谢您的帮助和建议,不胜感激!
正如所见here创建文本通道的正确方法(并且由于您使用的是消息变量,我假设您在消息事件中)
let name = message.author.username;
message.guild.createChannel(name, 'text')
.then(console.log)
.catch(console.error);
此外,我的另一个建议是使用 let
而不是 var
因为 this reason
编辑:刚刚注意到这对您不起作用的主要原因是因为您正在使用 message.createChannel()
并注意 message.guild.createChannel()
最近在做一个discord bot,想在玩家输入命令后做一个频道>report [Tag] [Reason]
。
这是我尝试过的两种方法(一种来自以前的 Whosebug 问题,但对我不起作用):
function makeChannel(message){
var server = message.guild;
var name = message.author.username;
server.createChannel(name, "text");
}
然后我尝试了我自己的版本,看看我是否可以做到:
var name = message.author.username;
let reportchannel = server.createChannel(name, "text");
message.createChannel(reportchannel);
但是都没有用,我很想得到帮助!
感谢您的帮助和建议,不胜感激!
正如所见here创建文本通道的正确方法(并且由于您使用的是消息变量,我假设您在消息事件中)
let name = message.author.username;
message.guild.createChannel(name, 'text')
.then(console.log)
.catch(console.error);
此外,我的另一个建议是使用 let
而不是 var
因为 this reason
编辑:刚刚注意到这对您不起作用的主要原因是因为您正在使用 message.createChannel()
并注意 message.guild.createChannel()