Refactor error handling slightly and don't use embeds for basic status/error messages. Closes #28.

This commit is contained in:
Ske
2018-11-15 21:05:13 +01:00
parent 869f686bd5
commit 8e504fa879
11 changed files with 74 additions and 81 deletions

View File

@@ -5,19 +5,19 @@ logger = logging.getLogger("pluralkit.commands")
async def set_log(ctx: CommandContext):
if not ctx.message.author.guild_permissions.administrator:
return CommandError("You must be a server administrator to use this command.")
raise CommandError("You must be a server administrator to use this command.")
server = ctx.message.guild
if not server:
return CommandError("This command can not be run in a DM.")
raise CommandError("This command can not be run in a DM.")
if not ctx.has_next():
channel_id = None
else:
channel = utils.parse_channel_mention(ctx.pop_str(), server=server)
if not channel:
return CommandError("Channel not found.")
raise CommandError("Channel not found.")
channel_id = channel.id
await db.update_server(ctx.conn, server.id, logging_channel_id=channel_id)
return CommandSuccess("Updated logging channel." if channel_id else "Cleared logging channel.")
await ctx.reply_ok("Updated logging channel." if channel_id else "Cleared logging channel.")