Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Questions #1

Closed
zBlbz opened this issue Aug 10, 2019 · 23 comments
Closed

Questions #1

zBlbz opened this issue Aug 10, 2019 · 23 comments
Labels
good first issue Good for newcomers question Further information is requested

Comments

@zBlbz
Copy link

zBlbz commented Aug 10, 2019

Hi, is there a place where I can dm you? I have some question regarding the bot.

@MizaGBF
Copy link
Owner

MizaGBF commented Aug 29, 2019

I'm so sorry, I only noticed your question just now.
If you have a technical question, here is fine (I'll try to pay more attention the next time I pass by).
If it's about an invite link for the bot, it's a no. I only share it to a limited amount of servers.

@MizaGBF MizaGBF added the question Further information is requested label Aug 29, 2019
@zBlbz
Copy link
Author

zBlbz commented Aug 31, 2019

I'm having some trouble setting it up on my own server.
Heroku:
image

Example folder/ config.json
image

Example folder/ settings.yaml (do I use google client ID and secret? or discord?)
image

Example folder/ credentials.json
image
Download JSON > rename it to credentials.json > place it on example folder?

Example folder/ save.json
Did not touch it as I have no idea what I should be adding on save.json.

I did pip install -r requirements.txt on my pc and heroku > run console.

Do I drag everything in the example folder to the root folder?

@MizaGBF
Copy link
Owner

MizaGBF commented Sep 9, 2019

sorry for the late reply again.
the problem is in your config file, line 3.
put your discord key between quotes.

"tokens" : {
    "discord" : "...discord token...",
    "drive" : "....drive key..."
},

EDIT: same for your google drive key, by the way

@MizaGBF
Copy link
Owner

MizaGBF commented Sep 9, 2019

To add more to that: a loadConfig() error in heroku is usually caused by a malformed config.json (quote, bracket or comma missing)

@zBlbz
Copy link
Author

zBlbz commented Sep 10, 2019

image

Now there's a different error after adding quotes to the discord and drive tokens. I guess its my google drive token issue as i'm unsure where to find/ create it.

@zBlbz
Copy link
Author

zBlbz commented Sep 10, 2019

image

I got my drive token from OAuth 2.0 Playground

@MizaGBF
Copy link
Owner

MizaGBF commented Sep 14, 2019

I'm not sure, to be honest.
I haven't used this system to get my google token.
Did you generate your credentials.json first?

I ran something like:

from pydrive.auth import GoogleAuth

gauth = GoogleAuth()
gauth.LocalWebserverAuth()
gauth.SaveCredentialsFile("credentials.json")

locally to get it. It will let you authentificate in a web browser, once.

If you did, I think that the problem is somewhere else.

@zBlbz
Copy link
Author

zBlbz commented Sep 14, 2019

Heroku:
image

googleapis link from heroku:
image

console.developers.google:
image

After generating credentials.json from the python file, console.developers.google finally manage to receive something but there's still some error.

@MizaGBF
Copy link
Owner

MizaGBF commented Sep 17, 2019

Did you put the example save.json file in the folder? The bot doesn't generate one the first time.
I'm not sure what's the problem, otherwise.

@zBlbz
Copy link
Author

zBlbz commented Sep 17, 2019

image
Yes, save.json is in the folder. Am I suppose to edit the save.json for it to work?

@MizaGBF
Copy link
Owner

MizaGBF commented Sep 20, 2019

I mean, in the google drive folder where the bot will save.
It seems to fail at retrieving the save from the drive.

And no you don't have to edit it, I believe it should work fine.

@zBlbz
Copy link
Author

zBlbz commented Sep 21, 2019

After placing the save.json to my google drive, the problem still persists.
I tried using the sample code from pydrive and it's able to return the save.json id.

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

gauth = GoogleAuth()
gauth.LocalWebserverAuth() # Creates local webserver and auto handles authentication.

drive = GoogleDrive(gauth)

# Auto-iterate through all files that matches this query
file_list = drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList()
for file1 in file_list:
  print('title: %s, id: %s' % (file1['title'], file1['id']))

image

@MizaGBF
Copy link
Owner

MizaGBF commented Sep 25, 2019

Check this:
My google application uses these scopes: ../auth/drive.appdata and ../auth/drive.file
I see this at https://console.developers.google.com/apis/credentials > OAuth consent screen

@zBlbz
Copy link
Author

zBlbz commented Sep 26, 2019

Ok I have added the 2 scope you mention, still having the same error.

Here's all my settings related to google, not sure where did I do wrong.

Google Drive API:
image
image

OAuth 2.0 Client web application:
image

OAuth consent screen:
image

Config and settings:
image

@MizaGBF
Copy link
Owner

MizaGBF commented Sep 28, 2019

It took me a while to check (Google UI is terrible to navigate in).
I'm lacking the Drive UI Integration tab (on the first screenshot) but everything else looks the same.
I think your problem is with config.json > tokens > drive, the name is misleading (I'm sorry) but you are supposed to put the drive folder id here, not your access token (the token is already read from the credentials file).
Go to the drive folder in your browser. The url should be something like https://drive.google.com/drive/folders/<id>. This id is what you are supposed to put in config.json.

@zBlbz
Copy link
Author

zBlbz commented Sep 28, 2019

Alright now it able get the save.json file but with a different error.

image

As for the config.json, will it cause any problem if I were to put 0 for the "ids" since I do not have most of the channel.

@MizaGBF
Copy link
Owner

MizaGBF commented Oct 3, 2019

0 should work. Some commands might crash or do nothing as a result. Some tasks might cause problems, I might try to update them.
As for the save error, check at the specified line.

@zBlbz
Copy link
Author

zBlbz commented Oct 3, 2019

Alright I think its working now.

Discord:
image
image

Heroku:
image

How do I unblock the bot?

@MizaGBF
Copy link
Owner

MizaGBF commented Oct 14, 2019

EDIT 3: For the cog error, you can remove the corresponding cog at the end of the bot.py file (the bot.loadCog line). You can also consider removing the RPG cog, it's unfinished and won't be for a long time.
EDIT 2: Should be fixed in v5.29.
EDIT 1: Nevermind, the help doesn't work because it tries to react with a custom emote and fails to. I'll fix this bug.

For the help issue, one of your discord setting is preventing it to dm you (check in setting > privacy or something similar). I don't know if adding the bot as a friend would work.

For the other errors, try the latest version, I added some extra checks to avoid them. If you know python, it might be better to edit out some things yourself.
The react error will go away if you to add your own emote ids in config.json.

@zBlbz
Copy link
Author

zBlbz commented Oct 17, 2019

Thanks the $help is working now but there's still some error.

image
image

Where do I get refresh_token/ access_type to offline? The error happen after > 11hrs online.

@MizaGBF
Copy link
Owner

MizaGBF commented Oct 21, 2019

I believe that your credentials.json file is the problem, it hasn't be generated properly and end up expiring after a certain amount of time.
Make a folder somewhere on your computer with:

  • client_secrets.json from the google drive api credentials page.
  • a copy of your settings.yaml file.
  • a new file (name it whatever.py) and put inside:
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive   
gauth = GoogleAuth()
gauth.LocalWebserverAuth()
gauth.LoadCredentialsFile(gauth)

(if you didn't install pydrive, run a pip install pydrive in a prompt, before).
Run this python file, your internet browser should open to authorize the app.
Once it's done, a new credentials.json file should be in the folder. Use that one.

If it doesn't work, I have no ideas why.

@zBlbz
Copy link
Author

zBlbz commented Oct 26, 2019

Thanks its able to run 24/7 now!
For the save.json:
Do I have to manually update in the "schedule"?

@MizaGBF
Copy link
Owner

MizaGBF commented Oct 31, 2019

Yes the $schedule command is manually updated with $setschedule, I don't have a way to automate it.
I'm closing the issue, since everything is resolved. Should be a nice "help" if someone stumbles upon it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants