Stopped trying to pull from a one indexed list, as we no longer use that in key'd tables
This commit is contained in:
parent
7a3e7afe33
commit
58eb623a1a
3
bot.py
3
bot.py
|
@ -51,8 +51,7 @@ async def process_command(ctx):
|
||||||
command_usage = await utils.get_content('command_usage', key=command.qualified_name)
|
command_usage = await utils.get_content('command_usage', key=command.qualified_name)
|
||||||
if command_usage is None:
|
if command_usage is None:
|
||||||
command_usage = {'command': command.qualified_name}
|
command_usage = {'command': command.qualified_name}
|
||||||
else:
|
|
||||||
command_usage = command_usage[0]
|
|
||||||
# Add one to the total usage for this command, basing it off 0 to start with (obviously)
|
# Add one to the total usage for this command, basing it off 0 to start with (obviously)
|
||||||
total_usage = command_usage.get('total_usage', 0) + 1
|
total_usage = command_usage.get('total_usage', 0) + 1
|
||||||
command_usage['total_usage'] = total_usage
|
command_usage['total_usage'] = total_usage
|
||||||
|
|
|
@ -109,8 +109,8 @@ class Core:
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
motd = await utils.get_content('motd', str(pendulum.parse(date).date()))
|
motd = await utils.get_content('motd', str(pendulum.parse(date).date()))
|
||||||
date = motd[0]['date']
|
date = motd['date']
|
||||||
motd = motd[0]['motd']
|
motd = motd['motd']
|
||||||
fmt = "Message of the day for {}:\n\n{}".format(date, motd)
|
fmt = "Message of the day for {}:\n\n{}".format(date, motd)
|
||||||
await ctx.send(fmt)
|
await ctx.send(fmt)
|
||||||
# This one will be hit if we return None for that day
|
# This one will be hit if we return None for that day
|
||||||
|
|
12
cogs/da.py
12
cogs/da.py
|
@ -131,12 +131,12 @@ class Deviantart:
|
||||||
entry = {'member_id': ctx.message.author.id, 'subbed': [username], 'last_updated': {}}
|
entry = {'member_id': ctx.message.author.id, 'subbed': [username], 'last_updated': {}}
|
||||||
await utils.add_content('deviantart', entry)
|
await utils.add_content('deviantart', entry)
|
||||||
await ctx.send("You have just subscribed to {}!".format(username))
|
await ctx.send("You have just subscribed to {}!".format(username))
|
||||||
elif content[0]['subbed'] is None or username not in content[0]['subbed']:
|
elif content['subbed'] is None or username not in content['subbed']:
|
||||||
if content[0]['subbed'] is None:
|
if content['subbed'] is None:
|
||||||
sub_list = [username]
|
sub_list = [username]
|
||||||
else:
|
else:
|
||||||
content[0]['subbed'].append(username)
|
content['subbed'].append(username)
|
||||||
sub_list = content[0]['subbed']
|
sub_list = content['subbed']
|
||||||
await utils.update_content('deviantart', {'subbed': sub_list}, key)
|
await utils.update_content('deviantart', {'subbed': sub_list}, key)
|
||||||
await ctx.send("You have just subscribed to {}!".format(username))
|
await ctx.send("You have just subscribed to {}!".format(username))
|
||||||
else:
|
else:
|
||||||
|
@ -152,9 +152,9 @@ class Deviantart:
|
||||||
key = ctx.message.author.id
|
key = ctx.message.author.id
|
||||||
content = await utils.get_content('deviantart', key)
|
content = await utils.get_content('deviantart', key)
|
||||||
|
|
||||||
if content is None or content[0]['subbed'] is None:
|
if content is None or content['subbed'] is None:
|
||||||
await ctx.send("You are not subscribed to anyone at the moment!")
|
await ctx.send("You are not subscribed to anyone at the moment!")
|
||||||
elif username in content[0]['subbed']:
|
elif username in content['subbed']:
|
||||||
content[0]['subbed'].remove(username)
|
content[0]['subbed'].remove(username)
|
||||||
await utils.update_content('deviantart', {'subbed': content[0]['subbed']}, key)
|
await utils.update_content('deviantart', {'subbed': content[0]['subbed']}, key)
|
||||||
await ctx.send("You have just unsubscribed from {}!".format(username))
|
await ctx.send("You have just unsubscribed from {}!".format(username))
|
||||||
|
|
|
@ -57,9 +57,9 @@ class StatsUpdate:
|
||||||
server_settings = await config.get_content('server_settings', guild.id)
|
server_settings = await config.get_content('server_settings', guild.id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
join_leave_on = server_settings[0]['join_leave']
|
join_leave_on = server_settings['join_leave']
|
||||||
if join_leave_on:
|
if join_leave_on:
|
||||||
channel_id = server_settings[0]['notification_channel'] or member.guild.id
|
channel_id = server_settings['notification_channel'] or member.guild.id
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
except (IndexError, TypeError):
|
except (IndexError, TypeError):
|
||||||
|
@ -73,9 +73,9 @@ class StatsUpdate:
|
||||||
server_settings = await config.get_content('server_settings', guild.id)
|
server_settings = await config.get_content('server_settings', guild.id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
join_leave_on = server_settings[0]['join_leave']
|
join_leave_on = server_settings['join_leave']
|
||||||
if join_leave_on:
|
if join_leave_on:
|
||||||
channel_id = server_settings[0]['notification_channel'] or member.guild.id
|
channel_id = server_settings['notification_channel'] or member.guild.id
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
except (IndexError, TypeError):
|
except (IndexError, TypeError):
|
||||||
|
|
|
@ -262,7 +262,7 @@ class Interaction:
|
||||||
key = booper.id
|
key = booper.id
|
||||||
boops = await utils.get_content('boops', key)
|
boops = await utils.get_content('boops', key)
|
||||||
if boops is not None:
|
if boops is not None:
|
||||||
boops = boops[0]['boops']
|
boops = boops['boops']
|
||||||
# If the booper has never booped the member provided, assure it's 0
|
# If the booper has never booped the member provided, assure it's 0
|
||||||
amount = boops.get(boopee.id, 0) + 1
|
amount = boops.get(boopee.id, 0) + 1
|
||||||
boops[boopee.id] = amount
|
boops[boopee.id] = amount
|
||||||
|
|
|
@ -155,7 +155,7 @@ class Mod:
|
||||||
update = {'nsfw_channels': r.row['nsfw_channels'].append(ctx.message.channel.id)}
|
update = {'nsfw_channels': r.row['nsfw_channels'].append(ctx.message.channel.id)}
|
||||||
|
|
||||||
server_settings = await utils.get_content('server_settings', key)
|
server_settings = await utils.get_content('server_settings', key)
|
||||||
if server_settings and 'nsfw_channels' in server_settings[0].keys():
|
if server_settings and 'nsfw_channels' in server_settings.keys():
|
||||||
await utils.update_content('server_settings', update, key)
|
await utils.update_content('server_settings', update, key)
|
||||||
elif server_settings:
|
elif server_settings:
|
||||||
await utils.update_content('server_settings', entry, key)
|
await utils.update_content('server_settings', entry, key)
|
||||||
|
@ -176,7 +176,7 @@ class Mod:
|
||||||
server_settings = await utils.get_content('server_settings', key)
|
server_settings = await utils.get_content('server_settings', key)
|
||||||
channel = ctx.message.channel.id
|
channel = ctx.message.channel.id
|
||||||
try:
|
try:
|
||||||
channels = server_settings[0]['nsfw_channels']
|
channels = server_settings['nsfw_channels']
|
||||||
if channel in channels:
|
if channel in channels:
|
||||||
channels.remove(channel)
|
channels.remove(channel)
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ class Mod:
|
||||||
|
|
||||||
server_settings = await utils.get_content('server_settings', ctx.message.guild.id)
|
server_settings = await utils.get_content('server_settings', ctx.message.guild.id)
|
||||||
try:
|
try:
|
||||||
server_perms = server_settings[0]['permissions']
|
server_perms = server_settings['permissions']
|
||||||
except (TypeError, IndexError):
|
except (TypeError, IndexError):
|
||||||
server_perms = {}
|
server_perms = {}
|
||||||
|
|
||||||
|
@ -457,8 +457,6 @@ class Mod:
|
||||||
if not rules or len(rules) == 0:
|
if not rules or len(rules) == 0:
|
||||||
await ctx.send("This server currently has no rules on it! I see you like to live dangerously...")
|
await ctx.send("This server currently has no rules on it! I see you like to live dangerously...")
|
||||||
return
|
return
|
||||||
else:
|
|
||||||
rules = rules[0]
|
|
||||||
|
|
||||||
if rule is None:
|
if rule is None:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Overwatch:
|
||||||
return
|
return
|
||||||
# This API sometimes takes a while to look up information, so send a message saying we're processing
|
# This API sometimes takes a while to look up information, so send a message saying we're processing
|
||||||
|
|
||||||
bt = ow_stats[0]['battletag']
|
bt = ow_stats['battletag']
|
||||||
|
|
||||||
if hero == "":
|
if hero == "":
|
||||||
# If no hero was provided, we just want the base stats for a player
|
# If no hero was provided, we just want the base stats for a player
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Picarto:
|
||||||
continue
|
continue
|
||||||
guild_alerts = await utils.get_content('server_alerts', {'server_id': guild_id})
|
guild_alerts = await utils.get_content('server_alerts', {'server_id': guild_id})
|
||||||
try:
|
try:
|
||||||
channel_id = guild_alerts[0]['channel_id']
|
channel_id = guild_alerts['channel_id']
|
||||||
except (IndexError, TypeError):
|
except (IndexError, TypeError):
|
||||||
channel_id = guild_id
|
channel_id = guild_id
|
||||||
channel = self.bot.get_channel(channel_id)
|
channel = self.bot.get_channel(channel_id)
|
||||||
|
@ -95,7 +95,7 @@ class Picarto:
|
||||||
continue
|
continue
|
||||||
guild_alerts = await utils.get_content('server_alerts', {'server_id': guild_id})
|
guild_alerts = await utils.get_content('server_alerts', {'server_id': guild_id})
|
||||||
try:
|
try:
|
||||||
channel_id = guild_alerts[0]['channel_id']
|
channel_id = guild_alerts['channel_id']
|
||||||
except (IndexError, TypeError):
|
except (IndexError, TypeError):
|
||||||
channel_id = guild_id
|
channel_id = guild_id
|
||||||
channel = self.bot.get_channel(channel_id)
|
channel = self.bot.get_channel(channel_id)
|
||||||
|
@ -128,7 +128,7 @@ class Picarto:
|
||||||
await ctx.send("That user does not have a picarto url setup!")
|
await ctx.send("That user does not have a picarto url setup!")
|
||||||
return
|
return
|
||||||
|
|
||||||
member_url = picarto_entry[0]['picarto_url']
|
member_url = picarto_entry['picarto_url']
|
||||||
|
|
||||||
# Use regex to get the actual username so that we can make a request to the API
|
# Use regex to get the actual username so that we can make a request to the API
|
||||||
stream = re.search("(?<=picarto.tv/)(.*)", member_url).group(1)
|
stream = re.search("(?<=picarto.tv/)(.*)", member_url).group(1)
|
||||||
|
@ -223,7 +223,7 @@ class Picarto:
|
||||||
"I do not have your Picarto URL added {}. You can save your Picarto url with !picarto add".format(
|
"I do not have your Picarto URL added {}. You can save your Picarto url with !picarto add".format(
|
||||||
ctx.message.author.mention))
|
ctx.message.author.mention))
|
||||||
# Then check if this guild is already added as one to notify in
|
# Then check if this guild is already added as one to notify in
|
||||||
elif ctx.message.guild.id in result[0]['servers']:
|
elif ctx.message.guild.id in result['servers']:
|
||||||
await ctx.send("I am already set to notify in this guild...")
|
await ctx.send("I am already set to notify in this guild...")
|
||||||
else:
|
else:
|
||||||
await utils.update_content('picarto', {'servers': r.row['servers'].append(ctx.message.guild.id)},
|
await utils.update_content('picarto', {'servers': r.row['servers'].append(ctx.message.guild.id)},
|
||||||
|
|
|
@ -62,9 +62,7 @@ class Stats:
|
||||||
return
|
return
|
||||||
|
|
||||||
command_stats = await utils.get_content('command_usage', cmd.qualified_name)
|
command_stats = await utils.get_content('command_usage', cmd.qualified_name)
|
||||||
try:
|
if command_stats is None:
|
||||||
command_stats = command_stats[0]
|
|
||||||
except TypeError:
|
|
||||||
await ctx.send("That command has never been used! You know I worked hard on that! :c")
|
await ctx.send("That command has never been used! You know I worked hard on that! :c")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -145,7 +143,7 @@ class Stats:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Just to make this easier, just pay attention to the boops data, now that we have the right entry
|
# Just to make this easier, just pay attention to the boops data, now that we have the right entry
|
||||||
boops = boops[0]['boops']
|
boops = boops['boops']
|
||||||
|
|
||||||
# First get a list of the ID's of all members in this server, for use in list comprehension
|
# First get a list of the ID's of all members in this server, for use in list comprehension
|
||||||
server_member_ids = [member.id for member in ctx.message.guild.members]
|
server_member_ids = [member.id for member in ctx.message.guild.members]
|
||||||
|
@ -175,7 +173,7 @@ class Stats:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Just to make this easier, just pay attention to the boops data, now that we have the right entry
|
# Just to make this easier, just pay attention to the boops data, now that we have the right entry
|
||||||
boops = boops[0]['boops']
|
boops = boops['boops']
|
||||||
|
|
||||||
# Same concept as the mostboops method
|
# Same concept as the mostboops method
|
||||||
server_member_ids = [member.id for member in ctx.message.guild.members]
|
server_member_ids = [member.id for member in ctx.message.guild.members]
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Tags:
|
||||||
|
|
||||||
EXAMPLE: !tags
|
EXAMPLE: !tags
|
||||||
RESULT: All tags setup on this server"""
|
RESULT: All tags setup on this server"""
|
||||||
tags = await utils.get_content('tags', {'server_id': ctx.message.guild.id})
|
tags = await utils.get_content('tags', ctx.message.guild.id)
|
||||||
# Simple generator that adds a tag to the list to print, if the tag is for this server
|
# Simple generator that adds a tag to the list to print, if the tag is for this server
|
||||||
try:
|
try:
|
||||||
fmt = "\n".join("{}".format(tag['tag']) for tag in tags)
|
fmt = "\n".join("{}".format(tag['tag']) for tag in tags)
|
||||||
|
|
|
@ -61,9 +61,9 @@ class Twitch:
|
||||||
server = self.bot.get_server(server_id)
|
server = self.bot.get_server(server_id)
|
||||||
if server is None:
|
if server is None:
|
||||||
continue
|
continue
|
||||||
server_alerts = await utils.get_content('server_alerts', server_id)
|
server_settings = await utils.get_content('server_settings', server_id)
|
||||||
try:
|
try:
|
||||||
channel_id = server_alerts[0]['channel_id']
|
channel_id = server_settings['notification_channel']
|
||||||
except (IndexError, TypeError):
|
except (IndexError, TypeError):
|
||||||
channel_id = server_id
|
channel_id = server_id
|
||||||
channel = self.bot.get_channel(channel_id)
|
channel = self.bot.get_channel(channel_id)
|
||||||
|
@ -86,10 +86,11 @@ class Twitch:
|
||||||
server = self.bot.get_server(server_id)
|
server = self.bot.get_server(server_id)
|
||||||
if server is None:
|
if server is None:
|
||||||
continue
|
continue
|
||||||
server_alerts = await utils.get_content('server_alerts', {'server_id': server_id})
|
server_settings = await utils.get_content('server_settings', server_id)
|
||||||
channel_id = server_id
|
try:
|
||||||
if server_alerts is not None and len(server_alerts) > 0:
|
channel_id = server_settings['notification_channel']
|
||||||
channel_id = server_alerts[0].get('channel_id')
|
except (IndexError, TypeError):
|
||||||
|
channel_id = server_id
|
||||||
channel = self.bot.get_channel(channel_id)
|
channel = self.bot.get_channel(channel_id)
|
||||||
# Get the member that has just gone live
|
# Get the member that has just gone live
|
||||||
member = server.get_member(m_id)
|
member = server.get_member(m_id)
|
||||||
|
@ -203,7 +204,7 @@ class Twitch:
|
||||||
"I do not have your twitch URL added {}. You can save your twitch url with !twitch add".format(
|
"I do not have your twitch URL added {}. You can save your twitch url with !twitch add".format(
|
||||||
ctx.message.author.mention))
|
ctx.message.author.mention))
|
||||||
# Then check if this server is already added as one to notify in
|
# Then check if this server is already added as one to notify in
|
||||||
elif ctx.message.guild.id in result[0]['servers']:
|
elif ctx.message.guild.id in result['servers']:
|
||||||
await ctx.send("I am already set to notify in this server...")
|
await ctx.send("I am already set to notify in this server...")
|
||||||
else:
|
else:
|
||||||
await utils.update_content('twitch', {'servers': r.row['servers'].append(ctx.message.guild.id)}, key)
|
await utils.update_content('twitch', {'servers': r.row['servers'].append(ctx.message.guild.id)}, key)
|
||||||
|
|
|
@ -50,7 +50,7 @@ async def channel_is_nsfw(channel):
|
||||||
server_settings = await config.get_content('server_settings', server)
|
server_settings = await config.get_content('server_settings', server)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return channel in server_settings[0]['nsfw_channels']
|
return channel in server_settings['nsfw_channels']
|
||||||
except (TypeError, IndexError):
|
except (TypeError, IndexError):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue