MizaGBF / MizaBOT

Python 3 Granblue Fantasy-themed Discord Bot
MIT License
25 stars 13 forks source link

Questions #1

Closed zBlbz closed 4 years ago

zBlbz commented 5 years ago

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

MizaGBF commented 4 years ago

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.

zBlbz commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

zBlbz commented 4 years ago

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 commented 4 years ago

image

I got my drive token from OAuth 2.0 Playground

MizaGBF commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

MizaGBF commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Alright I think its working now.

Discord: image image

Heroku: image

How do I unblock the bot?

MizaGBF commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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:

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

zBlbz commented 4 years ago

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

MizaGBF commented 4 years ago

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.