简体   繁体   中英

Channel create name Discord.js

How can I make the channel that is created called for example " TheRedyYT's Channel "?

addChannel.guild.channels.create(member.user.username, {
            type: 'voice',
            parent: addCategory.id,
            permissionOverwrites: [{
                id: member.id,
                allow: ['MANAGE_CHANNELS', 'MANAGE_ROLES']
            }]
    

If you want the channel named to the executor of the command you can try:

addChannel.guild.channels.create(`${member.user.username}'s Channel`, {
        type: 'voice',
        parent: addCategory.id,
        permissionOverwrites: [{
            id: member.id,
            allow: ['MANAGE_CHANNELS', 'MANAGE_ROLES']
        }]

I have to assume that addChannel , member and addCategory are already defined. In the code example above I made a string as the name of the created channel. In this string I used the username of the member as you did, but with the result that you want. For example if I would execute the command the channel would be named Freem | Jannik's Channel Freem | Jannik's Channel .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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