Contraversum / ContraBot

Discord Bot for Contraversum
1 stars 0 forks source link

sendTestButton function prevents the bot from starting #61

Closed q-Sci closed 1 year ago

q-Sci commented 1 year ago
/home/qsci/Projects/ContraBot/commands/test/test-command.ts:111
    (guild.channels.cache.get("1119231777391788062") as TextChannel).send({ components: [actionRow] }); // Channel Id for #How-to-basics
                                                                    ^
TypeError: Cannot read properties of undefined (reading 'send')
    at sendTestButton (/home/qsci/Projects/ContraBot/commands/test/test-command.ts:111:69)
    at Client.<anonymous> (/home/qsci/Projects/ContraBot/index.ts:17:19)
    at Client.emit (node:events:526:35)
    at Client.emit (node:domain:488:12)
    at WebSocketManager.triggerClientReady (/home/qsci/Projects/ContraBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:388:17)
    at WebSocketManager.checkShardsReady (/home/qsci/Projects/ContraBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:371:10)
    at WebSocketShard.<anonymous> (/home/qsci/Projects/ContraBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:201:16)
    at WebSocketShard.emit (node:events:514:28)
    at WebSocketShard.emit (node:domain:488:12)
    at WebSocketShard.checkReady (/home/qsci/Projects/ContraBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:181:12)

The issue only applies for the test server, because the text channel does not exist there.

q-Sci commented 1 year ago

Workaround is to comment the stuff out.

johan-t commented 1 year ago

You just have to change the id to fit the channel of the test server right?

johan-t commented 1 year ago

Alternatively you could change this to use .env variables but this would include changing the .env file of the production bot which I am unsure how to handle but maybe @GregTCLTK knows more about this

q-Sci commented 1 year ago

You just have to change the id to fit the channel of the test server right?

Maybe

johan-t commented 1 year ago

@q-Sci I think the easiest solution is to just add a comment for test channel id and production channel id so that we can easily change it when testing and deploying etc.

greg6775 commented 1 year ago

@q-Sci I think the easiest solution is to just add a comment for test channel id and production channel id so that we can easily change it when testing and deploying etc.

usually you don't even have to use the prod env on your local machine. i don't really get the point in running the bot with prod config on local as it would cause conflicts with the already running prod bot lol

q-Sci commented 1 year ago

@q-Sci I think the easiest solution is to just add a comment for test channel id and production channel id so that we can easily change it when testing and deploying etc.

usually you don't even have to use the prod env on your local machine. i don't really get the point in running the bot with prod config on local as it would cause conflicts with the already running prod bot lol

The channel id responsible for the error is hard-coded and not declared in the env.