Closed arcanius closed 2 years ago
The application does not accept string values either.
Can you try using the TOKEN environment variable and let me know what happens?
I'm not really using a VPS; rather trying to self-host it on a personal computer, so can't say for sure. Though I can post the rest of the log if that might help.
SyntaxError: F:\Bot\SR1eGameBot-master\discordauth.json: Unexpected token O in JSON at position 0
at parse (<anonymous>)
at Object.Module._extensions..json (node:internal/modules/cjs/loader:1167:22)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (F:\Bot\SR1eGameBot-master\main.js:1064:14)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
Follow-up question: is there a syntax the token must be formatted in, in the "DiscordAuth" file? It appears to only accept constant values for the token, and authentication tokens are comprising of both numerals and alphabets. Apologies if I'm consistently misunderstanding some minor issue on my side; I'm not very well-versed with JavaScript.
the discordauth.json file requires the following format:
{
"token": "your auth token string from the New Application button at http://discordapp.com/developers/applications/me"
}
Sorry, omit the comma (editing my prior message to remove it)
That does seem to solve the previous error, thank you.
However, there appear to be a minor problem here. The bot wouldn't start any automated(?) procedures to create Google Drive-related files, I think.
Error loading client secret file: [Error: ENOENT: no such file or directory, open 'F:\Bot\SR1eGameBot-master\googlecredentials.json'] {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'F:\\Bot\\SR1eGameBot-master\\googlecredentials.json'
}
{"message":"Connected; Logged in as: [(my-bot-account)#(hash)]","level":"info"}
The rest of the things work correctly on the client side as far as I can tell, with the minor exception that after a successful result, the bot stops responding to any successive commands and remains as such until "node ." is run again through the command prompt. The command prompt stays though; it doesn't force shut or crash. The bot has all the regular permissions, including Attach Files, Embed Links, Add Emojis, Use External Emotes, and all that; it appears to be something to do with the application interacting with the API. The log with regards to that is provided below.
🎲
F:\Bot\SR1eGameBot-master\SR1eGameBot-master\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85
new DiscordAPIError(res.request.path, res.body, res.request.method) : err);
^
DiscordAPIError: Missing Permissions
at F:\Bot\SR1eGameBot-master\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15
at F:\Bot\SR1eGameBot-master\node_modules\snekfetch\src\index.js:215:21
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
path: '/api/v7/channels/(some-number)/messages/(number)/reactions/%F0%9F%8E%B2/@me',
code: 50013,
method: 'PUT'
}
I also performed a clean re-extract of the recently-updated code files from this repository, and this issue still seems to persist.
My self-hosting directions seem to be sparse about instructing you on how to go through the process of setting up GDrive permissions.
Do you have googlecredentials.json and googletoken.json, in the same directory as main.js? Are they populated? Did the app prompt you to do the Google Drive login stuff the first time you ran it?
On Wed, Nov 24, 2021 at 11:40 AM arcanius @.***> wrote:
That does seem to solve the previous error, thank you.
However, there appear to be a minor problem here. The bot wouldn't start any automated(?) procedures to create Google Drive-related files, I think.
Error loading client secret file: [Error: ENOENT: no such file or directory, open 'F:\Bot\SR1eGameBot-master\googlecredentials.json'] {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'F:\Bot\SR1eGameBot-master\googlecredentials.json'
}
{"message":"Connected; Logged in as: [(my-bot-account)#(hash)]","level":"info"}
The rest of the things work correctly on the client side as far as I can tell, with the minor exception that after a successful result, the bot stops responding to any successive commands and remains as such until "node ." is run again through the command prompt. The command prompt stays though; it doesn't force shut or crash. The bot has all the regular permissions, including Attach Files, Embed Links, Add Emojis, Use External Emotes, and all that; it appears to be something to do with the application interacting with the API. The log with regards to that is provided below.
🎲
F:\Bot\SR1eGameBot-master\SR1eGameBot-master\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85
new DiscordAPIError(res.request.path, res.body, res.request.method) : err); ^
DiscordAPIError: Missing Permissions
at F:\Bot\SR1eGameBot-master\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15 at F:\Bot\SR1eGameBot-master\node_modules\snekfetch\src\index.js:215:21 at processTicksAndRejections (node:internal/process/task_queues:96:5) {
path: @.***',
code: 50013,
method: 'PUT'
}
I also performed a clean re-extract of the recently-updated code files from this repository, and this issue still seems to persist.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NathanHawks/SR1eGameBot/issues/10#issuecomment-978045176, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOP6MH6JUMZMJFLNYG2TYLUNUIOVANCNFSM5IWA54HA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Also it's possible you'll need to use the old version of discord.js that is specified in the project, 11.5.1.
On Wed, Nov 24, 2021 at 12:05 PM Nathan Hawks @.***> wrote:
My self-hosting directions seem to be sparse about instructing you on how to go through the process of setting up GDrive permissions.
Do you have googlecredentials.json and googletoken.json, in the same directory as main.js? Are they populated? Did the app prompt you to do the Google Drive login stuff the first time you ran it?
On Wed, Nov 24, 2021 at 11:40 AM arcanius @.***> wrote:
That does seem to solve the previous error, thank you.
However, there appear to be a minor problem here. The bot wouldn't start any automated(?) procedures to create Google Drive-related files, I think.
Error loading client secret file: [Error: ENOENT: no such file or directory, open 'F:\Bot\SR1eGameBot-master\googlecredentials.json'] {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'F:\Bot\SR1eGameBot-master\googlecredentials.json'
}
{"message":"Connected; Logged in as: [(my-bot-account)#(hash)]","level":"info"}
The rest of the things work correctly on the client side as far as I can tell, with the minor exception that after a successful result, the bot stops responding to any successive commands and remains as such until "node ." is run again through the command prompt. The command prompt stays though; it doesn't force shut or crash. The bot has all the regular permissions, including Attach Files, Embed Links, Add Emojis, Use External Emotes, and all that; it appears to be something to do with the application interacting with the API. The log with regards to that is provided below.
🎲
F:\Bot\SR1eGameBot-master\SR1eGameBot-master\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85
new DiscordAPIError(res.request.path, res.body, res.request.method) : err); ^
DiscordAPIError: Missing Permissions
at F:\Bot\SR1eGameBot-master\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15 at F:\Bot\SR1eGameBot-master\node_modules\snekfetch\src\index.js:215:21 at processTicksAndRejections (node:internal/process/task_queues:96:5) {
path: @.***',
code: 50013,
method: 'PUT'
}
I also performed a clean re-extract of the recently-updated code files from this repository, and this issue still seems to persist.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NathanHawks/SR1eGameBot/issues/10#issuecomment-978045176, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOP6MH6JUMZMJFLNYG2TYLUNUIOVANCNFSM5IWA54HA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
There was no prompt relating to a Google Drive log-in the first time the application was run, no. There is no googlecredentials.json or googletoken.json in the main directory either. I am using discord.js v11.5.1.
OK. Forgive me for the fact that I haven't done the installation process in 2 years.
Try node googletest-pre-merge.js
and see what it does.
It's possible (I really don't remember) that you may have to go here and click "Create Project" to turn on your access to Drive API:
https://console.cloud.google.com/projectselector2/apis/dashboard?pli=1&supportedpurview=project
On Wed, Nov 24, 2021 at 12:57 PM arcanius @.***> wrote:
There was no prompt relating to a Google Drive log-in the first time the application was run, no. There are no googlecredentials.json or googletoken.json in the main directory either. I am using discord.js v11.5.1.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NathanHawks/SR1eGameBot/issues/10#issuecomment-978104467, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOP6MBANDZCMOYDUXHQLZTUNURRPANCNFSM5IWA54HA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Hm, nope, that doesn't work either. Running node googletest-pre-merge.js
brings up one of the same errors posted in the prior messages.
Error loading client secret file: [Error: ENOENT: no such file or directory, open 'F:\Bot\SR1eGameBot-master\googlecredentials.json'] {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'F:\\Bot\\SR1eGameBot-master\\googlecredentials.json'
I'm not really sure since I haven't worked with this Google Drive stuff before, but can you manually create the googlecredentials.json or googletoken.json files? The script is looking for the .json files but they aren't present there. None of the scripts in the main directory attempt to create said files either.
If you saw the instructions I just sent... That was the wrong API page... hang on
On Fri, Nov 26, 2021 at 7:50 AM Nathan Hawks @.***> wrote:
"It should be working" (said every programmer ever) but I have confirmed it is not.
Try this.
Save the index.js script from step 2 of this page: https://developers.google.com/calendar/api/quickstart/nodejs
Run node index.js
See if that sets up your google stuff.
On Wed, Nov 24, 2021 at 11:48 PM arcanius @.***> wrote:
Hm, nope, that doesn't work either. Running node googletest-pre-merge.js brings up one of the same errors posted in the prior messages.
Error loading client secret file: [Error: ENOENT: no such file or directory, open 'F:\Bot\SR1eGameBot-master\googlecredentials.json'] { errno: -4058, code: 'ENOENT', syscall: 'open', path: 'F:\Bot\SR1eGameBot-master\googlecredentials.json'
I'm not really sure since I haven't worked with this Google Drive stuff before, but can you manually create the googlecredentials.json or googletoken.json files? The script is looking for the .json files but they aren't present there. None of the scripts in the main directory attempt to create the said files either.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NathanHawks/SR1eGameBot/issues/10#issuecomment-978832780, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOP6MFBPKK4DQW4AAE5KQLUNW5Y7ANCNFSM5IWA54HA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
"It should be working" (said every programmer ever) but I have confirmed it is not.
Try this:
Step 1:
Save the index.js
script from step 2 of this page, into the same folder as main.js
from the dicebot files:
https://developers.google.com/drive/api/v3/quickstart/nodejs
Step 2: Change that file so that the SCOPES line near the top says:
const SCOPES = ['https://www.googleapis.com/auth/drive.appdata',
'https://www.googleapis.com/auth/drive.file'];
Step 3:
Run the script using node index.js
Reading through the code for index.js, pretty sure these seemed to be the lines to start the authorization process however; running the script through the node after following these instructions seems to bring up the same errorno.: -4058; code: "ENOENT" (as posted earlier) yet again. Executing the script is trying to find a "credentials.json" which isn't present there, hence returning the error. If the file is created though completely unpopulated, the script fails yet again. Kinda hilarious, everything else is correct though based on your directions.
Try following the Prerequisite steps on that page ... I don't remember needing to do it but I do have Gamebot (and other projects) listed under its Projects drop-down.
On Fri, Nov 26, 2021 at 12:50 PM arcanius @.***> wrote:
Reading through the code for index.js, pretty sure these seemed to be the lines to start the authorization process however; running the script through the node after following these instructions seems to bring up the same errorno.: -4058; code: "ENOENT" (as posted earlier) yet again. Executing the script is trying to find a "credentials.json" which isn't present there, hence returning the error. If the file is created though completely unpopulated, the script fails yet again. Kinda hilarious, everything else is correct though based on your directions.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NathanHawks/SR1eGameBot/issues/10#issuecomment-980221815, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOP6MABK7DRXTLYB22CP3DUN7CGFANCNFSM5IWA54HA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Following the instructions in the node.js guide finally fixes up the token issues. The file "credentials.json" is exported from the Google Workspace after creating said credentials for a new project (-- I chose "External" and "Desktop Application"), which is then placed in the main directory for Dicebot. Running the index.js file with the modified SCOPES on the sixth line, through the command prompt, then proceeds through the necessary automated steps, as a result creating a "token.json" file. To use these files with your bot, one must rename the "credentials" and "token" files to "googlecredentials" and "googletoken" respectively, and then use node .
in the command prompt.
Using the bot might run into another issue that would crash the script on the console side due to a "Missing Permissions" error; this can be easily corrected by giving the bot more permissions on the server side, or using the default Bot Permissions form on the Bot page in the Discord Developer Portal. No other issues seem to come up at the time of the start-up.
((Thanks for the assistance. I intended to use your bot with running a virtual mini-campaign on Discord with handmade battle mechanics. It's kind of an inside joke in our server to have bots with names and avatars after characters or tropes present in our role-playing world, so I preferred to self-host your code than deploy the official instance of said bot to the server. I'm not really well-versed with javascript, and this google api stuff was new, so this thread was very helpful!))
Glad to hear it! Thanks for your patience and assistance working out the bug in my instructions!
On Sat, Nov 27, 2021 at 12:38 AM arcanius @.***> wrote:
((Thanks for the assistance. I intended to use your bot with running a virtual mini-campaign on Discord with handmade battle mechanics. It's kind of an inside joke in our server to have bots with names and avatars after characters or tropes present in our role-playing world, so I preferred to self-host your code than deploy the official instance of said bot to the server. I'm not really well-versed with javascript so this thread was very helpful!))
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NathanHawks/SR1eGameBot/issues/10#issuecomment-980506912, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOP6MACWOSVSTS25TLYXZTUOBVFDANCNFSM5IWA54HA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Pretty sure the documentation states that the authentication token must be stored in a discordauth.json file. However after creating the file, running node . in the main directory yields an error;
F:\Bot\SR1eGameBot-master\discordauth.json: Unexpected token O in JSON at position 0
All requirements are installed and in working state.