Fixing some bugs

This commit is contained in:
Anonymus Raccoon
2020-09-13 14:27:51 +02:00
parent 43cc41c4a5
commit 17f34be6c1
3 changed files with 15 additions and 3 deletions

View File

@@ -1,11 +1,16 @@
import discord
from discord import NotFound
import config
def auto_delete(f):
async def wrapper(*args, **kwargs):
ret = await f(*args, **kwargs)
try:
await kwargs["message"].delete()
except NotFound:
pass
return ret
return wrapper

View File

@@ -47,7 +47,10 @@ async def join_event(*,
guild: discord.Guild,
channel: discord.TextChannel,
**_):
try:
event: int = number_emojis.index(reaction.emoji) + 1
except ValueError:
return
role: str = discord.utils.get(guild.roles, name=f"{config.PARTICIPANT_PREFIX}{event}")
if role is None or role in member.roles:
return

View File

@@ -53,7 +53,11 @@ class Nemo(discord.Client):
await vote.remove(member)
return
try:
await handler[1](reaction=reaction, member=member, message=reaction.message, guild=reaction.message.guild, channel=reaction.message.channel)
await handler[1](reaction=reaction,
member=member,
message=reaction.message,
guild=reaction.message.guild,
channel=reaction.message.channel)
except Exception:
await reaction.message.channel.send(f"Fatal error: {traceback.format_exc()}")
raise