Skip to content

Commit

Permalink
Update to a1.1.1
Browse files Browse the repository at this point in the history
Added error logging
  • Loading branch information
wbourne0 committed Sep 25, 2019
1 parent 5fd17b9 commit 9027915
Show file tree
Hide file tree
Showing 13 changed files with 644 additions and 440 deletions.
1 change: 0 additions & 1 deletion asyncer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import asyncio
from threading import Thread

Expand Down
52 changes: 44 additions & 8 deletions commands/Help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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):
Expand All @@ -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`'
Expand Down
2 changes: 1 addition & 1 deletion commands/data_tweaking.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def Execute(args, msg, client):

await execute(command, locals())
out = f.getvalue()
error = False
done_oof = False
except Exception:

traceback_message = traceback.format_exc()
Expand Down
43 changes: 39 additions & 4 deletions commands/fun.py
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):
Expand All @@ -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')
3 changes: 1 addition & 2 deletions content_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
'er',
'it',
'hat',
'wipe',
'es'
'wipe'
''
]

Expand Down
4 changes: 3 additions & 1 deletion emojiCheck.py
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)
72 changes: 72 additions & 0 deletions error_log.py
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)
2 changes: 1 addition & 1 deletion findTime.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def findTime(string):
time = 2629746 * duration
else:
time = 60 * int(string)
return float(time)
return int(time)
11 changes: 11 additions & 0 deletions ignoredChars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ignoredChars = [
'`',
'*',
'-',
'~',
'_',
'|',
'\'',
'\\',
'\n'
]
Loading

0 comments on commit 9027915

Please sign in to comment.