mirror of
https://github.com/myned/modufur.git
synced 2024-11-01 21:02:38 +00:00
try/except to suppress()
This commit is contained in:
parent
e21909faec
commit
f63d7f65df
1 changed files with 5 additions and 8 deletions
|
@ -1,8 +1,9 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
|
from contextlib import suppress
|
||||||
|
|
||||||
import discord
|
import discord as d
|
||||||
from discord import errors as err
|
from discord import errors as err
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import errors as errext
|
from discord.ext.commands import errors as errext
|
||||||
|
@ -51,7 +52,7 @@ def mod(ctx):
|
||||||
|
|
||||||
def is_nsfw():
|
def is_nsfw():
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
if isinstance(ctx.message.channel, discord.TextChannel):
|
if isinstance(ctx.message.channel, d.TextChannel):
|
||||||
return ctx.message.channel.is_nsfw()
|
return ctx.message.channel.is_nsfw()
|
||||||
return True
|
return True
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
|
@ -59,12 +60,8 @@ def is_nsfw():
|
||||||
|
|
||||||
def del_ctx():
|
def del_ctx():
|
||||||
async def predicate(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']:
|
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):
|
||||||
try:
|
with suppress(err.NotFound):
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
|
|
||||||
except err.NotFound:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
|
|
Loading…
Reference in a new issue