FuseFairy / DiscordBot-EdgeGPT

Using Copilot, Bing Image Creator and DALLE-3 on Discord bot.
GNU General Public License v2.0
160 stars 41 forks source link

Big problem #23

Closed VIDRA4444 closed 1 year ago

VIDRA4444 commented 1 year ago

Hello! I have this trace when I start up, but everything is installed according to the instructions. What can it be? ==== RESTART: C:\Users\1111\Desktop\DiscordBot-EdgeGPT-main\bot.py ==== Traceback (most recent call last): File "C:\Users\1111\Desktop\DiscordBot-EdgeGPT-main\bot.py", line 1, in import discord ModuleNotFoundError: No module named 'discord'

VIDRA4444 commented 1 year ago

Okay, I figured it out and installed the discord.py library, now the error is different: [30;1m2023-03-23 01:55:54[0m [31mERROR [0m [35mmain[0m -> discord.py version 2.2.2 is installed but does not match the requirements

tankow79 commented 1 year ago

Hi there was an error during startup:

discord.client logging in using static token Traceback (most recent call last): File "D:\Programs_for_python\DiscordBot-EdgeGPT-main\venv\lib\site-packages\discord\client.py", line 828, in run asyncio.run(runner()) File "D:\Users\AndraX\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "D:\Users\AndraX\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "D:\Programs_for_python\DiscordBot-EdgeGPT-main\venv\lib\site-packages\discord\client.py", line 817, in runner await self.start(token, reconnect=reconnect) File "D:\Programs_for_python\DiscordBot-EdgeGPT-main\venv\lib\site-packages\discord\client.py", line 746, in start await self.connect(reconnect=reconnect) File "D:\Programs_for_python\DiscordBot-EdgeGPT-main\venv\lib\site-packages\discord\client.py", line 672, in connect raise PrivilegedIntentsRequired(exc.shard_id) from None discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead. python-BaseException

I tried switching the dependency as mentioned in "discord.errors.PrivilegedIntentsRequired" but it doesn't work for me

tankow79 commented 1 year ago

@VIDRA4444 You need to install the version of the library specified in requirements.txt "pip install -r requirements.txt"

In your case, you need to remove the discord.py version 2.2.2 library "pip uninstall discord.py" and then install discord.py version 2.1.0 "pip install discord.py==2.1.0"

FuseFairy commented 1 year ago

Hi there was an error during startup:

discord.client logging in using static token Traceback (most recent call last): File "D:\Programs_for_python\DiscordBot-EdgeGPT-main\venv\lib\site-packages\discord\client.py", line 828, in run asyncio.run(runner()) File "D:\Users\AndraX\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "D:\Users\AndraX\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "D:\Programs_for_python\DiscordBot-EdgeGPT-main\venv\lib\site-packages\discord\client.py", line 817, in runner await self.start(token, reconnect=reconnect) File "D:\Programs_for_python\DiscordBot-EdgeGPT-main\venv\lib\site-packages\discord\client.py", line 746, in start await self.connect(reconnect=reconnect) File "D:\Programs_for_python\DiscordBot-EdgeGPT-main\venv\lib\site-packages\discord\client.py", line 672, in connect raise PrivilegedIntentsRequired(exc.shard_id) from None discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead. python-BaseException

I tried switching the dependency as mentioned in "discord.errors.PrivilegedIntentsRequired" but it doesn't work for me

https://github.com/FuseFairy/DiscordBot-EdgeGPT/issues/19#issuecomment-1475361611

Here is the solution.

VIDRA4444 commented 1 year ago

@VIDRA4444 You need to install the version of the library specified in requirements.txt "pip install -r requirements.txt"

In your case, you need to remove the discord.py version 2.2.2 library "pip uninstall discord.py" and then install discord.py version 2.1.0 "pip install discord.py==2.1.0"

Having done as you said, I got this error: [30;1m2023-03-23 13:39:27[0m [31mERROR [0m [35mmain[0m -> python-dotenv version 1.0.0 is installed but does not match the requiremen

VIDRA4444 commented 1 year ago

Oh my God, I'm already tired... I installed the correct version of dotenv, but a new error popped up...
File "C:\Users\1111\Desktop\bot\DiscordBot-EdgeGPT-main\bot.py", line 9, in load_dotenv() TypeError: load_dotenv() missing 1 required positional argument: 'dotenv_path'

FuseFairy commented 1 year ago

Do you change file name .env.dev to .env?

VIDRA4444 commented 1 year ago

image

VIDRA4444 commented 1 year ago

yes. file is .env

FuseFairy commented 1 year ago

I update repo, you can try again.

VIDRA4444 commented 1 year ago

I update repo, you can try again.

Do I need to reinstall the zip?

FuseFairy commented 1 year ago

Yes, and reinstall the package

VIDRA4444 commented 1 year ago

Aaaaand...... image

VIDRA4444 commented 1 year ago

;(

FuseFairy commented 1 year ago

well,I guess you should change load_dotenv() to load_dotenv(dotenv_path= inputyour.env_path)

VIDRA4444 commented 1 year ago

Like this? image

VIDRA4444 commented 1 year ago

I'm sorry if I'm dumb. I don't understand much about code.

FuseFairy commented 1 year ago

Like this? image

dotenv_path = "./.env"

VIDRA4444 commented 1 year ago

Warning (from warnings module): File "C:\Users\1111\AppData\Local\Programs\Python\Python310\lib\site-packages\dotenv.py", line 18 warnings.warn("can't read %s - it doesn't exist." % dotenv_path) UserWarning: can't read C:Users\1111\AppData\Local\Programs\Python\Python310\Lib\site-packages\dotenv.env - it doesn't exist. 2023-03-23 15:19:05 ERROR  main -> discord.py version 2.1.0 is installed but does not match the requirements

VIDRA4444 commented 1 year ago

image I put this in, can you please tell me what I need to change?

FuseFairy commented 1 year ago

Warning (from warnings module): File "C:\Users\1111\AppData\Local\Programs\Python\Python310\lib\site-packages\dotenv.py", line 18 warnings.warn("can't read %s - it doesn't exist." % dotenv_path) UserWarning: can't read C:Users\1111\AppData\Local\Programs\Python\Python310\Lib\site-packages\dotenv.env - it doesn't exist. �[30;1m2023-03-23 15:19:05�[0m �[31mERROR �[0m �[35mmain�[0m -> discord.py version 2.1.0 is installed but does not match the requirements

I updated the version of discord.py to 2.2.2 and you can see the change in requirements.txt.

FuseFairy commented 1 year ago

image I put this in, can you please tell me what I need to change?

you can trydotenv_path = "./.env"or dotenv_path=r"your_path"

VIDRA4444 commented 1 year ago

okay! 2023-03-23 15:28:40 ERROR  main -> python-dotenv version 0.2.0 is installed but does not match the requirements

FuseFairy commented 1 year ago

Okay, I know what I should fix

FuseFairy commented 1 year ago

Modify your bot.py code to look like this

import discord
import os
import src.log
from discord.ext import commands
from dotenv import load_dotenv

load_dotenv(dotenv_path="./.env")

bot = commands.Bot(command_prefix='!', intents = discord.Intents.all())

# init loggger
logger = src.log.setup_logger(__name__)

@bot.event
async def on_ready():
    logger.info(f'{bot.user} is now running!')
    for Filename in os.listdir('./cogs'):
        if Filename.endswith('.py'):
            await bot.load_extension(f'cogs.{Filename[:-3]}')  
    print("Bot is Up and Ready!")
    try:
        synced = await bot.tree.sync()
        print(f"Synced {len(synced)} commands")
    except Exception as e:
        print(e)

@bot.command()
async def load(ctx, extension):
    await bot.load_extension(f'cogs.{extension}')
    await ctx.send(f'Loaded {extension} done.')

@bot.command()
async def unload(ctx, extension):
    await bot.unload_extension(f'cogs.{extension}')
    await ctx.send(f'Un-Loaded {extension} done.')

@bot.command()
async def reload(ctx, extension):
    await bot.reload_extension(f'cogs.{extension}')
    await ctx.send(f'Re-Loaded {extension} done.')

@bot.command()
async def clean(ctx):
    open('discord_bot.log', 'w').close()
    await ctx.send(f'Has been emptied')

if __name__ == '__main__':
    bot.run(os.getenv("DISCORD_BOT_TOKEN"))
VIDRA4444 commented 1 year ago

hm... image

FuseFairy commented 1 year ago

Can I see your bot.py?

VIDRA4444 commented 1 year ago

image

FuseFairy commented 1 year ago

hm..so strange, open .env file, and try to change DISCORD_BOT_TOKEN=your_token toDISCORD_BOT_TOKEN="your_token"

VIDRA4444 commented 1 year ago

image

VIDRA4444 commented 1 year ago

image damn! the bot is working, although previously it was not even online

FuseFairy commented 1 year ago

: )

VIDRA4444 commented 1 year ago

but........ image

VIDRA4444 commented 1 year ago

no response

VIDRA4444 commented 1 year ago

image

VIDRA4444 commented 1 year ago

he's online, but there are a lot of errors and he doesn't respond to any commands

FuseFairy commented 1 year ago

image

Are you sure you have the edgegpt package installed?

VIDRA4444 commented 1 year ago

yes

FuseFairy commented 1 year ago

I think your edgegpt package path is wrong

VIDRA4444 commented 1 year ago

Okay and... what should I do?

FuseFairy commented 1 year ago

confirm your edgegpt package info, like this:

(py_3-9-16) C:\Users\dd861\pyhon\discord bot EdgeGPT>pip show EdgeGPT
Name: EdgeGPT
Version: 0.1.3
Summary: Reverse engineered Edge Chat API
Home-page: https://github.com/acheong08/EdgeGPT
Author: Antonio Cheong
Author-email: acheong@student.dalat.org
License: GNU General Public License v2.0
Location: c:\users\dd861\anaconda3\envs\py_3-9-16\lib\site-packages
Requires: asyncio, certifi, httpx, prompt-toolkit, regex, requests, rich, websockets
Required-by:
VIDRA4444 commented 1 year ago

image

FuseFairy commented 1 year ago

This seems to be no problem, hm...

VIDRA4444 commented 1 year ago

image Here are the current startup errors

FuseFairy commented 1 year ago

Mybe you can reinstall all package, and try again

VIDRA4444 commented 1 year ago

All packages??? Python, dotenv, edge?

VIDRA4444 commented 1 year ago

okay! �[30;1m2023-03-23 15:28:40�[0m �[31mERROR �[0m �[35mmain�[0m -> python-dotenv version 0.2.0 is installed but does not match the requirements

Are you sure the error is not in the code? Last time I had an error only with dotenv, but now the whole screen is red

FuseFairy commented 1 year ago

Then try to install python-dotenv latest version first

FuseFairy commented 1 year ago

https://github.com/yaml/pyyaml/issues/574

you should try this

FuseFairy commented 1 year ago

I think this is a problem with py3.10, because I don't have this error with py3.9.