discord-relay-chat / drc

Discord Relay Chat
https://discordrc.com
MIT License
18 stars 3 forks source link

'Username cannot contain "discord"' #6

Closed edfletcher closed 1 year ago

edfletcher commented 1 year ago

Both shoky and supay reported this independently when they were setting up DRC, and both seemed to have experience it only when trying to chat in #discordrc. It doesn't occur for me in that channel, but clearly there is an issue here that needs to be debugged.

edfletcher commented 1 year ago

shoky had a good thought that it might be related to channel transforms (which I don't have for this channel and he did, although a no-op transform), but he's still seeing this error:

DiscordAPIError: Invalid Form Body
name: Username cannot contain "discord"
antishok commented 1 year ago

Debug log with stack trace:

2022-12-22T00:56:44.800Z [debug] generateListManagementUCExport hilite irc.libera.chat
2022-12-22T00:56:44.802Z [debug] generateListManagementUCExport ignore irc.libera.chat
2022-12-22T00:56:44.806Z [debug] generateListManagementUCExport muted irc.libera.chat
2022-12-22T00:56:44.807Z [debug] ignoreList EdFletcher EdFletcher false
2022-12-22T00:56:44.808Z [debug] mutedList [ __drcFormatter: [Function (anonymous)] ] EdFletcher EdFletcher false
2022-12-22T00:56:45.000Z [debug] EdFletcher_irc.libera.chat drc-dev:irc.libera.chat:discordrc:1055259749052072027 https://robohash.org/EdFletcher_irc.libera.chat.png HOOKS?? 0
2022-12-22T00:56:45.000Z [debug] create anew... drc-dev:irc.libera.chat:discordrc:1055259749052072027
2022-12-22T00:56:45.270Z [error] Failed to post message to drc-dev:irc.libera.chat:discordrc:1055259749052072027/1055259749052072027! "Invalid Form Body
name: Username cannot contain "discord" DiscordAPIError: Invalid Form Body
name: Username cannot contain "discord"
    at RequestHandler.execute (/home/ubuntu/drc/node_modules/discord.js/src/rest/RequestHandler.js:349:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async RequestHandler.push (/home/ubuntu/drc/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
    at async TextChannel.createWebhook (/home/ubuntu/drc/node_modules/discord.js/src/structures/BaseGuildTextChannel.js:156:18)
    at async Redis.<anonymous> (/home/ubuntu/drc/discord/ipcMessages/irc-channelJoined.js:170:24)
edfletcher commented 1 year ago

Finally figured it out: indeed, createWebhook does not allow the name parameter to contain the word "discord" 🤦 (also confirmed experimentally). In reality that name is symbolic and for "user" use, as the hooks are properly identified by their ID, and as users of DRC we don't ever need to adjust these webhooks (in fact doing so without the bot knowing would cause other failures!).

So, they can be simply named with their numeric ID instead, a fix that I've verified works. Pushing it soon.