1
0
Fork 0
mirror of synced 2024-06-26 18:21:15 +12:00

Merge branch 'rewrite' of https://github.com/Phxntxm/Bonfire into rewrite

This commit is contained in:
Phxntxm 2017-07-22 16:43:05 -05:00
commit 7964be7adb
7 changed files with 359 additions and 357 deletions

View file

@ -21,7 +21,7 @@ class Administration:
"""Turns on/off the birthday announcements in this server """Turns on/off the birthday announcements in this server
EXAMPLE: !allowbirthdays on EXAMPLE: !allowbirthdays on
RESULT: Playlists can now be used""" RESULT: Birthdays will now be announced"""
if setting.lower() in ['on', 'yes', 'true']: if setting.lower() in ['on', 'yes', 'true']:
allowed = True allowed = True
else: else:

View file

@ -1,12 +1,13 @@
import discord import discord
import pendulum import pendulum
import asyncio
from pendulum.parsing.exceptions import ParserError from pendulum.parsing.exceptions import ParserError
from discord.ext import commands from discord.ext import commands
from . import utils from . import utils
class Birthday:
class Birthday:
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
self.bot.loop.create_task(self.birthday_task()) self.bot.loop.create_task(self.birthday_task())
@ -47,20 +48,21 @@ class Birthday:
tfilter = {'birthdays_allowed': True} tfilter = {'birthdays_allowed': True}
servers = await self.bot.db.actual_load('server_settings', table_filter=tfilter) servers = await self.bot.db.actual_load('server_settings', table_filter=tfilter)
for s in servers: for s in servers:
server = bot.get_guild(int(s['server_id'])) server = self.bot.get_guild(int(s['server_id']))
if not server: if not server:
continue continue
bds = self.get_birthdays_for_server(server, today=True) bds = self.get_birthdays_for_server(server, today=True)
for bd in bds: for bd in bds:
# Set our default to either the one set, or the default channel of the server # Set our default to either the one set, or the default channel of the server
default_channel_id = servers.get('notifications', {}).get('default') or guild.id default_channel_id = s.get('notifications', {}).get('default') or server.id
# If it is has been overriden by picarto notifications setting, use this # If it is has been overriden by picarto notifications setting, use this
channel_id = servers.get('notifications', {}).get('birthdays') or default_channel_id channel_id = s.get('notifications', {}).get('birthday') or default_channel_id
# Now get the channel based on that ID # Now get the channel based on that ID
channel = server.get_channel(int(channel_id)) or server.default_channel channel = server.get_channel(int(channel_id)) or server.default_channel
try: try:
await channel.send("It is {}'s birthday today! Wish them a happy birthday! \N{SHORTCAKE}".format(member.mention)) await channel.send("It is {}'s birthday today! "
"Wish them a happy birthday! \N{SHORTCAKE}".format(bd['member'].mention))
except (discord.Forbidden, discord.HTTPException): except (discord.Forbidden, discord.HTTPException):
pass pass
@ -92,7 +94,6 @@ class Birthday:
except utils.CannotPaginate as e: except utils.CannotPaginate as e:
await ctx.send(str(e)) await ctx.send(str(e))
@birthday.command(name='add') @birthday.command(name='add')
@utils.custom_perms(send_messages=True) @utils.custom_perms(send_messages=True)
@utils.check_restricted() @utils.check_restricted()
@ -150,5 +151,6 @@ class Birthday:
self.bot.db.save('server_settings', entry) self.bot.db.save('server_settings', entry)
await ctx.send("All birthday notifications will now go to {}".format(channel.mention)) await ctx.send("All birthday notifications will now go to {}".format(channel.mention))
def setup(bot): def setup(bot):
bot.add_cog(Birthday(bot)) bot.add_cog(Birthday(bot))

View file

@ -186,7 +186,7 @@ class Miscallaneous:
embed.set_author(name=str(self.bot.owner), icon_url=self.bot.owner.avatar_url) embed.set_author(name=str(self.bot.owner), icon_url=self.bot.owner.avatar_url)
# Setup the process statistics # Setup the process statistics
name = "Process stats" name = "Process statistics"
value = "" value = ""
memory_usage = self.process.memory_full_info().uss / 1024 ** 2 memory_usage = self.process.memory_full_info().uss / 1024 ** 2
@ -198,7 +198,7 @@ class Miscallaneous:
embed.add_field(name=name, value=value, inline=False) embed.add_field(name=name, value=value, inline=False)
# Setup the user and guild statistics # Setup the user and guild statistics
name = "User/Guild stats" name = "User/Guild statistics"
value = "" value = ""
value += "Channels: {}".format(len(list(self.bot.get_all_channels()))) value += "Channels: {}".format(len(list(self.bot.get_all_channels())))

View file

@ -89,7 +89,7 @@ class Overwatch:
fmt = "\n".join("{}: {}".format(k, r) for k, r in output_data) fmt = "\n".join("{}: {}".format(k, r) for k, r in output_data)
await ctx.send("Overwatch stats for {}: ```py\n{}```".format(user.name, fmt)) await ctx.send("Overwatch stats for {}: ```py\n{}```".format(user.name, fmt))
@ow.command(pass_context=True, name="add") @ow.command(name="add")
@utils.custom_perms(send_messages=True) @utils.custom_perms(send_messages=True)
@utils.check_restricted() @utils.check_restricted()
async def add(self, ctx, bt: str): async def add(self, ctx, bt: str):
@ -122,7 +122,7 @@ class Overwatch:
self.bot.db.save('overwatch', entry) self.bot.db.save('overwatch', entry)
await ctx.send("I have just saved your battletag {}".format(ctx.message.author.mention)) await ctx.send("I have just saved your battletag {}".format(ctx.message.author.mention))
@ow.command(pass_context=True, name="delete", aliases=['remove']) @ow.command(name="delete", aliases=['remove'])
@utils.custom_perms(send_messages=True) @utils.custom_perms(send_messages=True)
@utils.check_restricted() @utils.check_restricted()
async def delete(self, ctx): async def delete(self, ctx):

View file

@ -70,7 +70,7 @@ class Polls:
if poll: if poll:
await poll.remove_other_reaction(reaction, user) await poll.remove_other_reaction(reaction, user)
@commands.command(pass_context=True) @commands.command()
@commands.guild_only() @commands.guild_only()
@utils.custom_perms(send_messages=True) @utils.custom_perms(send_messages=True)
@utils.check_restricted() @utils.check_restricted()

View file

@ -183,7 +183,7 @@ class Raffle:
raffle_count, ctx.prefix) raffle_count, ctx.prefix)
await ctx.send(fmt) await ctx.send(fmt)
@raffle.command(pass_context=True, name='create', aliases=['start', 'begin', 'add']) @raffle.command(name='create', aliases=['start', 'begin', 'add'])
@commands.guild_only() @commands.guild_only()
@utils.custom_perms(kick_members=True) @utils.custom_perms(kick_members=True)
@utils.check_restricted() @utils.check_restricted()

View file

@ -94,10 +94,10 @@ class Stats:
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.group(pass_context=False) @commands.group()
@utils.custom_perms(send_messages=True) @utils.custom_perms(send_messages=True)
@utils.check_restricted() @utils.check_restricted()
async def command(self): async def command(self, ctx):
pass pass
@command.command(name="stats") @command.command(name="stats")