#How to fix Unknown Interaction error

1 messages · Page 1 of 1 (latest)

pine mango
#

Hello !

I actually got this error that is annoying, it happen on multiple commands of my bot, including the ones with an autocomplete :

Ignoring exception in command translate:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 131, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 1009, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/app/cogs/translate.py", line 64, in translate
    await ctx.defer(ephemeral=ephemeral)
  File "/usr/local/lib/python3.12/site-packages/discord/interactions.py", line 748, in defer
    await self._locked_response(
  File "/usr/local/lib/python3.12/site-packages/discord/interactions.py", line 1243, in _locked_response
    await coro
  File "/usr/local/lib/python3.12/site-packages/discord/webhook/async_.py", line 220, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/discord/bot.py", line 1130, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 376, in invoke
    await injected(ctx)
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 139, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

For the command that made the error, here is the code :

class Translate(Cog):
    def __init__(self, bot):
        self.bot = bot

    #########################
    # autocomplete function #
    #########################

    async def get_languages(ctx: AutocompleteContext):
        filtered_languages = [lang for lang in LANGUAGES if lang.startswith(ctx.value.lower())]
        if len(filtered_languages) > 25:
            return filtered_languages[:25]
        else:
            return filtered_languages


    #############
    # translate #
    #############

    @slash_command(
        name="translate",
        description="Translate a text from a language to another.",
        guild_only=True
    )
    @option(
        name="text",
        description="The text you want to translate.",
        required=True,
        type=str
    )
    @option(
        name="to_language",
        description="The language you want to translate the text into.",
        required=True,
        type=str,
        autocomplete=basic_autocomplete(get_languages)
    )
    @option(
        name="from_language",
        description="The language of your actual text.",
        required=False,
        type=str,
        autocomplete=basic_autocomplete(get_languages)
    )
    @option(
        name="ephemeral",
        description="if you want the answer to be visible only to you. Default is False",
        required=False,
        type=bool
    )
    async def translate(self, ctx : ApplicationContext, text, to_language, from_language = None, ephemeral = False):

        await ctx.defer(ephemeral=ephemeral)

        try :
            if from_language is None :
                traduction = trad.translate(text, dest=to_language)
            else :
                traduction = trad.translate(text, dest=to_language, src=from_language)
        except :
            await ctx.respond("An error occured while translating the text.\nPlease try again.", ephemeral=True)
            return

        await ctx.respond(f"{traduction.text}", ephemeral=ephemeral)


def setup(bot):
    print("Translate Command is ready !")
    bot.add_cog(Translate(bot))
#

maybe upper the problem is the autocomplete with the defer, but I have another command that send the same error sometimes, here is the code :

import discord
from discord import Embed, ApplicationContext
from discord.ext.commands import slash_command, Cog
from datetime import datetime

class StatsCommand(Cog):
    def __init__(self, bot):
        self.bot = bot

    @slash_command(
        name="stats",
        description="Display the stats of the bot.",
        guild_only=True
    )
    async def stats(self, ctx: ApplicationContext):

        await ctx.defer(ephemeral=True)

        uptime = datetime.now() - self.bot.start_time
        days, remainder = divmod(int(uptime.total_seconds()), 86400)
        hours, remainder = divmod(remainder, 3600)
        minutes, seconds = divmod(remainder, 60)

        embed = Embed(
            title="Stats Command",
            description="They are the stats of my bot.",
            color=0x5865F2
        )
        # Footer :
        embed.set_footer(
            icon_url = f"https://cdn.discordapp.com/avatars/341257685901246466/ee4062cd8d5888421a51c2fc9875b9df.png?size=4096",
            text = f"unbonwhisky"
        )
        # Author :
        embed.set_author(
            name = self.bot.user.display_name,
            icon_url= self.bot.user.avatar.url
        )
        # Fields :
        embed.add_field(
            name="Servers",
            value="{:,}".format(len(self.bot.guilds)).replace(',', ' '),
            inline=True
        )
        embed.add_field(
            name="Channels",
            value="{:,}".format(sum(len(guild.channels) for guild in self.bot.guilds)).replace(',', ' '),
            inline=True
        )
        embed.add_field(
            name="Users",
            value="{:,}".format(sum(guild.member_count for guild in self.bot.guilds)).replace(',', ' '),
            inline=True
        )
        embed.add_field(
            name="Actual Server Shard :",
            value=ctx.guild.shard_id,
            inline=True
        )
        embed.add_field(
            name="Uptime :",
            value=f"{days}d {hours}h {minutes}m {seconds}s",
            inline=True
        )
        embed.add_field(
            name="Shards count :",
            value=self.bot.shard_count,
            inline=True
        )

        await ctx.respond(embed=embed, ephemeral=True)

def setup(bot):
    print('Stats Command is ready!')
    bot.add_cog(StatsCommand(bot))
proven quiver
#

Try to defer the command

pine mango
proven quiver
#

Oh yea

#

Nvm

pine mango
#

any idea ?
It happen too for the autocomplete callback like here :

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/discord/bot.py", line 872, in callback
    return await command.invoke_autocomplete_callback(ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 1376, in invoke_autocomplete_callback
    await command.invoke_autocomplete_callback(ctx)
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 1042, in invoke_autocomplete_callback
    return await ctx.interaction.response.send_autocomplete_result(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/interactions.py", line 1139, in send_autocomplete_result
    await self._locked_response(
  File "/usr/local/lib/python3.12/site-packages/discord/interactions.py", line 1243, in _locked_response
    await coro
  File "/usr/local/lib/python3.12/site-packages/discord/webhook/async_.py", line 220, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
proven quiver
#

Mhm

#

Can you show your pip list pls?

worldly pebble
pine mango
worldly pebble
pine mango
#

no, it is the only one

worldly pebble
pine mango
#

yeah, I will send you the list when I get back to home

worldly pebble
#

ok

pine mango
# worldly pebble .

here is the pip list :

root@4dba9b1b31a3:/# pip list
Package       Version
------------- --------
aiohttp       3.9.5
aiosignal     1.3.1
attrs         23.2.0
certifi       2024.6.2
chardet       3.0.4
frozenlist    1.4.1
googletrans   3.1.0a0
h11           0.9.0
h2            3.2.0
hpack         3.0.0
hstspreload   2024.6.1
httpcore      0.9.1
httpx         0.13.3
hyperframe    5.2.0
idna          2.10
multidict     6.0.5
pip           24.0
py-cord       2.5.0
python-dotenv 1.0.1
rfc3986       1.5.0
setuptools    69.1.1
sniffio       1.3.1
wheel         0.43.0
yarl          1.9.4
worldly pebble
#

nothing strange for me

#

does the bot has a lot of member/user ?

#

or some def function that can maybe blocked it sometime

pine mango
worldly pebble
# pine mango around 1 million

i think it can be an issue, if there is a def function or something like that it can take too munch time between the invoke and defer

#

can you check if you have no def function or function like pillow

pine mango
worldly pebble
#

Yes a def function block the whole bot

pine mango
# worldly pebble Yes a def function block the whole bot

I have changed all def to async def, and I still have errors like this :

Task exception was never retrieved
future: <Task finished name='Task-543450' coro=<ApplicationCommandMixin.on_application_command_auto_complete.<locals>.callback() done, defined at /usr/local/lib/python3.12/site-packages/discord/bot.py:869> exception=NotFound('404 Not Found (error code: 10062): Unknown interaction')>
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/discord/bot.py", line 872, in callback
    return await command.invoke_autocomplete_callback(ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 1042, in invoke_autocomplete_callback
    return await ctx.interaction.response.send_autocomplete_result(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/interactions.py", line 1139, in send_autocomplete_result
    await self._locked_response(
  File "/usr/local/lib/python3.12/site-packages/discord/interactions.py", line 1243, in _locked_response
    await coro
  File "/usr/local/lib/python3.12/site-packages/discord/webhook/async_.py", line 220, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
worldly pebble
#

if when you try it on a smaller bot there is not issue, it can be because of that

pine mango
#

uh ? still had one, oops

worldly pebble
#

there is a lot of not def thing like some database etc

#

and limited it the most can help

#

i just realised ur french

#

or francophone

pine mango
#

seems like there is no more issues.
Thanks !
I will let the case open for 24h and close it tomorrow if I don't have any new error

pine mango
worldly pebble
#

lets hop u still have no issue

pine mango
worldly pebble
#

.norequests

dire canopyBOT
#

Why you should not use the requests library for your bot
requests is a popular HTTP library for Python. It is however not a good option for Discord bots, since it is not async and blocking.

This essentially means that your bot will not be able to execute any code at all while a request is happening. Since requests usually take a few seconds to complete, this can have a detrimental effect on your bot's performance. E.g if a user executes a command that performs a request taking 5 seconds to complete, no one else will be able to use your bot for those 5 seconds.

Please look at using a HTTP library that has async support, such as aiohttp or httpx

worldly pebble
pine mango
pine mango
pine mango
#

pushed in production
still no issue now, I will close the case tomorrow if I still not have any issue

pine mango
#

example of one of the errors :

Task exception was never retrieved
future: <Task finished name='Task-155118' coro=<ApplicationCommandMixin.on_application_command_auto_complete.<locals>.callback() done, defined at /usr/local/lib/python3.12/site-packages/discord/bot.py:869> exception=NotFound('404 Not Found (error code: 10062): Unknown interaction')>
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/discord/bot.py", line 872, in callback
    return await command.invoke_autocomplete_callback(ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 1042, in invoke_autocomplete_callback
    return await ctx.interaction.response.send_autocomplete_result(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/interactions.py", line 1139, in send_autocomplete_result
    await self._locked_response(
  File "/usr/local/lib/python3.12/site-packages/discord/interactions.py", line 1243, in _locked_response
    await coro
  File "/usr/local/lib/python3.12/site-packages/discord/webhook/async_.py", line 220, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
proven quiver
#

is it only at the commands with the autocomplete?

pine mango
#

I can send the files content if you want

worldly pebble
#

?

#

Like advence autocomplete that may help

#

I will try to look at that

pine mango
# worldly pebble You are using basic autocomplete, is there another thing like that )

Here is the autocomplete function I am using :

from discord import slash_command, ApplicationContext, AutocompleteContext, option
from discord.ext.commands import Cog
from discord.utils import basic_autocomplete
from googletrans import Translator

trad = Translator()

LANGUAGES = [list of strings]

class Translate(Cog):
    def __init__(self, bot):
        self.bot = bot

    #########################
    # autocomplete function #
    #########################

    async def get_languages(ctx: AutocompleteContext):
        filtered_languages = [lang for lang in LANGUAGES if lang.startswith(ctx.value.lower())]
        if len(filtered_languages) > 25:
            return filtered_languages[:25]
        else:
            return filtered_languages

    @slash_command(
        name="translate",
        description="Translate a text from a language to another.",
        guild_only=True
    )
    @option(
        name="text",
        description="The text you want to translate.",
        required=True,
        type=str
    )
    @option(
        name="to_language",
        description="The language you want to translate the text into.",
        required=True,
        type=str,
        autocomplete=basic_autocomplete(get_languages)
    )
    @option(
        name="from_language",
        description="The language of your actual text.",
        required=False,
        type=str,
        autocomplete=basic_autocomplete(get_languages)
    )
    @option(
        name="ephemeral",
        description="if you want the answer to be visible only to you. Default is False",
        required=False,
        type=bool
    )
    async def translate(...):
        ....
#

so yes, it is a basic_autocomplete

worldly pebble
#

does this error appear less than before

#

(since you removed all the different def function)

pine mango
#

I just don't have the errors like Unknown Interaction for the ctx.defer or something else, but this error is still at the "same frequency" for the autocomplete. It randomly happens, but it is not appearing less than before

proven quiver
#

btw why did you set the limit to 25 at the autocomplete?

proven quiver
#

and I wonder if you still get it if the autocomplete is outside of the cog

worldly pebble
#

so just do autocomplete = ur fonction

worldly pebble
#

( in the example they never put a limit)

pine mango
worldly pebble
#

okay so yeah limit 25 might be better

#

maybe you can try without the basic autocomplete, i guess it can maybe help

pine mango
#

seem to be working, let me put it in my bot, reload my cogs and I will tell you after X hours if errors came back

worldly pebble
#

try

blazing summit
# worldly pebble so just do autocomplete = ur fonction

This will help. You were nesting your function inside basic autocomplete. Basic autocomplete is a helper function that is doing essentially what you are doing in your autocomplete. So you were autocompleting and than running it through another autocomplete.

worldly pebble
#

^^^

pine mango
#

yeah it seems to be good, I will close the case now

open obsidianBOT
#

This thread was archived by the user that opened it.

pine mango
#

Hello again, I am facing the same issue I had before, but this time I have followed what is said in the last messages :

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 131, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 1009, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/app/cogs/translate.py", line 83, in translate
    await ctx.defer(ephemeral=ephemeral)
  File "/usr/local/lib/python3.12/site-packages/discord/interactions.py", line 748, in defer
    await self._locked_response(
  File "/usr/local/lib/python3.12/site-packages/discord/interactions.py", line 1243, in _locked_response
    await coro
  File "/usr/local/lib/python3.12/site-packages/discord/webhook/async_.py", line 220, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```


Here is the code :
```py
...
    async def get_languages(ctx: AutocompleteContext):
        filtered_languages = [lang for lang in LANGUAGES if lang.startswith(ctx.value.lower())]
        if len(filtered_languages) > 25:
            return filtered_languages[:25]
        else:
            return filtered_languages
...
    @option(
        name="to_language",
        description="The language you want to translate the text into.",
        required=True,
        type=str,
        autocomplete=get_languages
    )
    @option(
        name="from_language",
        description="The language of your actual text.",
        required=False,
        type=str,
        autocomplete=get_languages
    )
...
proven quiver
#

try it with defer

pine mango
# proven quiver try it with defer

I already got it at the first line of my function

    @option(
        name="ephemeral",
        description="if you want the answer to be visible only to you. Default is False",
        required=False,
        type=bool
    )
    async def translate(self, ctx : ApplicationContext, text, to_language, from_language = 'auto', ephemeral = False):
        
        await ctx.defer(ephemeral=ephemeral)
proven quiver
#

do you use something like requests?

pine mango
#

No, I have edited the library files of what I used into httpx.AsyncClient to avoid using synchronous methods

proven quiver
#

do you use a db?

pine mango
#

yes, sqlite3

proven quiver
#

sqlite3 is blocking your bot

#

use aiosqlite instead

pine mango
#

okay, maybe a dumb question but is it exactly like sqlite3 with await before the cursor calls ?

#

yes it is. Thanks, I will edit and close if it works

pine mango
worldly pebble
#

Not since it can be trigger more than one time

pine mango
#

okay, do you have a better idea ?

worldly pebble
#

I do something a little bit more difficult so maybe someone else wirh find an idea

#

If the initialisation is not unit put it just before the bot.run

#

Is not async *

pine mango
#

the initialization is with await, so it is async

worldly pebble
#

There is many way a function setup that u run, a loop that only fire once etc, but ig there a better way that zerry should know

pine mango
#

I will maybe do a function like this :

    init database

asyncio.run(myfunc())
bot.run(TOKEN)
worldly pebble
#

Because it will block all ur loop

pine mango
#

all my loop ? I am talking about running the function just before the bot.run

worldly pebble
#

Asyncio.run block all the loop of the bot

#

.tag Jason

dire canopyBOT
#

Tag not found.

worldly pebble
#

Wait

pine mango
#

asyncio.create_task then ?

worldly pebble
#

Nope no idea rn

worldly pebble
pine mango
# worldly pebble Yes maybe

It was not working with create_task but it seems to be working with this on my test bot

async def connect_database():
    db = await aiosqlite.connect('translator.sqlite')
    cursor = await db.cursor()
    return db, cursor

bot.db, bot.cursor = asyncio.run(connect_database())
worldly pebble
#

Since asyncio.run is blocking

pine mango
#

which loops are you talking about ?

worldly pebble
#

@tasks.loop

pine mango
#

I don't have anyone

#

so for now it seems to work, I will check a better solution but it is not mandatory for now

worldly pebble
#

Still not a good practice but I will find another tonight with my Mac

#

Or if someone here has a better thing

pine mango
#

Here is my new code :

import discord, aiosqlite, os, json, httpx
from discord import Intents
from dotenv import load_dotenv
from datetime import datetime

os.chdir(os.path.dirname(os.path.abspath(__file__)))

# Chargement du token
load_dotenv()
TOKEN = os.getenv('BOT_TOKEN')

class ShardedBot(discord.AutoShardedBot):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.db = None
        self.cursor = None
        
    def __await__(self):
        return self.setup_database().__await__()
    
    # On connection function
    async def setup_database(self):
        self.db = await aiosqlite.connect('translator.sqlite')
        self.cursor = await bot.db.cursor()
        await self.create_tables()
        return self
        
    async def create_tables(self):
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS default_guild_language(
            guild_id TEXT,
            default_language TEXT,
            reaction_activated TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS DMUser(
            user_id TEXT,
            yesno TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS reversed(
            guild_id TEXT,
            channel_id TEXT,
            language_1 TEXT,
            language_2 TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS channel_language(
            guild_id TEXT,
            channel_id TEXT,
            language TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS force_reaction(
            guild_id TEXT,
            forced TEXT,
            minimalist TEXT,
            timeout TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS linkchannels(
            guild_id TEXT,
            channel_id_1 TEXT,
            channel_id_2 TEXT,
            language_1 TEXT,
            language_2 TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS langinfo(
            guild_id TEXT,
            info TEXT
            )
        """)
        print('=== Database Tables are created ! ===')
        
    
    # On ready
    async def on_ready(self):
        print('===== Translator Bot is ready ! =====')

    # On shard connect
    async def on_shard_connect(self, shard_id):
        print(f"=== Shard {shard_id}/{bot.shard_count-1} is ready ! ===")

intents = Intents(guilds=True, messages=True, reactions=True, message_content=True, voice_states=True)
bot = ShardedBot(intents=intents, activity=discord.Game(name="/ translations"), owner_id=341257685901246466)
bot.start_time = datetime.now()

async def main():
    await bot

    # Load cogs
    for filename in os.listdir('./cogs'):
        if filename.endswith('.py'):
            bot.load_extension(f'cogs.{filename[:-3]}')
    
    #bot.start(TOKEN)

if __name__ == '__main__':
    import asyncio
    asyncio.run(main())
    bot.run(TOKEN)

The problem I have is if I want to uncomment the bot.start, the bot.db and bot.cursor are not sent to my cogs. Any way to make it working without breaking loops like Luma said ?

grim badger
#

why are you trying to run your bot twice?

pine mango
#

I am speaking about if I uncomment bot.start, for sure I comment bot.run

#

I do not put twice lol

worldly pebble
#

@pine mango if you are overwriting the Bot thing i have an idea

pine mango
#

tell me ?

worldly pebble
#
    async def start(self, token: str, *, reconnect: bool = True):
        await self.setup_database()
        await self.login(token)
        await self.connect(reconnect=reconnect)
#

so it will setup the database just before the bot connect

#

and then you cant do
if name == 'main':
bot.run(TOKEN)

#

it will work fine

#

you can also add ur cog logic there if you want

#

that was the complicated thing i was doing kinda (i'm using 3 custom class for my database...)

pine mango
#

I just remove the __await__(self) function ?

#

what do I have to remove ?
the return self in setup_database() may not be useful too

worldly pebble
#

and yeah return slef is not realy useful

pine mango
grim badger
#

what does that even mean

worldly pebble
#

bot.db is None is the cog

#

Does ur setup database is fire before the cog ?

grim badger
#

also, wtf is this line

worldly pebble
#

To trigger the __await__

pine mango
worldly pebble
#

Can you show me the code ?

pine mango
#

sure

#
import discord, aiosqlite, os, json, httpx
from discord import Intents
from dotenv import load_dotenv
from datetime import datetime

os.chdir(os.path.dirname(os.path.abspath(__file__)))

# Chargement du token
load_dotenv()
TOKEN = os.getenv('BOT_TOKEN')

# Création du Httpx client
HTTPClient = httpx.AsyncClient()

class ShardedBot(discord.AutoShardedBot):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.db = None
        self.cursor = None
    
    async def start(self, token: str, *, reconnect: bool = True):
        await self.setup_database()
        
        # Load cogs
        for filename in os.listdir('./cogs'):
            if filename.endswith('.py'):
                bot.load_extension(f'cogs.{filename[:-3]}')
                
        await self.login(token)
        await self.connect(reconnect=reconnect)
        
    
    # On connection function
    async def setup_database(self):
        self.db = await aiosqlite.connect('translator.sqlite')
        self.cursor = await bot.db.cursor()
        await self.create_tables()
        
    async def create_tables(self):
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS default_guild_language(
            guild_id TEXT,
            default_language TEXT,
            reaction_activated TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS DMUser(
            user_id TEXT,
            yesno TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS reversed(
            guild_id TEXT,
            channel_id TEXT,
            language_1 TEXT,
            language_2 TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS channel_language(
            guild_id TEXT,
            channel_id TEXT,
            language TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS force_reaction(
            guild_id TEXT,
            forced TEXT,
            minimalist TEXT,
            timeout TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS linkchannels(
            guild_id TEXT,
            channel_id_1 TEXT,
            channel_id_2 TEXT,
            language_1 TEXT,
            language_2 TEXT
            )
        """)
        await self.cursor.execute("""
            CREATE TABLE IF NOT EXISTS langinfo(
            guild_id TEXT,
            info TEXT
            )
        """)
        print('=== Database Tables are created ! ===')
        
    
    # On ready
    async def on_ready(self):
        print('===== Translator Bot is ready ! =====')

    # On shard connect
    async def on_shard_connect(self, shard_id):
        print(f"=== Shard {shard_id}/{bot.shard_count-1} is ready ! ===")

intents = Intents(guilds=True, messages=True, reactions=True, message_content=True, voice_states=True)
bot = ShardedBot(intents=intents, activity=discord.Game(name="/ translations"), owner_id=341257685901246466)
bot.start_time = datetime.now()

async def main():    
    await bot.start(TOKEN)

if __name__ == '__main__':
    import asyncio
    asyncio.run(main())
worldly pebble
#

change that

#
async def main():    
    await bot.start(TOKEN)

if __name__ == '__main__':
    import asyncio
    asyncio.run(main())
#

bt that:


if __name__ == '__main__':
    bot.run(TOKEN)
#

@pine mango

pine mango
#

working now

#

thanks !

worldly pebble
#

with pleasure