#creating listeners outside of the main file?

1 messages · Page 1 of 1 (latest)

sonic spruce
#

Is it possible to write your @listen() in the an extension? for me it just throws critical errors but i just don know what i did wrong.

Example: I want to have a listener that does something on a message deleted event, inside an extnasion. How would i do it?

open capeBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

sonic spruce
#

creating listeners outside of the main file?

pine goblet
#

you do the same thing as for your main class

#

you probably indented it badly

sonic spruce
#

so in my main class it would be the following listener:

@listen()
async def on_ready():
    global bot_info
    print(f'Logged in as {bot.user.username} ({bot.user.id})')
    ns.logthis("info", f"Logged in as {bot.user.username} ({bot.user.id})")
    await bot.change_presence(activity=Activity(name=bot_info["general_variables"]["startup_activity"], type=ActivityType.WATCHING))```
In my Extesnion it would be something like this:
```class listeners(Extension):
    @listen()
    async def on_message_delete(self):
     do some crazy stuff here


def setup(bot):
    listeners(bot)```

but it says the listen decorator has no referrence
open lily
#

well you gotta import listen

sonic spruce
#

Awh man... sorry for bothering you keepincool