Sheepolution / robot-trip

A bot for posting NOS Liveblog posts in Discord.
MIT License
0 stars 0 forks source link

DiscordAPIError: Missing Access #1

Open Bas-Korver opened 2 years ago

Bas-Korver commented 2 years ago

When running the bot in wsl ubuntu I get the error DiscordAPIError: Missing Access, I gave the bot administrator permission and the application.commands scope.

Start-up and error message:

[INFO] 12:06:05 ts-node-dev ver. 1.1.8 (using ts-node ver. 9.1.1, typescript ver. 4.5.5)
Robot Trip: Connected
DiscordAPIError: Missing Access
    at RequestHandler.execute (/home/bas/test/robot-trip/code/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at RequestHandler.push (/home/bas/test/robot-trip/code/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
    at Message.crosspost (/home/bas/test/robot-trip/code/node_modules/discord.js/src/structures/Message.js:487:5)
[ERROR] 12:10:15 DiscordAPIError: Missing Access

package-lock.txt

Sheepolution commented 2 years ago

Did you fill out a correct .venv file?

Bas-Korver commented 2 years ago

I tried 3 different .env configurations:

TOKEN='OTQ2MzE5OTgxMDMxODY2Mzg4.Yhc_KQ.Q-GkCMqFzcMV6gaLLHhBZKWyKXY'
CHANNEL_NEWS_ID=946321733428858892
CHANNEL_BINNENLAND_ID=946322028640759818
CHANNEL_BUITENLAND_ID=946322045711568997
TOKEN='OTQ2MzE5OTgxMDMxODY2Mzg4.Yhc_KQ.Q-GkCMqFzcMV6gaLLHhBZKWyKXY'
CHANNEL_NEWS_ID=946321733428858892

and

TOKEN=OTQ2MzE5OTgxMDMxODY2Mzg4.Yhc_KQ.Q-GkCMqFzcMV6gaLLHhBZKWyKXY
CHANNEL_NEWS_ID=946321733428858892
CHANNEL_BINNENLAND_ID=946322028640759818
CHANNEL_BUITENLAND_ID=946322045711568997
CHANNEL_SPORTS_ID=946322045711568997
CHANNEL_REGIONAAL_ID=946322045711568997
CHANNEL_POLITIEK_ID=946322045711568997
CHANNEL_ECONOMIE_ID=946322045711568997
CHANNEL_KONINGSHUIS_ID=946322045711568997
CHANNEL_TECH_ID=946322045711568997
CHANNEL_CULTUUR_ID=946322045711568997
CHANNEL_OPMERKELIJK_ID=946322045711568997

All of them result in the same error. (The 'TOKEN' in the examples above are just placeholders, in the real .env I have the correct token)

Sheepolution commented 2 years ago

It's probably the elections channel. Let me know if 87a8d0ecb18c5b2b98130082fd07b11393572d4b fixed it.

Edit: 808f994708139ab19465452c604c257711ca4cd4 should fix it (forgot to commit a file)

Bas-Korver commented 2 years ago

Unfortunately, that didn't fix my problem, but I think I found what the problem is. in BotManager.ts message.crosspost() is used which publishes a message in an announcement channel to all channels following it. But that means that the channel to which the bot is configured to send messages has to be a news channel.

I tried making that command conditional with an if statement like is example, but because typeguards are used, that if statement creates an error that says: the if statement wouldn't work because it will always be a "TextChannel". But when I print the .type of that channel it returns "news" when it is a news channel even though a "TextChannel" typeguard is used.