#get_guild() always returns None
1 messages · Page 1 of 1 (latest)
can you show your bots constructor?
Do you mean
token="...",
default_enabled_guilds=(test_server_id),
intents=Intents.GUILD_MEMBERS
)```
yes
your issue is that you only specified one intent
you maybe want to do ```py
intents = hikari.Intents.ALL_UNPRIVILEDGED | hikari.Intents.GUILD_MEMBERS
describe "it did not work" please :)
I get the same result as before. The Optional[GatewayGuild] is still empty.
did you restart your bot?
have you tried off and on again? yes
mind showing the code?
Sorry, I was away over Easter. The function looks like this:
def check_permissions(guild: GatewayGuild, bot_user: OwnUser, req_perms: Flag) -> bool:
bot_role = guild.get_role(bot_user)
if (bot_role.permissions & req_perms) == req_perms:
return True
return False
Called from:
@bot.listen(events.MemberCreateEvent)
async def on_member_join(event: events.MemberCreateEvent):
print(">>> Captured MemberCreateEvent")
print(event.member)
if not check_permissions(event.member.get_guild(), bot.get_me(), required_perms):
raise errors.UnauthorizedError(
f"{bot.get_me().mention} has incomplete permissions.")
await assign_new_role(event.member)
await welcome_message(event.member)
I somehow managed to resolve this issue by removing the bot's GUILD_MEMBERS intent and then adding it back in. Still got permission issues, but that's a different problem.