Search code examples
pythondiscord.pytermux

Discord.py's [async def setup_hook(self):] called on Windows but don't on Termux


Code:

import discord
 
import credentials
 
discord_client = None
 
class MyDiscordClient(discord.Client):
 
    async def on_ready(self):
        print("Logged on as {0}!".format(self.user))
 
    async def setup_hook(self):
        print('async def setup_hook(self):')
 
 
def handle_discord():
    print('Start:Discord.')
    global discord_client
    discord_client = MyDiscordClient(intents=discord.Intents.default())
    discord_client.run(credentials.TOKEN)
    print('Complete:Discord.')
 
def main():
    handle_discord()
 
main()

So this work on Windows and give me this output:

Start:Discord.
async def setup_hook(self):
Logged on as TestBot#6191!

But on Termux i get this:

Start:Discord.
Logged on as TestBot#6191!

So [async def setup_hook(self):] don't get called on Termux BUT discord bot is working fine, it can receive and send messages.


Solution

  • Full wipe of Termux solved this issue. (Reinstalling of Python and Discord.py don't work)