-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added error logging
- Loading branch information
Showing
13 changed files
with
644 additions
and
440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
import asyncio | ||
from threading import Thread | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,38 @@ | |
from commands import data_tweaking | ||
from commands import moderation_tools | ||
from checkTrust import checkTrust | ||
from commands import fun | ||
|
||
main_body = '''**Fun**: Fun commands such as a dice roller | ||
''' | ||
|
||
main_help = discord.Embed( | ||
title='Help', | ||
description=''' | ||
**Currently, I do not have any commands for non-moderators. I appologize inconvenience **''') | ||
description=main_body | ||
) | ||
|
||
main_help.set_footer( | ||
text='Use help <catagory> to get help on a certain section.' | ||
'Comments or suggestions? Email [email protected] to be heard' | ||
) | ||
|
||
mod_help = discord.Embed(title='Help', description=''' | ||
**Customization:** Customization commands, such as mute duration | ||
**Moderation:** Moderation commands.''', color=0xff8000) | ||
**Moderation:** Moderation commands.\n''' + main_body, color=0xff8000) | ||
mod_help.set_footer( | ||
text='Use help <catagory> to get help on a certain section.' | ||
'Comments or suggestions? Email [email protected] to be heard' | ||
) | ||
|
||
main_pgs = { | ||
'fun': fun.helpMsg | ||
} | ||
|
||
mod_pgs = { | ||
'customization': data_tweaking.helpMsg, | ||
'moderation': moderation_tools.helpMsg | ||
'moderation': moderation_tools.helpMsg, | ||
} | ||
mod_pgs.update(main_pgs) | ||
|
||
trust_moderation_help = discord.Embed( | ||
title='Moderation', | ||
|
@@ -31,19 +46,25 @@ | |
**`warn <user> <reason>`:** Warn a user. | ||
(*=optional)''', | ||
(*=optional)\n''' + main_body, | ||
color=0xd82222 | ||
) | ||
|
||
trust_pgs = { | ||
'moderation': trust_moderation_help | ||
} | ||
|
||
trust_help = '**Moderation:** Moderation commands.' | ||
trust_help = discord.Embed( | ||
title='Help', | ||
description=trust_help, | ||
color=0xff8000 | ||
) | ||
mainPgs = {} | ||
|
||
trust_help.set_footer( | ||
text='Use help <catagory> to get help on a certain section.' | ||
'Comments or suggestions? Email [email protected] to be heard.' | ||
) | ||
|
||
|
||
async def Help(args, msg): | ||
|
@@ -52,39 +73,54 @@ async def Help(args, msg): | |
args.remove('') | ||
channel = msg.channel | ||
if msg.author.guild_permissions.administrator: | ||
|
||
if len(args) == 0: | ||
await channel.send(embed=mod_help) | ||
|
||
elif len(args) == 1: | ||
|
||
if args[0].lower() in mod_pgs: | ||
await channel.send(embed=mod_pgs[args[0].lower()]) | ||
|
||
else: | ||
await channel.send(args[0].lower() + ' is not in the help list.') | ||
|
||
else: | ||
await channel.send( | ||
'Invalid ammount of args. example command: `help Customization`' | ||
) | ||
|
||
elif (await checkTrust(msg.guild, msg.author)): | ||
|
||
if len(args) == 0: | ||
await channel.send(embed=trust_help) | ||
|
||
elif len(args) == 1: | ||
|
||
if args[0].lower() in trust_pgs: | ||
await channel.send(embed=trust_pgs[args[0].lower()]) | ||
|
||
else: | ||
await channel.send(args[0].lower() + ' is not in the help list.') | ||
|
||
else: | ||
await channel.send( | ||
'Invalid ammount of args. example command: `help Customization`' | ||
) | ||
|
||
else: | ||
|
||
if len(args) == 0: | ||
await channel.send(embed=main_help) | ||
|
||
elif len(args) == 1: | ||
if args[0].lower() in mainPgs: | ||
await channel.send(embed=mainPgs[args[0].lower()]) | ||
|
||
if args[0].lower() in main_pgs: | ||
await channel.send(embed=main_pgs[args[0].lower()]) | ||
|
||
else: | ||
await channel.send(args[0].lower() + ' is not in the help list.') | ||
|
||
else: | ||
await channel.send( | ||
'Invalid ammount of args. example command: `help Customization`' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
import discord | ||
import asyncio | ||
from random import randint | ||
help_message = ''' | ||
helpText = ''' | ||
**`roll: <amount>d<sides>`** Gets the combined total of <amount> dice with <sides> sides. | ||
''' | ||
helpMsg = discord.Embed( | ||
title="Fun", | ||
description=helpText, | ||
color=0x00f2ff | ||
) | ||
|
||
helpMsg.set_footer( | ||
text='Comments or suggestions? Email [email protected] ' | ||
'for your suggestion to be heard' | ||
) | ||
|
||
|
||
async def roll(args, msg): | ||
|
@@ -33,3 +40,31 @@ async def roll(args, msg): | |
'Email [email protected] to reply.' | ||
) | ||
await channel.send(embed=embed) | ||
|
||
|
||
async def statroll(args, msg): | ||
channel = msg.channel | ||
author = msg.author | ||
|
||
while '' in args: | ||
args.remove('') | ||
|
||
if len(args) == 0: | ||
stats = [] | ||
|
||
for n in range(6): | ||
results = [] | ||
|
||
for l in range(4): | ||
results.append(randint(2, 6)) | ||
|
||
results = sorted(results) | ||
results.remove(results[-1]) | ||
value = 0 | ||
for a in results: | ||
value += a | ||
print(value) | ||
|
||
|
||
else: | ||
await channel.send(f'<@{author.id}> this command takes no arguments') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,7 @@ | |
'er', | ||
'it', | ||
'hat', | ||
'wipe', | ||
'es' | ||
'wipe' | ||
'' | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import re | ||
import emoji | ||
|
||
|
||
def count(message): | ||
emoji_list = [c for c in message if c in emoji.UNICODE_EMOJI] | ||
emoji_list += re.findall(r'<:\w*:\d*>', message) | ||
return len(emoji_list) | ||
return len(emoji_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import re | ||
import discord | ||
from datetime import datetime, timedelta | ||
|
||
|
||
class InvalidDate(BaseException): pass | ||
|
||
|
||
def find_date(string): # Credits to mat for this script again | ||
times = { | ||
'months': timedelta(days=30), | ||
'month': timedelta(days=30), | ||
'mo': timedelta(days=30), | ||
|
||
'weeks': timedelta(weeks=1), | ||
'week': timedelta(weeks=1), | ||
'w': timedelta(weeks=1), | ||
|
||
'days': timedelta(days=1), | ||
'day': timedelta(days=1), | ||
'd': timedelta(days=1), | ||
|
||
'hours': timedelta(hours=1), | ||
'hour': timedelta(hours=1), | ||
'h': timedelta(hours=1), | ||
|
||
'minutes': timedelta(minutes=1), | ||
'minute': timedelta(minutes=1), | ||
'm': timedelta(minutes=1), | ||
|
||
'seconds': timedelta(seconds=1), | ||
'second': timedelta(seconds=1), | ||
's': timedelta(seconds=1), | ||
} | ||
leftover_string = string | ||
total_time = timedelta() | ||
while leftover_string: | ||
found_match = None | ||
found_time = None | ||
for t in times: | ||
matched = re.match(r'^(\d+) ?' + t, leftover_string) | ||
if matched is not None: | ||
found_match = matched | ||
found_time = times[t] | ||
break | ||
if found_match is None: | ||
raise InvalidDate(f'Invalid date "{string}"') | ||
amount = matched.group(1) | ||
added_time = found_time * int(amount) | ||
total_time += added_time | ||
|
||
string_end = found_match.span()[1] | ||
|
||
leftover_string = leftover_string[string_end:] | ||
leftover_string = leftover_string.strip() | ||
return str((datetime.now() + total_time).strftime('%Y-%m-%w-%W %H:%M:%S')) | ||
|
||
|
||
async def error_log(tb, error, client): | ||
error_type = str(error[0])[8:][:-2] | ||
|
||
embed = discord.Embed( | ||
title=f'**{error_type}**', | ||
description=f'```py\n{tb}\n```', | ||
color=0xff0000 | ||
) | ||
|
||
embed.set_footer(text=find_date('0s')) | ||
|
||
guild = client.get_guild(585606083897458691) | ||
channel = guild.get_channel(626223737376604191) | ||
await channel.send(embed=embed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
ignoredChars = [ | ||
'`', | ||
'*', | ||
'-', | ||
'~', | ||
'_', | ||
'|', | ||
'\'', | ||
'\\', | ||
'\n' | ||
] |
Oops, something went wrong.