PluralKit/src/pluralkit/bot/commands/mod_commands.py

22 lines
772 B
Python
Raw Normal View History

from pluralkit.bot.commands import *
2018-09-07 17:34:38 +02:00
async def set_log(ctx: CommandContext):
if not ctx.message.author.guild_permissions.administrator:
raise CommandError("You must be a server administrator to use this command.")
2018-09-07 17:34:38 +02:00
server = ctx.message.guild
if not server:
raise CommandError("This command can not be run in a DM.")
2018-09-07 17:34:38 +02:00
if not ctx.has_next():
channel_id = None
else:
2018-09-07 17:34:38 +02:00
channel = utils.parse_channel_mention(ctx.pop_str(), server=server)
if not channel:
raise CommandError("Channel not found.")
channel_id = channel.id
await db.update_server(ctx.conn, server.id, logging_channel_id=channel_id)
await ctx.reply_ok("Updated logging channel." if channel_id else "Cleared logging channel.")