Change database saving, and command reading to not create tasks each time
This commit is contained in:
parent
b897740e76
commit
e7c2cdceb7
7
bot.py
7
bot.py
|
@ -38,11 +38,6 @@ async def on_message(message):
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_command_completion(ctx):
|
async def on_command_completion(ctx):
|
||||||
# There's no reason to continue waiting for this to complete, so lets immediately launch this in a new future
|
|
||||||
bot.loop.create_task(process_command(ctx))
|
|
||||||
|
|
||||||
|
|
||||||
async def process_command(ctx):
|
|
||||||
author = ctx.message.author
|
author = ctx.message.author
|
||||||
server = ctx.message.guild
|
server = ctx.message.guild
|
||||||
command = ctx.command
|
command = ctx.command
|
||||||
|
@ -68,7 +63,7 @@ async def process_command(ctx):
|
||||||
command_usage['server_usage'] = total_server_usage
|
command_usage['server_usage'] = total_server_usage
|
||||||
|
|
||||||
# Save all the changes
|
# Save all the changes
|
||||||
bot.db.save('command_usage', command_usage)
|
await bot.db.save('command_usage', command_usage)
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
|
|
|
@ -58,11 +58,10 @@ class Administration:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'battles': msgs
|
'battles': msgs
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', update)
|
await self.bot.db.save('server_settings', update)
|
||||||
fmt = "I have just saved your new battle message, it will appear like this: \n\n*{}*".format(message)
|
fmt = "I have just saved your new battle message, it will appear like this: \n\n*{}*".format(message)
|
||||||
await ctx.send(fmt.format(loser=ctx.message.author.display_name, winner=ctx.message.guild.me.display_name))
|
await ctx.send(fmt.format(loser=ctx.message.author.display_name, winner=ctx.message.guild.me.display_name))
|
||||||
|
|
||||||
|
|
||||||
@battles.command(name='remove', aliases=['delete'])
|
@battles.command(name='remove', aliases=['delete'])
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@utils.custom_perms(manage_guild=True)
|
@utils.custom_perms(manage_guild=True)
|
||||||
|
@ -77,6 +76,7 @@ class Administration:
|
||||||
# Then let them know to respond with the number needed
|
# Then let them know to respond with the number needed
|
||||||
await ctx.send("Please respond with the number matching the battle message you want to remove")
|
await ctx.send("Please respond with the number matching the battle message you want to remove")
|
||||||
# The check to ensure it's in this channel...and what's provided is an int
|
# The check to ensure it's in this channel...and what's provided is an int
|
||||||
|
|
||||||
def check(m):
|
def check(m):
|
||||||
if m.author == ctx.message.author and m.channel == ctx.message.channel:
|
if m.author == ctx.message.author and m.channel == ctx.message.channel:
|
||||||
try:
|
try:
|
||||||
|
@ -107,10 +107,9 @@ class Administration:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'battles': msgs
|
'battles': msgs
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send("I have just removed that battle message")
|
await ctx.send("I have just removed that battle message")
|
||||||
|
|
||||||
|
|
||||||
@battles.command(name='default')
|
@battles.command(name='default')
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@utils.custom_perms(send_messages=True)
|
@utils.custom_perms(send_messages=True)
|
||||||
|
@ -130,7 +129,7 @@ class Administration:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'default_battles': setting
|
'default_battles': setting
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
fmt = "" if setting else "not "
|
fmt = "" if setting else "not "
|
||||||
await ctx.send("Default messages will {}be used as well as custom messages".format(fmt))
|
await ctx.send("Default messages will {}be used as well as custom messages".format(fmt))
|
||||||
|
|
||||||
|
@ -176,11 +175,10 @@ class Administration:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'hugs': msgs
|
'hugs': msgs
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', update)
|
await self.bot.db.save('server_settings', update)
|
||||||
fmt = "I have just saved your new hug message, it will appear like this: \n\n*{}*".format(message)
|
fmt = "I have just saved your new hug message, it will appear like this: \n\n*{}*".format(message)
|
||||||
await ctx.send(fmt.format(user=ctx.message.author.display_name))
|
await ctx.send(fmt.format(user=ctx.message.author.display_name))
|
||||||
|
|
||||||
|
|
||||||
@hugs.command(name='remove', aliases=['delete'])
|
@hugs.command(name='remove', aliases=['delete'])
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@utils.custom_perms(manage_guild=True)
|
@utils.custom_perms(manage_guild=True)
|
||||||
|
@ -195,6 +193,7 @@ class Administration:
|
||||||
# Then let them know to respond with the number needed
|
# Then let them know to respond with the number needed
|
||||||
await ctx.send("Please respond with the number matching the hug message you want to remove")
|
await ctx.send("Please respond with the number matching the hug message you want to remove")
|
||||||
# The check to ensure it's in this channel...and what's provided is an int
|
# The check to ensure it's in this channel...and what's provided is an int
|
||||||
|
|
||||||
def check(m):
|
def check(m):
|
||||||
if m.author == ctx.message.author and m.channel == ctx.message.channel:
|
if m.author == ctx.message.author and m.channel == ctx.message.channel:
|
||||||
try:
|
try:
|
||||||
|
@ -225,10 +224,9 @@ class Administration:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'hugs': msgs
|
'hugs': msgs
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send("I have just removed that hug message")
|
await ctx.send("I have just removed that hug message")
|
||||||
|
|
||||||
|
|
||||||
@hugs.command(name='default')
|
@hugs.command(name='default')
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@utils.custom_perms(send_messages=True)
|
@utils.custom_perms(send_messages=True)
|
||||||
|
@ -248,7 +246,7 @@ class Administration:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'default_hugs': setting
|
'default_hugs': setting
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
fmt = "" if setting else "not "
|
fmt = "" if setting else "not "
|
||||||
await ctx.send("Default messages will {}be used as well as custom messages".format(fmt))
|
await ctx.send("Default messages will {}be used as well as custom messages".format(fmt))
|
||||||
|
|
||||||
|
@ -269,7 +267,7 @@ class Administration:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'birthdays_allowed': allowed
|
'birthdays_allowed': allowed
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
fmt = "The birthday announcements have just been turned {}".format("on" if allowed else "off")
|
fmt = "The birthday announcements have just been turned {}".format("on" if allowed else "off")
|
||||||
await ctx.send(fmt)
|
await ctx.send(fmt)
|
||||||
|
|
||||||
|
@ -290,7 +288,7 @@ class Administration:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'colour_roles_allowed': allowed
|
'colour_roles_allowed': allowed
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
fmt = "The ability to use colour roles have just been turned {}".format("on" if allowed else "off")
|
fmt = "The ability to use colour roles have just been turned {}".format("on" if allowed else "off")
|
||||||
await ctx.send(fmt)
|
await ctx.send(fmt)
|
||||||
|
|
||||||
|
@ -311,7 +309,7 @@ class Administration:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'playlists_allowed': allowed
|
'playlists_allowed': allowed
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
fmt = "The ability to use playlists has just been turned {}".format("on" if allowed else "off")
|
fmt = "The ability to use playlists has just been turned {}".format("on" if allowed else "off")
|
||||||
await ctx.send(fmt)
|
await ctx.send(fmt)
|
||||||
|
|
||||||
|
@ -557,7 +555,7 @@ class Administration:
|
||||||
'to': to
|
'to': to
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', update)
|
await self.bot.db.save('server_settings', update)
|
||||||
elif from_entry:
|
elif from_entry:
|
||||||
restrictions = self.bot.db.load('server_settings', key=ctx.message.guild.id, pluck='restrictions') or {}
|
restrictions = self.bot.db.load('server_settings', key=ctx.message.guild.id, pluck='restrictions') or {}
|
||||||
_from = restrictions.get('from', [])
|
_from = restrictions.get('from', [])
|
||||||
|
@ -569,7 +567,7 @@ class Administration:
|
||||||
'from': _from
|
'from': _from
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', update)
|
await self.bot.db.save('server_settings', update)
|
||||||
elif overwrites:
|
elif overwrites:
|
||||||
channel = overwrites.pop('channel')
|
channel = overwrites.pop('channel')
|
||||||
for target, setting in overwrites.items():
|
for target, setting in overwrites.items():
|
||||||
|
@ -644,7 +642,7 @@ class Administration:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'restrictions': restrictions
|
'restrictions': restrictions
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
# If this isn't a blacklist/whitelist, then we are attempting to remove an overwrite
|
# If this isn't a blacklist/whitelist, then we are attempting to remove an overwrite
|
||||||
else:
|
else:
|
||||||
# Get the source and destination based on whatever order is provided
|
# Get the source and destination based on whatever order is provided
|
||||||
|
@ -743,7 +741,7 @@ class Administration:
|
||||||
'server_id': str(key)
|
'server_id': str(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send(fmt)
|
await ctx.send(fmt)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
|
@ -792,7 +790,7 @@ class Administration:
|
||||||
'server_id': str(key)
|
'server_id': str(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send(fmt)
|
await ctx.send(fmt)
|
||||||
|
|
||||||
@commands.command(aliases=['notifications'])
|
@commands.command(aliases=['notifications'])
|
||||||
|
@ -814,7 +812,7 @@ class Administration:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send("I have just changed this server's default 'notifications' channel"
|
await ctx.send("I have just changed this server's default 'notifications' channel"
|
||||||
"\nAll notifications will now default to `{}`".format(channel))
|
"\nAll notifications will now default to `{}`".format(channel))
|
||||||
|
|
||||||
|
@ -838,7 +836,7 @@ class Administration:
|
||||||
'join_leave': on_off
|
'join_leave': on_off
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
fmt = "notify" if on_off else "not notify"
|
fmt = "notify" if on_off else "not notify"
|
||||||
await ctx.send("This server will now {} if someone has joined or left".format(fmt))
|
await ctx.send("This server will now {} if someone has joined or left".format(fmt))
|
||||||
|
|
||||||
|
@ -858,7 +856,7 @@ class Administration:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"I have just changed this server's welcome/goodbye notifications channel to {}".format(channel.name))
|
"I have just changed this server's welcome/goodbye notifications channel to {}".format(channel.name))
|
||||||
|
|
||||||
|
@ -882,7 +880,7 @@ class Administration:
|
||||||
await ctx.send("Illegal content in {} message".format(parent))
|
await ctx.send("Illegal content in {} message".format(parent))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
test_keys = msg.format(member='test', server='test')
|
msg.format(member='test', server='test')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
await ctx.send("Illegal keyword in {0} message. Please use `{1.prefix}help {0} message` "
|
await ctx.send("Illegal keyword in {0} message. Please use `{1.prefix}help {0} message` "
|
||||||
"for what keywords can be used".format(parent, ctx))
|
"for what keywords can be used".format(parent, ctx))
|
||||||
|
@ -891,7 +889,7 @@ class Administration:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
parent + '_message': msg
|
parent + '_message': msg
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send("I have just updated your {} message".format(parent))
|
await ctx.send("I have just updated your {} message".format(parent))
|
||||||
|
|
||||||
@commands.group()
|
@commands.group()
|
||||||
|
@ -923,7 +921,7 @@ class Administration:
|
||||||
'nsfw_channels': channels
|
'nsfw_channels': channels
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
|
|
||||||
await ctx.send("This channel has just been registered as 'nsfw'! Have fun you naughties ;)")
|
await ctx.send("This channel has just been registered as 'nsfw'! Have fun you naughties ;)")
|
||||||
|
|
||||||
|
@ -949,7 +947,7 @@ class Administration:
|
||||||
'server_id': key,
|
'server_id': key,
|
||||||
'nsfw_channels': channels
|
'nsfw_channels': channels
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send("This channel has just been unregistered as a nsfw channel")
|
await ctx.send("This channel has just been unregistered as a nsfw channel")
|
||||||
else:
|
else:
|
||||||
await ctx.send("This channel is not registerred as a nsfw channel!")
|
await ctx.send("This channel is not registerred as a nsfw channel!")
|
||||||
|
@ -1086,7 +1084,7 @@ class Administration:
|
||||||
'permissions': {cmd.qualified_name: perm_value}
|
'permissions': {cmd.qualified_name: perm_value}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
|
|
||||||
await ctx.send("I have just added your custom permissions; "
|
await ctx.send("I have just added your custom permissions; "
|
||||||
"you now need to have `{}` permissions to use the command `{}`".format(permissions, command))
|
"you now need to have `{}` permissions to use the command `{}`".format(permissions, command))
|
||||||
|
@ -1113,7 +1111,7 @@ class Administration:
|
||||||
'permissions': {cmd.qualified_name: None}
|
'permissions': {cmd.qualified_name: None}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send("I have just removed the custom permissions for {}!".format(cmd))
|
await ctx.send("I have just removed the custom permissions for {}!".format(cmd))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
|
@ -1137,7 +1135,7 @@ class Administration:
|
||||||
'prefix': prefix
|
'prefix': prefix
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
|
|
||||||
if prefix is None:
|
if prefix is None:
|
||||||
fmt = "I have just cleared your custom prefix, the default prefix will have to be used now"
|
fmt = "I have just cleared your custom prefix, the default prefix will have to be used now"
|
||||||
|
@ -1194,7 +1192,7 @@ class Administration:
|
||||||
'rules': rules
|
'rules': rules
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
|
|
||||||
await ctx.send("I have just saved your new rule, use the rules command to view this server's current rules")
|
await ctx.send("I have just saved your new rule, use the rules command to view this server's current rules")
|
||||||
|
|
||||||
|
@ -1216,7 +1214,7 @@ class Administration:
|
||||||
'server_id': key,
|
'server_id': key,
|
||||||
'rules': rules
|
'rules': rules
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send("I have just removed that rule from your list of rules!")
|
await ctx.send("I have just removed that rule from your list of rules!")
|
||||||
except IndexError:
|
except IndexError:
|
||||||
await ctx.send("That is not a valid rule number, try running the command again.")
|
await ctx.send("That is not a valid rule number, try running the command again.")
|
||||||
|
|
|
@ -154,7 +154,7 @@ class Birthday:
|
||||||
'member_id': str(ctx.message.author.id),
|
'member_id': str(ctx.message.author.id),
|
||||||
'birthday': date
|
'birthday': date
|
||||||
}
|
}
|
||||||
self.bot.db.save('birthdays', entry)
|
await self.bot.db.save('birthdays', entry)
|
||||||
await ctx.send("I have just saved your birthday as {}".format(date))
|
await ctx.send("I have just saved your birthday as {}".format(date))
|
||||||
|
|
||||||
@birthday.command(name='remove')
|
@birthday.command(name='remove')
|
||||||
|
@ -169,7 +169,7 @@ class Birthday:
|
||||||
'member_id': str(ctx.message.author.id),
|
'member_id': str(ctx.message.author.id),
|
||||||
'birthday': None
|
'birthday': None
|
||||||
}
|
}
|
||||||
self.bot.db.save('birthdays', entry)
|
await self.bot.db.save('birthdays', entry)
|
||||||
await ctx.send("I don't know your birthday anymore :(")
|
await ctx.send("I don't know your birthday anymore :(")
|
||||||
|
|
||||||
@birthday.command(name='alerts', aliases=['notifications'])
|
@birthday.command(name='alerts', aliases=['notifications'])
|
||||||
|
@ -188,7 +188,7 @@ class Birthday:
|
||||||
'birthday': str(channel.id)
|
'birthday': str(channel.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await 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))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,7 @@ class Interaction:
|
||||||
str(boopee.id): amount
|
str(boopee.id): amount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.bot.db.save('boops', entry)
|
await self.bot.db.save('boops', entry)
|
||||||
|
|
||||||
fmt = "{0.mention} has just booped {1.mention}{3}! That's {2} times now!"
|
fmt = "{0.mention} has just booped {1.mention}{3}! That's {2} times now!"
|
||||||
await ctx.send(fmt.format(booper, boopee, amount, message))
|
await ctx.send(fmt.format(booper, boopee, amount, message))
|
||||||
|
|
|
@ -107,7 +107,7 @@ class Osu:
|
||||||
'osu_username': user.username
|
'osu_username': user.username
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('osu', entry)
|
await self.bot.db.save('osu', entry)
|
||||||
|
|
||||||
await ctx.send("I have just saved your Osu user {}".format(author.display_name))
|
await ctx.send("I have just saved your Osu user {}".format(author.display_name))
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ class Overwatch:
|
||||||
'battletag': bt
|
'battletag': bt
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('overwatch', entry)
|
await 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(name="delete", aliases=['remove'])
|
@ow.command(name="delete", aliases=['remove'])
|
||||||
|
@ -134,7 +134,7 @@ class Overwatch:
|
||||||
'member_id': str(ctx.message.author.id),
|
'member_id': str(ctx.message.author.id),
|
||||||
'battletag': None
|
'battletag': None
|
||||||
}
|
}
|
||||||
self.bot.db.save('overwatch', entry)
|
await self.bot.db.save('overwatch', entry)
|
||||||
await ctx.send("I no longer have your battletag saved {}".format(ctx.message.author.mention))
|
await ctx.send("I no longer have your battletag saved {}".format(ctx.message.author.mention))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,11 @@ class Picarto:
|
||||||
# If they're currently online, but saved as not then we'll let servers know they are now online
|
# If they're currently online, but saved as not then we'll let servers know they are now online
|
||||||
if online and data['live'] == 0:
|
if online and data['live'] == 0:
|
||||||
msg = "{member.display_name} has just gone live!"
|
msg = "{member.display_name} has just gone live!"
|
||||||
self.bot.db.save('picarto', {'live': 1, 'member_id': str(m_id)})
|
await self.bot.db.save('picarto', {'live': 1, 'member_id': str(m_id)})
|
||||||
# Otherwise our notification will say they've gone offline
|
# Otherwise our notification will say they've gone offline
|
||||||
elif not online and data['live'] == 1:
|
elif not online and data['live'] == 1:
|
||||||
msg = "{member.display_name} has just gone offline!"
|
msg = "{member.display_name} has just gone offline!"
|
||||||
self.bot.db.save('picarto', {'live': 0, 'member_id': str(m_id)})
|
await self.bot.db.save('picarto', {'live': 0, 'member_id': str(m_id)})
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ class Picarto:
|
||||||
'live': 0,
|
'live': 0,
|
||||||
'member_id': key
|
'member_id': key
|
||||||
}
|
}
|
||||||
self.bot.db.save('picarto', entry)
|
await self.bot.db.save('picarto', entry)
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"I have just saved your Picarto URL {}, this guild will now be notified when you go live".format(
|
"I have just saved your Picarto URL {}, this guild will now be notified when you go live".format(
|
||||||
ctx.message.author.mention))
|
ctx.message.author.mention))
|
||||||
|
@ -219,7 +219,7 @@ class Picarto:
|
||||||
'member_id': str(ctx.message.author.id)
|
'member_id': str(ctx.message.author.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('picarto', entry)
|
await self.bot.db.save('picarto', entry)
|
||||||
await ctx.send("I am no longer saving your picarto URL {}".format(ctx.message.author.mention))
|
await ctx.send("I am no longer saving your picarto URL {}".format(ctx.message.author.mention))
|
||||||
else:
|
else:
|
||||||
await ctx.send("I cannot remove something that I don't have (you've never saved your Picarto URL)")
|
await ctx.send("I cannot remove something that I don't have (you've never saved your Picarto URL)")
|
||||||
|
@ -240,7 +240,7 @@ class Picarto:
|
||||||
'picarto': str(channel.id)
|
'picarto': str(channel.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send("All Picarto notifications will now go to {}".format(channel.mention))
|
await ctx.send("All Picarto notifications will now go to {}".format(channel.mention))
|
||||||
|
|
||||||
@picarto.group(invoke_without_command=True)
|
@picarto.group(invoke_without_command=True)
|
||||||
|
@ -269,7 +269,7 @@ class Picarto:
|
||||||
'member_id': key,
|
'member_id': key,
|
||||||
'servers': servers
|
'servers': servers
|
||||||
}
|
}
|
||||||
self.bot.db.save('picarto', entry)
|
await self.bot.db.save('picarto', entry)
|
||||||
await ctx.send("This server will now be notified if you go live")
|
await ctx.send("This server will now be notified if you go live")
|
||||||
|
|
||||||
@notify.command(name='on', aliases=['start,yes'])
|
@notify.command(name='on', aliases=['start,yes'])
|
||||||
|
@ -288,7 +288,7 @@ class Picarto:
|
||||||
'member_id': key,
|
'member_id': key,
|
||||||
'notifications_on': 1
|
'notifications_on': 1
|
||||||
}
|
}
|
||||||
self.bot.db.save('picarto', entry)
|
await self.bot.db.save('picarto', entry)
|
||||||
await ctx.send("I will notify if you go live {}, you'll get a bajillion followers I promise c:".format(
|
await ctx.send("I will notify if you go live {}, you'll get a bajillion followers I promise c:".format(
|
||||||
ctx.message.author.mention))
|
ctx.message.author.mention))
|
||||||
else:
|
else:
|
||||||
|
@ -310,7 +310,7 @@ class Picarto:
|
||||||
'member_id': key,
|
'member_id': key,
|
||||||
'notifications_on': 0
|
'notifications_on': 0
|
||||||
}
|
}
|
||||||
self.bot.db.save('picarto', entry)
|
await self.bot.db.save('picarto', entry)
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"I will not notify if you go live anymore {}, "
|
"I will not notify if you go live anymore {}, "
|
||||||
"are you going to stream some lewd stuff you don't want people to see?~".format(
|
"are you going to stream some lewd stuff you don't want people to see?~".format(
|
||||||
|
|
|
@ -94,7 +94,7 @@ class Raffle:
|
||||||
'server_id': raffle['server_id'],
|
'server_id': raffle['server_id'],
|
||||||
'raffles': raffle['raffles']
|
'raffles': raffle['raffles']
|
||||||
}
|
}
|
||||||
self.bot.db.save('raffles', entry)
|
await self.bot.db.save('raffles', entry)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
|
@ -157,7 +157,7 @@ class Raffle:
|
||||||
'raffles': raffles,
|
'raffles': raffles,
|
||||||
'server_id': key
|
'server_id': key
|
||||||
}
|
}
|
||||||
self.bot.db.save('raffles', update)
|
await self.bot.db.save('raffles', update)
|
||||||
await ctx.send("{} you have just entered the raffle!".format(author.mention))
|
await ctx.send("{} you have just entered the raffle!".format(author.mention))
|
||||||
# Otherwise, make sure the author gave a valid raffle_id
|
# Otherwise, make sure the author gave a valid raffle_id
|
||||||
elif raffle_id in range(raffle_count):
|
elif raffle_id in range(raffle_count):
|
||||||
|
@ -175,12 +175,13 @@ class Raffle:
|
||||||
'raffles': raffles,
|
'raffles': raffles,
|
||||||
'server_id': key
|
'server_id': key
|
||||||
}
|
}
|
||||||
self.bot.db.save('raffles', update)
|
await self.bot.db.save('raffles', update)
|
||||||
await ctx.send("{} you have just entered the raffle!".format(author.mention))
|
await ctx.send("{} you have just entered the raffle!".format(author.mention))
|
||||||
else:
|
else:
|
||||||
fmt = "Please provide a valid raffle ID, as there are more than one setup on the server! " \
|
fmt = "Please provide a valid raffle ID, as there are more than one setup on the server! " \
|
||||||
"There are currently `{}` raffles running, use {}raffles to view the current running raffles".format(
|
"There are currently `{}` raffles running, use {}raffles to view the current running raffles".format(
|
||||||
raffle_count, ctx.prefix)
|
raffle_count, ctx.prefix
|
||||||
|
)
|
||||||
await ctx.send(fmt)
|
await ctx.send(fmt)
|
||||||
|
|
||||||
@raffle.command(name='create', aliases=['start', 'begin', 'add'])
|
@raffle.command(name='create', aliases=['start', 'begin', 'add'])
|
||||||
|
@ -275,7 +276,7 @@ class Raffle:
|
||||||
'server_id': str(server.id),
|
'server_id': str(server.id),
|
||||||
'raffles': raffles
|
'raffles': raffles
|
||||||
}
|
}
|
||||||
self.bot.db.save('raffles', update)
|
await self.bot.db.save('raffles', update)
|
||||||
await ctx.send("I have just saved your new raffle!")
|
await ctx.send("I have just saved your new raffle!")
|
||||||
|
|
||||||
@raffle.command(name='alerts')
|
@raffle.command(name='alerts')
|
||||||
|
@ -294,7 +295,7 @@ class Raffle:
|
||||||
'raffle': str(channel.id)
|
'raffle': str(channel.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send("All raffle notifications will now go to {}".format(channel.mention))
|
await ctx.send("All raffle notifications will now go to {}".format(channel.mention))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -452,7 +452,7 @@ class Roles:
|
||||||
'self_assignable_roles': self_assignable_roles
|
'self_assignable_roles': self_assignable_roles
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
|
|
||||||
if len(roles) == 1:
|
if len(roles) == 1:
|
||||||
fmt = "Successfully added {} as a self-assignable role".format(role[0].name)
|
fmt = "Successfully added {} as a self-assignable role".format(role[0].name)
|
||||||
|
@ -522,7 +522,7 @@ class Roles:
|
||||||
'self_assignable_roles': self_assignable_roles,
|
'self_assignable_roles': self_assignable_roles,
|
||||||
'server_id': key
|
'server_id': key
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', update)
|
await self.bot.db.save('server_settings', update)
|
||||||
await ctx.send(fmt)
|
await ctx.send(fmt)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ class Tags:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'tags': tags
|
'tags': tags
|
||||||
}
|
}
|
||||||
self.bot.db.save('tags', entry)
|
await self.bot.db.save('tags', entry)
|
||||||
await ctx.send("I have just setup a new tag for this server! You can call your tag with {}".format(trigger))
|
await ctx.send("I have just setup a new tag for this server! You can call your tag with {}".format(trigger))
|
||||||
|
|
||||||
@tag.command(name='edit')
|
@tag.command(name='edit')
|
||||||
|
@ -186,7 +186,7 @@ class Tags:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'tags': tags
|
'tags': tags
|
||||||
}
|
}
|
||||||
self.bot.db.save('tags', entry)
|
await self.bot.db.save('tags', entry)
|
||||||
await ctx.send("Alright, the tag {} has been updated".format(tag))
|
await ctx.send("Alright, the tag {} has been updated".format(tag))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -217,7 +217,7 @@ class Tags:
|
||||||
'server_id': str(ctx.message.guild.id),
|
'server_id': str(ctx.message.guild.id),
|
||||||
'tags': tags
|
'tags': tags
|
||||||
}
|
}
|
||||||
self.bot.db.save('tags', entry)
|
await self.bot.db.save('tags', entry)
|
||||||
await ctx.send("I have just removed the tag {}".format(tag))
|
await ctx.send("I have just removed the tag {}".format(tag))
|
||||||
else:
|
else:
|
||||||
await ctx.send("You don't own that tag! You can't remove it!")
|
await ctx.send("You don't own that tag! You can't remove it!")
|
||||||
|
|
|
@ -104,12 +104,12 @@ class Twitch:
|
||||||
# If they're currently online, but saved as not then we'll let servers know they are now online
|
# If they're currently online, but saved as not then we'll let servers know they are now online
|
||||||
if embed and data['live'] == 0:
|
if embed and data['live'] == 0:
|
||||||
msg = "{member.display_name} has just gone live!"
|
msg = "{member.display_name} has just gone live!"
|
||||||
self.bot.db.save('twitch', {'live': 1, 'member_id': str(m_id)})
|
await self.bot.db.save('twitch', {'live': 1, 'member_id': str(m_id)})
|
||||||
# Otherwise our notification will say they've gone offline
|
# Otherwise our notification will say they've gone offline
|
||||||
elif not embed and data['live'] == 1:
|
elif not embed and data['live'] == 1:
|
||||||
msg = "{member.display_name} has just gone offline!"
|
msg = "{member.display_name} has just gone offline!"
|
||||||
embed = await self.offline_embed(url)
|
embed = await self.offline_embed(url)
|
||||||
self.bot.db.save('twitch', {'live': 0, 'member_id': str(m_id)})
|
await self.bot.db.save('twitch', {'live': 0, 'member_id': str(m_id)})
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ class Twitch:
|
||||||
'live': 0,
|
'live': 0,
|
||||||
'member_id': key
|
'member_id': key
|
||||||
}
|
}
|
||||||
self.bot.db.save('twitch', entry)
|
await self.bot.db.save('twitch', entry)
|
||||||
await ctx.send("I have just saved your twitch url {}".format(ctx.message.author.mention))
|
await ctx.send("I have just saved your twitch url {}".format(ctx.message.author.mention))
|
||||||
|
|
||||||
@twitch.command(name='remove', aliases=['delete'])
|
@twitch.command(name='remove', aliases=['delete'])
|
||||||
|
@ -231,7 +231,7 @@ class Twitch:
|
||||||
'member_id': str(ctx.message.author.id)
|
'member_id': str(ctx.message.author.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.db.save('twitch', entry)
|
await self.bot.db.save('twitch', entry)
|
||||||
await ctx.send("I am no longer saving your twitch URL {}".format(ctx.message.author.mention))
|
await ctx.send("I am no longer saving your twitch URL {}".format(ctx.message.author.mention))
|
||||||
|
|
||||||
@twitch.command(name='alerts', aliases=['notifications'])
|
@twitch.command(name='alerts', aliases=['notifications'])
|
||||||
|
@ -250,7 +250,7 @@ class Twitch:
|
||||||
'twitch': str(channel.id)
|
'twitch': str(channel.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.bot.db.save('server_settings', entry)
|
await self.bot.db.save('server_settings', entry)
|
||||||
await ctx.send("All Twitch notifications will now go to {}".format(channel.mention))
|
await ctx.send("All Twitch notifications will now go to {}".format(channel.mention))
|
||||||
|
|
||||||
@twitch.group(invoke_without_command=True)
|
@twitch.group(invoke_without_command=True)
|
||||||
|
@ -279,7 +279,7 @@ class Twitch:
|
||||||
'member_id': key,
|
'member_id': key,
|
||||||
'servers': servers
|
'servers': servers
|
||||||
}
|
}
|
||||||
self.bot.db.save('twitch', entry)
|
await self.bot.db.save('twitch', entry)
|
||||||
await ctx.send("This server will now be notified if you go live")
|
await ctx.send("This server will now be notified if you go live")
|
||||||
|
|
||||||
@notify.command(name='on', aliases=['start,yes'])
|
@notify.command(name='on', aliases=['start,yes'])
|
||||||
|
@ -298,7 +298,7 @@ class Twitch:
|
||||||
'member_id': key,
|
'member_id': key,
|
||||||
'notifications_on': 1
|
'notifications_on': 1
|
||||||
}
|
}
|
||||||
self.bot.db.save('twitch', entry)
|
await self.bot.db.save('twitch', entry)
|
||||||
await ctx.send("I will notify if you go live {}, you'll get a bajillion followers I promise c:".format(
|
await ctx.send("I will notify if you go live {}, you'll get a bajillion followers I promise c:".format(
|
||||||
ctx.message.author.mention))
|
ctx.message.author.mention))
|
||||||
else:
|
else:
|
||||||
|
@ -320,7 +320,7 @@ class Twitch:
|
||||||
'member_id': key,
|
'member_id': key,
|
||||||
'notifications_on': 0
|
'notifications_on': 0
|
||||||
}
|
}
|
||||||
self.bot.db.save('twitch', entry)
|
await self.bot.db.save('twitch', entry)
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"I will not notify if you go live anymore {}, "
|
"I will not notify if you go live anymore {}, "
|
||||||
"are you going to stream some lewd stuff you don't want people to see?~".format(
|
"are you going to stream some lewd stuff you don't want people to see?~".format(
|
||||||
|
|
|
@ -52,6 +52,7 @@ class Cache:
|
||||||
if key is None and table_filter is None:
|
if key is None and table_filter is None:
|
||||||
return self.values
|
return self.values
|
||||||
elif key:
|
elif key:
|
||||||
|
key = str(key)
|
||||||
for value in self.values:
|
for value in self.values:
|
||||||
if value[self.key] == key:
|
if value[self.key] == key:
|
||||||
if pluck:
|
if pluck:
|
||||||
|
@ -94,11 +95,11 @@ class DB:
|
||||||
await conn.close()
|
await conn.close()
|
||||||
return cursor
|
return cursor
|
||||||
|
|
||||||
def save(self, table, content):
|
# def save(self, table, content):
|
||||||
"""A synchronous task to throw saving content into a task"""
|
# """A synchronous task to throw saving content into a task"""
|
||||||
self.loop.create_task(self._save(table, content))
|
# self.loop.create_task(self._save(table, content))
|
||||||
|
|
||||||
async def _save(self, table, content):
|
async def save(self, table, content):
|
||||||
"""Saves data in the table"""
|
"""Saves data in the table"""
|
||||||
|
|
||||||
index = await self.query(r.table(table).info())
|
index = await self.query(r.table(table).info())
|
||||||
|
|
|
@ -184,5 +184,5 @@ async def update_records(key, db, winner, loser):
|
||||||
winner_stats = {'wins': winner_wins, 'losses': winner_losses, 'rating': winner_rating, 'member_id': str(winner.id)}
|
winner_stats = {'wins': winner_wins, 'losses': winner_losses, 'rating': winner_rating, 'member_id': str(winner.id)}
|
||||||
loser_stats = {'wins': loser_wins, 'losses': loser_losses, 'rating': loser_rating, 'member_id': str(loser.id)}
|
loser_stats = {'wins': loser_wins, 'losses': loser_losses, 'rating': loser_rating, 'member_id': str(loser.id)}
|
||||||
|
|
||||||
db.save(key, winner_stats)
|
await db.save(key, winner_stats)
|
||||||
db.save(key, loser_stats)
|
await db.save(key, loser_stats)
|
||||||
|
|
Loading…
Reference in a new issue