问题
Recently I have been making a discord bot, and I wanted to make a channel once the players have entered the command >report [Tag] [Reason].
Here are the two methods I have tried (one from a previous StackOverflow question that did not work for me):
function makeChannel(message){
var server = message.guild;
var name = message.author.username;
server.createChannel(name, "text");
}
Then I tried my own version to see if I could do it:
var name = message.author.username;
let reportchannel = server.createChannel(name, "text");
message.createChannel(reportchannel);
Yet neither work, and I am dying for help!
Thanks for the help and suggestions, greatly appreciated!
回答1:
As seen here the proper way to create a text channel (and since you're using the message variable I'm going to assume you're in the message event)
let name = message.author.username;
message.guild.createChannel(name, 'text')
.then(console.log)
.catch(console.error);
Also, another suggestion I have is to use let instead of var because this reason
edit: Just noticed the main reason this isn't working for you is because you're using message.createChannel() and note message.guild.createChannel()
来源:https://stackoverflow.com/questions/54099201/how-to-create-a-text-channel