#how to tell if a guild is cached?
1 messages · Page 1 of 1 (latest)
Hey! Once your issue is solved, press the button below to close this thread!
Get guild returns None -> not cached
like self.guildIdObj = client.get_guild()
and in like an on_ready event, then check if its cached or not
btw why you need to use get_guild instead of fetch?
im doing it in the init method of a class
oh so you cant use async?
then I advise you to use Startup event instead of init
that's what I do
alright
something like:
from interactions import Client, Extension, events, listen
class InteractionExtTemplate(Extension):
def __init__(self, client: Client):
self.client = client
self.guildObject = None
@listen()
async def on_startup(self, event: events.Startup):
self.guildObject = self.client.fetch_guild()
@listen()
async def onGuildMemberJoin(self, event: events.MemberAdd):
print("Do your thing with guildObject here...")
def setup(client):
InteractionExtTemplate(client)
this, what you would do?
yep, you can even remove totally the init since it's useless here
uh yes you should have it it's passed by default to an Extension
theres no autocomplete for it
OH yeah!
i think i can do value reassign to give it autocomplete
good catch actually
from interactions import Client, Extension, events, listen, Bot
class InteractionExtTemplate(Extension):
@listen()
async def on_startup(self, event: events.Startup):
self.bot: Client = self.bot
self.guildObject = self.client.fetch_guild()
@listen()
async def onGuildMemberJoin(self, event: events.MemberAdd):
print("Do your thing with guildObject here...")
def setup(client):
InteractionExtTemplate(client)