FANTSCRIN
@FANTSCRIN
Учусь кодить

Не компилируется файл бота для discorda из .py в .exe (pyinstaller). Выдает ошибки. С vk и telegram работает нормально. Как исправить?

import cfg
import time
import discord
from discord import utils
from MIRA import MIRA

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as {0}!'.format(self.user))
        await client.change_presence(status=discord.Status.online, activity=discord.Game("fanTTools"))


    async def on_message(self, message):
        if int(message.channel.id) == 797463389965385759:
            if message.author.id != 793221581941243966:
                channel = self.get_channel(message.channel.id)
                data = MIRA().select_command(1, message.content)
                if data != None:
                    await channel.send(f'{data[0]}\n\n{message.author.mention}')
                    MIRA().output_logs('DISCORD', message.author, data[1], data[2])


    async def on_raw_reaction_add(self, payload):
        if payload.message_id == cfg.POST_ID:
            channel = self.get_channel(payload.channel_id) 
            message = await channel.fetch_message(payload.message_id)
            member = await (await client.fetch_guild(payload.guild_id)).fetch_member(payload.user_id)
 
            try:
                emoji = str(payload.emoji)
                role = utils.get(message.guild.roles, id=cfg.ROLES[emoji])
                
                if(len([i for i in member.roles if i.id not in cfg.EXCROLES]) <= cfg.MAX_ROLES_PER_USER):
                    await member.add_roles(role)
                    MIRA().output_logs('DISCORD', member.name, 'get role (' + role.name + ')', 1)
                    if role.id == 793225592572739594:
                        data = MIRA().select_command(1, '/commands')
                        if data != None:
                            channel = self.get_channel(797463389965385759)
                            await channel.send(f'{data[0]}\n\n{member.mention}')
                            MIRA().output_logs('DISCORD', member.display_name, data[1], data[2])
                else:
                    await message.remove_reaction(payload.emoji, member)
                    print('[ERROR] Too many roles for user {0.display_name}'.format(member))
            
            except KeyError as e:
                print('[ERROR] KeyError, no role found for ' + emoji)
            except Exception as e:
                print(repr(e))
 

    async def on_raw_reaction_remove(self, payload):
        channel = self.get_channel(payload.channel_id) 
        message = await channel.fetch_message(payload.message_id)
        member = await (await client.fetch_guild(payload.guild_id)).fetch_member(payload.user_id)
 
        try:
            emoji = str(payload.emoji) 
            role = utils.get(message.guild.roles, id=cfg.ROLES[emoji]) 
 
            await member.remove_roles(role)
            MIRA().output_logs('DISCORD', member.display_name, 'remove role ( ' + role.name + ' )', 1)
 
        except KeyError as e:
            print('[ERROR] KeyError, no role found for ' + emoji)
        except Exception as e:
            print(repr(e))

client = MyClient()
client.run(cfg.DISCORD_TOKEN)

Traceback (most recent call last):
File "", line 41, in
File "", line 13, in walk_packages
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\pkgutil.py", line 130, in iter_modules
for name, ispkg in iter_importer_modules(i, prefix):
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\pkgutil.py", line 149, in _iter_file_finder_modules
import inspect
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\inspect.py", line 35, in
import dis
File "C:\Users\FANTSCRIN\Documents\PythonProjects\MIRA\dis\dis.py", line 3, in
import discord
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\discord\__init__.py", line 25, in
from .client import Client
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\discord\client.py", line 33, in
import aiohttp
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\aiohttp\__init__.py", line 6, in
from .client import BaseConnector as BaseConnector
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\aiohttp\client.py", line 32, in
from . import hdrs, http, payload
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\aiohttp\http.py", line 7, in
from .http_parser import HeadersParser as HeadersParser
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\aiohttp\http_parser.py", line 15, in
from .helpers import NO_EXTENSIONS, BaseTimerContext
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\aiohttp\helpers.py", line 107, in
def noop(*args, **kwargs): # type: ignore
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\asyncio\coroutines.py", line 114, in coroutine
if inspect.iscoroutinefunction(func):
AttributeError: partially initialized module 'inspect' has no attribute 'iscoroutinefunction' (most likely due to a circular import)

Traceback (most recent call last):
File "", line 41, in
File "", line 13, in walk_packages
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\pkgutil.py", line 130, in iter_modules
for name, ispkg in iter_importer_modules(i, prefix):
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\pkgutil.py", line 149, in _iter_file_finder_modules
import inspect
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\inspect.py", line 35, in
import dis
File "C:\Users\FANTSCRIN\Documents\PythonProjects\MIRA\dis\dis.py", line 3, in
import discord
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\discord\__init__.py", line 25, in
from .client import Client
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\discord\client.py", line 33, in
import aiohttp
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\aiohttp\__init__.py", line 6, in
from .client import BaseConnector as BaseConnector
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\aiohttp\client.py", line 32, in
from . import hdrs, http, payload
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\aiohttp\http.py", line 7, in
from .http_parser import HeadersParser as HeadersParser
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\aiohttp\http_parser.py", line 15, in
from .helpers import NO_EXTENSIONS, BaseTimerContext
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\site-packages\aiohttp\helpers.py", line 107, in
def noop(*args, **kwargs): # type: ignore
File "c:\users\fantscrin\appdata\local\programs\python\python38\lib\asyncio\coroutines.py", line 114, in coroutine
if inspect.iscoroutinefunction(func):
AttributeError: partially initialized module 'inspect' has no attribute 'iscoroutinefunction' (most likely due to a circular import)
  • Вопрос задан
  • 153 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
23 нояб. 2024, в 22:03
3000 руб./за проект
23 нояб. 2024, в 21:53
30000 руб./за проект
23 нояб. 2024, в 21:49
1000 руб./в час