Skip to content

Commit

Permalink
Updating to Beta 1.1.0
Browse files Browse the repository at this point in the history
Added purge command and re-added logging to the bot.
  • Loading branch information
wbourne0 committed Dec 31, 2019
1 parent 1578edc commit b748283
Show file tree
Hide file tree
Showing 18 changed files with 557 additions and 8 deletions.
Binary file modified Commands/__pycache__/data_tweaking.cpython-37.pyc
Binary file not shown.
Binary file modified Commands/__pycache__/dev_cmds.cpython-37.pyc
Binary file not shown.
Binary file modified Commands/__pycache__/fun.cpython-37.pyc
Binary file not shown.
Binary file modified Commands/__pycache__/help.cpython-37.pyc
Binary file not shown.
Binary file modified Commands/__pycache__/moderation.cpython-37.pyc
Binary file not shown.
23 changes: 23 additions & 0 deletions Commands/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,29 @@ def check(reaction, user):
else:
await ctx.send('Warning will not be deleted.')

@commands.command(name='purge')
async def purge(self, ctx, ammount: int, user: discord.Member = None):
channel = ctx.channel

def check_user(message):
return message.author == user
msg = await ctx.send('Purging messages.')
if user is not None:
await channel.purge(
limit=ammount,
check=lambda x: x.author == user,
bulk=True
)
else:
await channel.purge(
limit=ammount + 1,
check=lambda x: x != msg,
bulk=True
)
await msg.edit(content='Deleted messages.')
await asyncio.sleep(2)
await msg.delete()


def setup(bot):
bot.add_cog(Moderation(bot))
Binary file modified Mail/__pycache__/main.cpython-37.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions Mail/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def __init__(self):

def __repr__(self):
return self.data

def get_data(self, message_id):
if message_id in self.data:
return self.data[message_id]
else:
return None

def add_data(self, ctx, message):
user = ctx.author
if user.id in self.users:
Expand All @@ -56,7 +56,7 @@ def add_data(self, ctx, message):
self.data[message.id] = PendingConversation(user.id, guild.id)
self.users.append(user.id)
return True

def remove(self, message):
if message.id not in self.data:
return
Expand Down
4 changes: 2 additions & 2 deletions Moderation/Message_Checks/banned_word.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
'er',
'it',
'hat',
'wipe',
'wipe',
'wipe'
'',
''
]

base_words = [
Expand Down
Binary file modified Moderation/__pycache__/main.cpython-37.pyc
Binary file not shown.
Binary file modified Moderation/__pycache__/spamchart.cpython-37.pyc
Binary file not shown.
Binary file not shown.
119 changes: 119 additions & 0 deletions Other/Starboard/Events/on_reaction_add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
from re import findall
from Other.Starboard.utils import get_embed, get_star_ammount, image_types


async def reaction_added(reaction, user, bot, data):

msg = reaction.message
author = msg.author
guild = msg.guild
if str(reaction) == '⭐':
leaderboard = data.get_leaders(guild)
msg = reaction.message
channel = msg.channel
reactions = msg.reactions
stars = await get_star_ammount(reactions, msg)
star_dict = data.get_star(guild)
msg_dict = data.get_msg(guild)
stars_needed = data.get_data(guild)['min']

star_channel = guild.get_channel(
int(data.get_data(guild)['channel'])
)

if str(msg.id) in star_dict or str(msg.id) in msg_dict:
if str(msg.id) in star_dict:

other_post_id = star_dict[str(msg.id)]
other_msg = await star_channel.fetch_message(int(other_post_id))
other_reactions = other_msg.reactions
embed = other_msg.embeds[0]
bots_msg = False

else:
other_post_info = msg_dict[str(msg.id)]
other_post_id = other_post_info[0]
other_post_channel = other_post_info[1]
other_post_channel = guild.get_channel(int(other_post_channel))
other_msg = await other_post_channel.fetch_message(int(other_post_id))
other_reactions = other_msg.reactions
embed = msg.embeds[0]
bots_msg = True

stars = await get_star_ammount(
reactions,
msg,
other=other_reactions,
author=other_msg.author
)

embed.set_footer(text=f'⭐: {stars}')

if bots_msg:
await msg.edit(embed=embed)
user = other_msg.author

else:
user = author

await other_msg.edit(embed=embed)
await data.set_leaders(guild, leaderboard)
leaderboard[str(user.id)] += 1
elif author != bot.user:

stars = await get_star_ammount(reactions, msg)
if stars >= stars_needed:

user = author
image_found = False

for a in msg.attachments:
for n in image_types:

if n in a.url:
image_found = True
image_url = a.url

if image_found:
break
if not image_found:
links = findall(
r'''(?:(?:https?|ftp):\/\/|\b(?:[a-z\d]+\.))(?:(?:[^\s()<>]+|\((?:[^\s()<'
'>]+|(?:\([^\s()<>]+\)))?\))+(?:\((?:[^\s()<>]+|(?:\(?:[^\s()<>]+\)))?\)|['
'^\s`!()\[\]{};:'\".,<>?«»“”‘’]))?''',
msg.content
)

for a in links:
for n in image_types:

if n in a:
image_found = True
image_url = a

if image_found:
break

if image_found:
embed = get_embed(stars, msg, image_url)
else:
embed = get_embed(stars, msg)

if str(msg.id) not in data.get_star(guild):
if user.id in leaderboard:
leaderboard[str(user.id)] += stars

else:
leaderboard[str(user.id)] = stars

other_msg = await star_channel.send(embed=embed)
await other_msg.add_reaction('⭐')
msg_dict[str(other_msg.id)] = [str(msg.id), str(channel.id)]
star_dict[str(msg.id)] = str(other_msg.id)
await data.set_star(guild, star_dict)
await data.set_msg(guild, msg_dict)

else:
leaderboard[str(user.id)] += 1

await data.set_leaders(guild, leaderboard)
80 changes: 80 additions & 0 deletions Other/Starboard/Events/on_reaction_remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from re import sub
from Other.Starboard.utils import get_star_ammount


async def reaction_removed(reaction, user, bot, data):
msg = reaction.message
guild = msg.guild
if str(reaction) == '⭐':
leaderboard = data.get_leaders(guild)
msg = reaction.message
reactions = msg.reactions
stars = await get_star_ammount(reactions, msg)
star_dict = data.get_star(guild)
msg_dict = data.get_msg(guild)
stars_needed = data.get_data(guild)['min']

star_channel = guild.get_channel(
int(data.get_data(guild)['channel'])
)
if str(msg.id) in star_dict or str(msg.id) in msg_dict:
if str(msg.id) in star_dict:

other_post_id = star_dict[str(msg.id)]
other_msg = await star_channel.fetch_message(int(other_post_id))
other_reactions = other_msg.reactions
embed = other_msg.embeds[0]
user = msg.author
bots_msg = False

else:
other_post_info = msg_dict[str(msg.id)]
other_post_id = other_post_info[0]
other_post_channel = other_post_info[1]
other_post_channel = guild.get_channel(int(other_post_channel))
other_msg = await other_post_channel.fetch_message(int(other_post_id))
other_reactions = other_msg.reactions
embed = msg.embeds[0]
bots_msg = True
user = other_msg.author

stars = await get_star_ammount(
reactions,
msg,
other=other_reactions,
author=other_msg.author
)

embed.set_footer(text=f'⭐: {stars}')

if user != bot.user:
if bots_msg:
await msg.edit(embed=embed)

else:
await other_msg.edit(embed=embed)
lb_user_stars = leaderboard[str(user.id)]
lb_user_stars -= 1
leaderboard[str(user.id)] = lb_user_stars
if stars < stars_needed:

if bots_msg:
await msg.delete()
del msg_dict[str(msg.id)]
del star_dict[str(other_msg.id)]

else:
await other_msg.delete()
del msg_dict[str(other_msg.id)]
del star_dict[str(msg.id)]

lb_user_stars -= stars
if lb_user_stars <= 0:
del leaderboard[str(user.id)]
else:
leaderboard[str(user.id)] = lb_user_stars
await data.set_star(guild, star_dict)
await data.set_msg(guild, msg_dict)
if lb_user_stars <= 0:
del leaderboard[str(user.id)]
await data.set_leaders(guild, leaderboard)
Binary file added Other/Starboard/__pycache__/main.cpython-37.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion Other/Starboard/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ async def setmin(self, ctx, amount: int):
title='**Star Minumum**', description=desc, color=0x73ff00)
await ctx.send(embed=embed)

@commands.Cog.listener()
#@commands.Cog.listener()
async def on_command_error(self, ctx, Exception):
'''if isinstance(Exception, commands.errors.MissingPermissions):
desc = 'You do not have sufficent permissions to use this command.'
Expand Down
Loading

0 comments on commit b748283

Please sign in to comment.