Added stupid check to see if the message was "edited" within dms

pull/8/head
sgoudham 4 years ago
parent f246fb1d2f
commit 404b9daa37

@ -3,7 +3,7 @@ from datetime import timedelta
from typing import Optional from typing import Optional
import discord import discord
from discord import Member, Embed from discord import Member, Embed, DMChannel
from discord.ext.commands import command, guild_only, has_guild_permissions, bot_has_guild_permissions, Greedy, \ from discord.ext.commands import command, guild_only, has_guild_permissions, bot_has_guild_permissions, Greedy, \
cooldown, BucketType, Cog cooldown, BucketType, Cog
@ -608,8 +608,14 @@ class Moderation(Cog):
async def on_message_edit(self, before, after): async def on_message_edit(self, before, after):
"""Logging Message Edits (Within Cache)""" """Logging Message Edits (Within Cache)"""
msg_channel = self.bot.get_channel(int(after.channel.id))
# Get the channel within the cache
if not isinstance(msg_channel, DMChannel):
# Get the channel within the cache # Get the channel within the cache
channel = get_modlog_for_guild(str(after.guild.id)) channel = get_modlog_for_guild(str(after.guild.id))
else:
return
# When no modlogs channel is returned, do nothing # When no modlogs channel is returned, do nothing
if channel is not None: if channel is not None:
@ -641,8 +647,13 @@ class Moderation(Cog):
async def on_raw_message_edit(self, payload): async def on_raw_message_edit(self, payload):
"""Logging Message Edits Not Stored Within Internal Cache""" """Logging Message Edits Not Stored Within Internal Cache"""
msg_channel = self.bot.get_channel(int(payload.data["channel_id"]))
# Get the channel within the cache # Get the channel within the cache
channel = get_modlog_for_guild(str(payload.data["guild_id"])) if not isinstance(msg_channel, DMChannel):
channel = get_modlog_for_guild(payload.data["guild_id"])
else:
return
# Only log this message if the message does not exist within the internal cache and modlogs channel is set up # Only log this message if the message does not exist within the internal cache and modlogs channel is set up
if channel is not None and not payload.cached_message: if channel is not None and not payload.cached_message:

Loading…
Cancel
Save