Discord.js: Channel author ID ≠ username

Created on 11 May 2018  Â·  4Comments  Â·  Source: discordjs/discord.js

Please describe the problem you are having in as much detail as possible:
If the user types the command so that the bot creates a channel that contains the user ID (message.author.id) then it can do it once. If you create a channel for the second time, you will not be able to. This is a blockade. That's my goal. The code below shows it. In case I would like the bot to create a channel with the username (message.author.username), it can make as many channels as it wants. It should not be like that. It should be like with ID.

Video showing the whole problem:
https://youtu.be/QaTYJRxbLvI

Include a reproducible code sample here, if possible:

With user ID.
if (message.guild.channels.exists("name", "ticket" + message.author.id)) return message.channel.send({ embed: whylol });
message.guild.createChannel(`ticket${message.author.id}`, "text").then(c => {

With user username.
if (message.guild.channels.exists("name", "ticket" + message.author.username)) return message.channel.send({ embed: whylol });
message.guild.createChannel(`ticket${message.author.username}`, "text").then(c => {

Further details:

  • discord.js version: 11.3.2
  • node.js version: 9.x
question (please use Discord instead)

Most helpful comment

that's becuz the channel's name is lowercase, ur message.author.username might have uppercase (or anything that is illegal in a channel's name) thus making the .exists failed

either u do a check and turn the message.author.username into something that is channel-name-able, or use userID for it

All 4 comments

The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue – you will get redirected there anyway.

This is not a bug, lol?

No, it's not. All IDs are snowflakes, or in other words, +17 digit numbers (we have them as strings them due to IEEE 754's lack of accuracy over 16 digits) that never change. Usernames are another thing and can be changed (same with the discriminator number). Your issue is most likely caused by your code as Collection#exists works perfectly (and I have just tested it).

that's becuz the channel's name is lowercase, ur message.author.username might have uppercase (or anything that is illegal in a channel's name) thus making the .exists failed

either u do a check and turn the message.author.username into something that is channel-name-able, or use userID for it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tiritto picture tiritto  Â·  3Comments

Blumlaut picture Blumlaut  Â·  3Comments

Dmitry221060 picture Dmitry221060  Â·  3Comments

xCuzImPro picture xCuzImPro  Â·  3Comments

kvn1351 picture kvn1351  Â·  3Comments