Message and error logging, various bugfixes

This commit is contained in:
Ske
2018-10-27 23:30:12 +02:00
parent ea62ede21b
commit 58d8927380
7 changed files with 161 additions and 37 deletions

View File

@@ -8,7 +8,7 @@ async def get_message_contents(client: discord.Client, channel_id: int, message_
channel = client.get_channel(str(channel_id))
if channel:
try:
original_message = await client.get_message(channel, str(message_id))
original_message = await client.get_channel(channel).get_message(message_id)
return original_message.content or None
except (discord.errors.Forbidden, discord.errors.NotFound):
pass
@@ -24,13 +24,13 @@ async def message_info(ctx: CommandContext):
return CommandError("You must pass a valid number as a message ID.", help=help.message_lookup)
# Find the message in the DB
message = await db.get_message(ctx.conn, str(mid))
message = await db.get_message(ctx.conn, mid)
if not message:
raise CommandError("Message with ID '{}' not found.".format(mid))
# Get the original sender of the messages
try:
original_sender = await ctx.client.get_user_info(str(message.sender))
original_sender = await ctx.client.get_user_info(message.sender)
except discord.NotFound:
# Account was since deleted - rare but we're handling it anyway
original_sender = None

View File

@@ -4,10 +4,13 @@ logger = logging.getLogger("pluralkit.commands")
async def set_log(ctx: CommandContext):
if not ctx.message.author.server_permissions.administrator:
if not ctx.message.author.guild_permissions.administrator:
return CommandError("You must be a server administrator to use this command.")
server = ctx.message.server
server = ctx.message.guild
if not server:
return CommandError("This command can not be run in a DM.")
if not ctx.has_next():
channel_id = None
else: