1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 13:02:38 +00:00

try/except to suppress()

This commit is contained in:
Myned 2017-10-16 02:07:15 -04:00
parent e21909faec
commit f63d7f65df

View file

@ -1,8 +1,9 @@
import asyncio
import json
import traceback
from contextlib import suppress
import discord
import discord as d
from discord import errors as err
from discord.ext import commands
from discord.ext.commands import errors as errext
@ -51,7 +52,7 @@ def mod(ctx):
def is_nsfw():
def predicate(ctx):
if isinstance(ctx.message.channel, discord.TextChannel):
if isinstance(ctx.message.channel, d.TextChannel):
return ctx.message.channel.is_nsfw()
return True
return commands.check(predicate)
@ -59,12 +60,8 @@ def is_nsfw():
def del_ctx():
async def predicate(ctx):
if ctx.me.permissions_in(ctx.channel).manage_messages and isinstance(ctx.message.channel, discord.TextChannel) and ctx.guild.id in u.settings['del_ctx']:
try:
if ctx.guild.id in u.settings['del_ctx'] and ctx.me.permissions_in(ctx.channel).manage_messages and isinstance(ctx.message.channel, d.TextChannel):
with suppress(err.NotFound):
await ctx.message.delete()
except err.NotFound:
pass
return True
return commands.check(predicate)