Channel naming
Hello!
I'm working on a ticket system that creates a channel, and uses
user.tag
as part of the channel name.
Is there a chance that a user has such a fancy name that it it won't be usable in a channel name?
Or are the rules for naming channels and users the same / user.tag
already returns the user's tag in a "safe" format?3 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
The tag can have much different characters than channels allow (remember text channels don't even allow capital letters)
Hence, most ticket bots just use the id instead
What I am doing now is:
- I create the channel name like this:
const ticketchannelname = `${interaction.user.tag}--${new Date(Date.now()).toLocaleString('hu-HU')}`;
- Then use this constant as the name parameter for guild.channels.create
Worked fine so far with my not so fancy name, didn't care about the capital letter, created the channel in all lowercases, even was able to turn the date and timestamp into the "channel name format"
eg: farleena-dani8626-2022-12-31-182742
I was just curious if some random dude with superduper extra fancy special characters in his username could make make this command error out
Well, I could use the user id, but that looks dumb as a channel name and is not so easy to read 😄
I see, thank you!