-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherrors.py
47 lines (41 loc) · 2.44 KB
/
errors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import asyncio
import discord
from discord.ext import commands
timeout = 5
class sendErrorMessage:
def __init__(self, ctx):
self.embed = discord.Embed(
title="# {}".format(str(ctx.channel)),
description="!Something Went Wrong",
color=0xA292C1,
)
self.channel = ctx.channel
async def sendError(self, errorcode):
if errorcode == "" or str(errorcode).startswith("E_"):
errorcode = self.get_error(errorcode)
self.embed.add_field(name="Error:", value=errorcode)
self.embed.set_thumbnail(
url="https://cdn.pixabay.com/photo/2017/02/12/21/29/false-2061131_960_720.png"
)
message = await self.channel.send(embed=self.embed)
await asyncio.sleep(timeout)
await message.delete()
def get_error(self, errorcode):
errors = {
"E_INVALID_COMMAND": "I've never heard of that command before, for help, take a look at !ctf help (custom made for She11Sh0ck :P)",
"E_INVALID_PARAMS": "Unfortunately more parameters were expected for that command. If you're still unsure, consider `!ctf help`.",
"E_CHANNEL_NOT_FOUND": "That channel doesn't seem to exist. I'll look again, but I might just be blind. ",
"E_CHANNEL_NOT_SET": "I really can't help you send messages to a channel that isn't defined. If you don't know what I should do, then how should I?",
"E_CTF_NOT_SET": "To my knowledge there is no ongoing CTF, perhaps you should consider setting one using `!ctf createctf [ctfname]` or `!ctf setctf [ctfname]`.",
"E_CTF_NOT_FOUND": "That CTF doesn't exist, maybe you mispelled it.",
"E_CTF_NOT_IN_DB": "It looks like the CTF you are in is not in our database, perhaps it was deleted or you didn't create it yet.",
"E_CTF_ALREADY_EXISTS": "That CTF already exists, maybe you should `!ctf setctf [ctfname]`",
"E_CTF_ALREADY_MERGED": "This CTF has already been merged or something has gone very, very wrong",
"E_Q_NOT_FOUND": "That Q doesn't exist, maybe you mispelled it.",
"E_Q_ALREADY_EXISTS": "A Q with that name already exists.",
"E_TEAM_ID_NOT_SET": "You haven't set your team ID. Please set it with !ctf setid [id]",
"E_TEAM_ID_WRONG" : "CTFTime doesn't have a team with this ID. Please try re-entering your team ID with !ctf setid [id]. You can find your id in the URL of your team's CTFTime page.",
"E_GENERIC": "An unknown error occured. The developers have been notified. (It's possible you just entered the command incorrectly :P )",
"": "E_[...] Expectant an Error, no errorcode defined.",
}
return errors[errorcode]