Skip to content

Commit

Permalink
Improve systemchannel explanation (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
eibex authored Mar 6, 2021
1 parent ef20cc6 commit e3d5300
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,10 +1207,27 @@ async def set_systemchannel(ctx):
or not mentioned_channels
or channel_type not in ["main", "server"]
):
server_channel = db.fetch_systemchannel(guild_id)
if isinstance(server_channel, Exception):
await system_notification(
None,
"Database error when fetching guild system"
f" channels:\n```\n{server_channel}\n```\n\n{text}",
)
return

if server_channel:
server_channel = server_channel[0][0]

await ctx.send(
"Define if you are setting up a server or main system channel and"
f" mention the target channel.\n```\n{prefix}systemchannel"
" <main/server> #channelname\n```"
" <main/server> #channelname\n```\nThe server system channel"
" reports errors and notifications related to this server only,"
" while the main system channel is used as a fall-back and for"
" bot-wide errors and notifications.\n\nThe current channels are:\n"
f"**Main:** {system_channel.mention if system_channel else "none"}\n"
f"**Server:** {server_channel.mention if server_channel else "none"}"
)
return

Expand All @@ -1219,7 +1236,7 @@ async def set_systemchannel(ctx):

server = await getguild(guild_id)
bot_user = server.get_member(bot.user.id)
bot_permissions = (await getchannel(system_channel)).permissions_for(bot_user)
bot_permissions = (await getchannel(target_channel)).permissions_for(bot_user)
writable = bot_permissions.read_messages
readable = bot_permissions.view_channel
if not writable or not readable:
Expand Down

0 comments on commit e3d5300

Please sign in to comment.