Add invite URL and check for expected permissions
This commit is contained in:
parent
0adb6d32ff
commit
144dcd509e
24
ahtcg_bot.py
24
ahtcg_bot.py
@ -63,6 +63,17 @@ class ArkhamDBUpdater(discord.Client):
|
||||
|
||||
async def on_ready(self) -> None:
|
||||
logging.info(f"Logged in as {self.user} (ID: {self.user.id})")
|
||||
expected_permissions = permissions = discord.Permissions(
|
||||
read_messages=True,
|
||||
read_message_history=True,
|
||||
send_messages=True,
|
||||
use_application_commands=True,
|
||||
)
|
||||
logging.info(
|
||||
"Invite URL: "
|
||||
+ discord.utils.oauth_url(self.user.id, permissions=expected_permissions)
|
||||
)
|
||||
|
||||
logging.info("Enabled on servers:")
|
||||
async for guild in self.fetch_guilds(limit=150):
|
||||
logging.info(f" - {guild.name}")
|
||||
@ -70,8 +81,17 @@ class ArkhamDBUpdater(discord.Client):
|
||||
|
||||
for channel_id in self.channel_list:
|
||||
channel = self.get_channel(channel_id)
|
||||
print(channel)
|
||||
print(channel.permissions_for(self.user))
|
||||
permissions = channel.permissions_for(channel.guild.me)
|
||||
missing_permissions = (
|
||||
permissions & expected_permissions
|
||||
) ^ expected_permissions
|
||||
if missing_permissions.value:
|
||||
logging.warning(
|
||||
f"channel: '{channel}' missing permissions: {missing_permissions}"
|
||||
)
|
||||
else:
|
||||
logging.info(f"channel '{channel}' permissions OK")
|
||||
logging.debug(f"channel '{channel}' permissions: {dict(permissions)}")
|
||||
|
||||
await self.setup_commands()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user