Convert all comparisions to the db to string, as rethinkdb fails to parse ints as keys, or long ints in general
This commit is contained in:
parent
18e5648b41
commit
6ed044c1cc
|
@ -102,7 +102,7 @@ class Deviantart:
|
||||||
# Now we can update the user's last updated for this DA
|
# Now we can update the user's last updated for this DA
|
||||||
# We want to do this whether or not our last if statement was met
|
# We want to do this whether or not our last if statement was met
|
||||||
update = {'last_updated': {da_name: result['deviationid']}}
|
update = {'last_updated': {da_name: result['deviationid']}}
|
||||||
await utils.update_content('deviantart', update, user.id)
|
await utils.update_content('deviantart', update, str(user.id))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
tb = traceback.format_exc()
|
tb = traceback.format_exc()
|
||||||
fmt = "{1}\n{0.__class__.__name__}: {0}".format(tb, e)
|
fmt = "{1}\n{0.__class__.__name__}: {0}".format(tb, e)
|
||||||
|
@ -123,12 +123,12 @@ class Deviantart:
|
||||||
|
|
||||||
EXAMPLE: !da sub MyFavoriteArtistEva<3
|
EXAMPLE: !da sub MyFavoriteArtistEva<3
|
||||||
RESULT: Notifications of amazing pics c:"""
|
RESULT: Notifications of amazing pics c:"""
|
||||||
key = ctx.message.author.id
|
key = str(ctx.message.author.id)
|
||||||
content = await utils.get_content('deviantart', key)
|
content = await utils.get_content('deviantart', key)
|
||||||
# TODO: Ensure the user provided is a real user
|
# TODO: Ensure the user provided is a real user
|
||||||
|
|
||||||
if content is None:
|
if content is None:
|
||||||
entry = {'member_id': ctx.message.author.id, 'subbed': [username], 'last_updated': {}}
|
entry = {'member_id': str(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['subbed'] is None or username not in content['subbed']:
|
elif content['subbed'] is None or username not in content['subbed']:
|
||||||
|
@ -149,7 +149,7 @@ class Deviantart:
|
||||||
|
|
||||||
EXAMPLE: !da unsub TheArtistWhoBetrayedMe
|
EXAMPLE: !da unsub TheArtistWhoBetrayedMe
|
||||||
RESULT: No more pics from that terrible person!"""
|
RESULT: No more pics from that terrible person!"""
|
||||||
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['subbed'] is None:
|
if content is None or content['subbed'] is None:
|
||||||
|
|
|
@ -54,7 +54,7 @@ class StatsUpdate:
|
||||||
|
|
||||||
async def on_member_join(self, member):
|
async def on_member_join(self, member):
|
||||||
guild = member.guild
|
guild = member.guild
|
||||||
server_settings = await config.get_content('server_settings', guild.id)
|
server_settings = await config.get_content('server_settings', str(guild.id))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
join_leave_on = server_settings['join_leave']
|
join_leave_on = server_settings['join_leave']
|
||||||
|
@ -65,12 +65,12 @@ class StatsUpdate:
|
||||||
except (IndexError, TypeError):
|
except (IndexError, TypeError):
|
||||||
return
|
return
|
||||||
|
|
||||||
channel = guild.get_channel(channel_id)
|
channel = guild.get_channel(int(channel_id))
|
||||||
await channel.send("Welcome to the '{0.guild.name}' server {0.mention}!".format(member))
|
await channel.send("Welcome to the '{0.guild.name}' server {0.mention}!".format(member))
|
||||||
|
|
||||||
async def on_member_remove(self, member):
|
async def on_member_remove(self, member):
|
||||||
guild = member.guild
|
guild = member.guild
|
||||||
server_settings = await config.get_content('server_settings', guild.id)
|
server_settings = await config.get_content('server_settings', str(guild.id))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
join_leave_on = server_settings['join_leave']
|
join_leave_on = server_settings['join_leave']
|
||||||
|
@ -81,7 +81,7 @@ class StatsUpdate:
|
||||||
except (IndexError, TypeError):
|
except (IndexError, TypeError):
|
||||||
return
|
return
|
||||||
|
|
||||||
channel = guild.get_channel(channel_id)
|
channel = guild.get_channel(int(channel_id))
|
||||||
await channel.send("{0} has left the server, I hope it wasn't because of something I said :c".format(member.display_name))
|
await channel.send("{0} has left the server, I hope it wasn't because of something I said :c".format(member.display_name))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,7 @@ class Interaction:
|
||||||
await ctx.send("Why the heck are you booping me? Get away from me >:c")
|
await ctx.send("Why the heck are you booping me? Get away from me >:c")
|
||||||
return
|
return
|
||||||
|
|
||||||
key = booper.id
|
key = str(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['boops']
|
boops = boops['boops']
|
||||||
|
@ -269,7 +269,7 @@ class Interaction:
|
||||||
|
|
||||||
await utils.update_content('boops', {'boops': boops}, key)
|
await utils.update_content('boops', {'boops': boops}, key)
|
||||||
else:
|
else:
|
||||||
entry = {'member_id': booper.id,
|
entry = {'member_id': str(booper.id),
|
||||||
'boops': {str(boopee.id): 1}}
|
'boops': {str(boopee.id): 1}}
|
||||||
|
|
||||||
await utils.add_content('boops', entry)
|
await utils.add_content('boops', entry)
|
||||||
|
|
42
cogs/mod.py
42
cogs/mod.py
|
@ -107,9 +107,9 @@ class Mod:
|
||||||
|
|
||||||
EXAMPLE: !alerts #alerts
|
EXAMPLE: !alerts #alerts
|
||||||
RESULT: No more alerts spammed in #general!"""
|
RESULT: No more alerts spammed in #general!"""
|
||||||
key = ctx.message.guild.id
|
key = str(ctx.message.guild.id)
|
||||||
entry = {'server_id': ctx.message.guild.id,
|
entry = {'server_id': key,
|
||||||
'notification_channel': channel.id}
|
'notification_channel': str(channel.id)}
|
||||||
if not await utils.update_content('server_alerts', entry, key):
|
if not await utils.update_content('server_alerts', entry, key):
|
||||||
await utils.add_content('server_alerts', entry)
|
await utils.add_content('server_alerts', entry)
|
||||||
await ctx.send("I have just changed this server's 'notifications' channel"
|
await ctx.send("I have just changed this server's 'notifications' channel"
|
||||||
|
@ -127,8 +127,8 @@ class Mod:
|
||||||
# So we base this channel on it's own and not from alerts
|
# So we base this channel on it's own and not from alerts
|
||||||
# When mod logging becomes available, that will be kept to it's own channel if wanted as well
|
# When mod logging becomes available, that will be kept to it's own channel if wanted as well
|
||||||
on_off = True if re.search("(on|yes|true)", on_off.lower()) else False
|
on_off = True if re.search("(on|yes|true)", on_off.lower()) else False
|
||||||
key = ctx.message.guild.id
|
key = str(ctx.message.guild.id)
|
||||||
entry = {'server_id': ctx.message.guild.id,
|
entry = {'server_id': key,
|
||||||
'join_leave': on_off}
|
'join_leave': on_off}
|
||||||
if not await utils.update_content('user_notifications', entry, key):
|
if not await utils.update_content('user_notifications', entry, key):
|
||||||
await utils.add_content('user_notifications', entry)
|
await utils.add_content('user_notifications', entry)
|
||||||
|
@ -149,10 +149,10 @@ class Mod:
|
||||||
|
|
||||||
EXAMPLE: !nsfw add
|
EXAMPLE: !nsfw add
|
||||||
RESULT: ;)"""
|
RESULT: ;)"""
|
||||||
key = ctx.message.guild.id
|
key = str(ctx.message.guild.id)
|
||||||
entry = {'server_id': key,
|
entry = {'server_id': key,
|
||||||
'nsfw_channels': [ctx.message.channel.id]}
|
'nsfw_channels': [str(ctx.message.channel.id)]}
|
||||||
update = {'nsfw_channels': r.row['nsfw_channels'].append(ctx.message.channel.id)}
|
update = {'nsfw_channels': r.row['nsfw_channels'].append(str(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.keys():
|
if server_settings and 'nsfw_channels' in server_settings.keys():
|
||||||
|
@ -172,9 +172,9 @@ class Mod:
|
||||||
EXAMPLE: !nsfw remove
|
EXAMPLE: !nsfw remove
|
||||||
RESULT: ;("""
|
RESULT: ;("""
|
||||||
|
|
||||||
key = ctx.message.guild.id
|
key = str(ctx.message.guild.id)
|
||||||
server_settings = await utils.get_content('server_settings', key)
|
server_settings = await utils.get_content('server_settings', key)
|
||||||
channel = ctx.message.channel.id
|
channel = str(ctx.message.channel.id)
|
||||||
try:
|
try:
|
||||||
channels = server_settings['nsfw_channels']
|
channels = server_settings['nsfw_channels']
|
||||||
if channel in channels:
|
if channel in channels:
|
||||||
|
@ -222,7 +222,7 @@ class Mod:
|
||||||
await ctx.send("That is not a valid command!")
|
await ctx.send("That is not a valid command!")
|
||||||
return
|
return
|
||||||
|
|
||||||
server_settings = await utils.get_content('server_settings', ctx.message.guild.id)
|
server_settings = await utils.get_content('server_settings', str(ctx.message.guild.id))
|
||||||
try:
|
try:
|
||||||
server_perms = server_settings['permissions']
|
server_perms = server_settings['permissions']
|
||||||
except (TypeError, IndexError):
|
except (TypeError, IndexError):
|
||||||
|
@ -309,8 +309,8 @@ class Mod:
|
||||||
await ctx.send("This command cannot have custom permissions setup!")
|
await ctx.send("This command cannot have custom permissions setup!")
|
||||||
return
|
return
|
||||||
|
|
||||||
key = ctx.message.guild.id
|
key = str(ctx.message.guild.id)
|
||||||
entry = {'server_id': ctx.message.guild.id,
|
entry = {'server_id': key,
|
||||||
'permissions': {cmd.qualified_name: perm_value}}
|
'permissions': {cmd.qualified_name: perm_value}}
|
||||||
|
|
||||||
if not await utils.update_content('server_settings', entry, key):
|
if not await utils.update_content('server_settings', entry, key):
|
||||||
|
@ -335,7 +335,7 @@ class Mod:
|
||||||
return
|
return
|
||||||
|
|
||||||
update = {'permissions': {cmd.qualified_name: None}}
|
update = {'permissions': {cmd.qualified_name: None}}
|
||||||
await utils.update_content('custom_permissions', update, ctx.message.guild.id)
|
await utils.update_content('custom_permissions', update, str(ctx.message.guild.id))
|
||||||
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(no_pm=True)
|
@commands.command(no_pm=True)
|
||||||
|
@ -345,11 +345,11 @@ class Mod:
|
||||||
|
|
||||||
EXAMPLE: !prefix new_prefix
|
EXAMPLE: !prefix new_prefix
|
||||||
RESULT: You probably screwing it up and not realizing you now need to do new_prefixprefix"""
|
RESULT: You probably screwing it up and not realizing you now need to do new_prefixprefix"""
|
||||||
key = ctx.message.guild.id
|
key = str(ctx.message.guild.id)
|
||||||
if prefix.lower().strip() == "none":
|
if prefix.lower().strip() == "none":
|
||||||
prefix = None
|
prefix = None
|
||||||
|
|
||||||
entry = {'server_id': ctx.message.guild.id,
|
entry = {'server_id': key,
|
||||||
'prefix': prefix}
|
'prefix': prefix}
|
||||||
|
|
||||||
if not await utils.update_content('server_settings', entry, key):
|
if not await utils.update_content('server_settings', entry, key):
|
||||||
|
@ -451,8 +451,8 @@ class Mod:
|
||||||
|
|
||||||
EXAMPLE: !rules 5
|
EXAMPLE: !rules 5
|
||||||
RESULT: Rule 5 is printed"""
|
RESULT: Rule 5 is printed"""
|
||||||
server_settings = await utils.get_content('server_settings', ctx.message.guild.id)
|
server_settings = await utils.get_content('server_settings', str(ctx.message.guild.id))
|
||||||
rules = server_settings['rules']
|
rules = server_settings.get('rules')
|
||||||
|
|
||||||
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...")
|
||||||
|
@ -480,8 +480,8 @@ class Mod:
|
||||||
|
|
||||||
EXAMPLE: !rules add No fun allowed in this server >:c
|
EXAMPLE: !rules add No fun allowed in this server >:c
|
||||||
RESULT: No more fun...unless they break the rules!"""
|
RESULT: No more fun...unless they break the rules!"""
|
||||||
key = ctx.message.guild.id
|
key = str(ctx.message.guild.id)
|
||||||
entry = {'server_id': ctx.message.guild.id,
|
entry = {'server_id': key,
|
||||||
'rules': [rule]}
|
'rules': [rule]}
|
||||||
update = {'rules': r.row['rules'].append(rule)}
|
update = {'rules': r.row['rules'].append(rule)}
|
||||||
|
|
||||||
|
@ -504,7 +504,7 @@ class Mod:
|
||||||
EXAMPLE: !rules delete 5
|
EXAMPLE: !rules delete 5
|
||||||
RESULT: Freedom from opression!"""
|
RESULT: Freedom from opression!"""
|
||||||
update = {'rules': r.row['rules'].delete_at(rule - 1)}
|
update = {'rules': r.row['rules'].delete_at(rule - 1)}
|
||||||
if not await utils.update_content('server_settings', update, ctx.message.guild.id):
|
if not await utils.update_content('server_settings', update, str(ctx.message.guild.id)):
|
||||||
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.")
|
||||||
else:
|
else:
|
||||||
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!")
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Overwatch:
|
||||||
await ctx.message.channel.trigger_typing()
|
await ctx.message.channel.trigger_typing()
|
||||||
|
|
||||||
user = user or ctx.message.author
|
user = user or ctx.message.author
|
||||||
ow_stats = await utils.get_content('overwatch', user.id)
|
ow_stats = await utils.get_content('overwatch', str(user.id))
|
||||||
|
|
||||||
if ow_stats is None:
|
if ow_stats is None:
|
||||||
await ctx.send("I do not have this user's battletag saved!")
|
await ctx.send("I do not have this user's battletag saved!")
|
||||||
|
@ -95,7 +95,7 @@ class Overwatch:
|
||||||
# Battletags are normally provided like name#id
|
# Battletags are normally provided like name#id
|
||||||
# However the API needs this to be a -, so repliace # with - if it exists
|
# However the API needs this to be a -, so repliace # with - if it exists
|
||||||
bt = bt.replace("#", "-")
|
bt = bt.replace("#", "-")
|
||||||
key = ctx.message.author.id
|
key = str(ctx.message.author.id)
|
||||||
|
|
||||||
# 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
|
||||||
await ctx.send("Looking up your profile information....")
|
await ctx.send("Looking up your profile information....")
|
||||||
|
@ -109,7 +109,7 @@ class Overwatch:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Now just save the battletag
|
# Now just save the battletag
|
||||||
entry = {'member_id': ctx.message.author.id, 'battletag': bt}
|
entry = {'member_id': key, 'battletag': bt}
|
||||||
update = {'battletag': bt}
|
update = {'battletag': bt}
|
||||||
# Try adding this first, if that fails, update the saved entry
|
# Try adding this first, if that fails, update the saved entry
|
||||||
if not await utils.add_content('overwatch', entry):
|
if not await utils.add_content('overwatch', entry):
|
||||||
|
@ -123,7 +123,7 @@ class Overwatch:
|
||||||
|
|
||||||
EXAMPLE: !ow delete
|
EXAMPLE: !ow delete
|
||||||
RESULT: Your battletag is no longer saved"""
|
RESULT: Your battletag is no longer saved"""
|
||||||
if await utils.remove_content('overwatch', ctx.message.author.id):
|
if await utils.remove_content('overwatch', str(ctx.message.author.id)):
|
||||||
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))
|
||||||
else:
|
else:
|
||||||
await ctx.send("I don't even have your battletag saved {}".format(ctx.message.author.mention))
|
await ctx.send("I don't even have your battletag saved {}".format(ctx.message.author.mention))
|
||||||
|
|
|
@ -14,7 +14,7 @@ log = logging.getLogger()
|
||||||
BASE_URL = 'https://ptvappapi.picarto.tv'
|
BASE_URL = 'https://ptvappapi.picarto.tv'
|
||||||
|
|
||||||
# This is a public key for use, I don't care if this is seen
|
# This is a public key for use, I don't care if this is seen
|
||||||
key = '03e26294-b793-11e5-9a41-005056984bd4'
|
api_key = '03e26294-b793-11e5-9a41-005056984bd4'
|
||||||
|
|
||||||
|
|
||||||
async def online_users():
|
async def online_users():
|
||||||
|
@ -24,7 +24,7 @@ async def online_users():
|
||||||
# In place of requesting for /channel and checking if that is online currently, for each channel
|
# In place of requesting for /channel and checking if that is online currently, for each channel
|
||||||
# This method is in place to just return all online_users
|
# This method is in place to just return all online_users
|
||||||
url = BASE_URL + '/online/all'
|
url = BASE_URL + '/online/all'
|
||||||
payload = {'key': key}
|
payload = {'key': api_key}
|
||||||
return await utils.request(url, payload=payload)
|
return await utils.request(url, payload=payload)
|
||||||
except:
|
except:
|
||||||
return {}
|
return {}
|
||||||
|
@ -123,7 +123,7 @@ class Picarto:
|
||||||
RESULT: Info about their picarto stream"""
|
RESULT: Info about their picarto stream"""
|
||||||
# If member is not given, base information on the author
|
# If member is not given, base information on the author
|
||||||
member = member or ctx.message.author
|
member = member or ctx.message.author
|
||||||
picarto_entry = await utils.get_content('picarto', member.id)
|
picarto_entry = await utils.get_content('picarto', str(member.id))
|
||||||
if picarto_entry is None:
|
if picarto_entry is None:
|
||||||
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
|
||||||
|
@ -133,7 +133,7 @@ class Picarto:
|
||||||
# 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)
|
||||||
url = BASE_URL + '/channel/{}'.format(stream)
|
url = BASE_URL + '/channel/{}'.format(stream)
|
||||||
payload = {'key': key}
|
payload = {'key': api_key}
|
||||||
|
|
||||||
data = await utils.request(url, payload=payload)
|
data = await utils.request(url, payload=payload)
|
||||||
|
|
||||||
|
@ -176,19 +176,19 @@ class Picarto:
|
||||||
url = "https://www.{}".format(url)
|
url = "https://www.{}".format(url)
|
||||||
channel = re.search("https://www.picarto.tv/(.*)", url).group(1)
|
channel = re.search("https://www.picarto.tv/(.*)", url).group(1)
|
||||||
url = BASE_URL + '/channel/{}'.format(channel)
|
url = BASE_URL + '/channel/{}'.format(channel)
|
||||||
payload = {'key': key}
|
payload = {'key': api_key}
|
||||||
data = await utils.request(url, payload=payload)
|
data = await utils.request(url, payload=payload)
|
||||||
if not data:
|
if not data:
|
||||||
await ctx.send("That Picarto user does not exist! What would be the point of adding a nonexistant Picarto "
|
await ctx.send("That Picarto user does not exist! What would be the point of adding a nonexistant Picarto "
|
||||||
"user? Silly")
|
"user? Silly")
|
||||||
return
|
return
|
||||||
|
|
||||||
key = ctx.message.author.id
|
key = str(ctx.message.author.id)
|
||||||
entry = {'picarto_url': url,
|
entry = {'picarto_url': url,
|
||||||
'servers': [ctx.message.guild.id],
|
'servers': [str(ctx.message.guild.id)],
|
||||||
'notifications_on': 1,
|
'notifications_on': 1,
|
||||||
'live': 0,
|
'live': 0,
|
||||||
'member_id': ctx.message.author.id}
|
'member_id': key}
|
||||||
if await utils.add_content('picarto', entry):
|
if await utils.add_content('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(
|
||||||
|
@ -201,7 +201,7 @@ class Picarto:
|
||||||
@utils.custom_perms(send_messages=True)
|
@utils.custom_perms(send_messages=True)
|
||||||
async def remove_picarto_url(self, ctx):
|
async def remove_picarto_url(self, ctx):
|
||||||
"""Removes your picarto URL"""
|
"""Removes your picarto URL"""
|
||||||
if await utils.remove_content('picarto', ctx.message.author.id):
|
if await utils.remove_content('picarto', str(ctx.message.author.id)):
|
||||||
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(
|
await ctx.send(
|
||||||
|
@ -216,7 +216,8 @@ class Picarto:
|
||||||
|
|
||||||
EXAMPLE: !picarto notify
|
EXAMPLE: !picarto notify
|
||||||
RESULT: This guild will now be notified of you going live"""
|
RESULT: This guild will now be notified of you going live"""
|
||||||
result = await utils.get_content('picarto', ctx.message.author.id)
|
key = str(ctx.message.author.id)
|
||||||
|
result = await utils.get_content('picarto', key)
|
||||||
# Check if this user is saved at all
|
# Check if this user is saved at all
|
||||||
if result is None:
|
if result is None:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
|
@ -226,8 +227,7 @@ class Picarto:
|
||||||
elif ctx.message.guild.id in result['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(str(ctx.message.guild.id))}, key)
|
||||||
ctx.message.author.id)
|
|
||||||
|
|
||||||
@notify.command(name='on', aliases=['start,yes'], no_pm=True)
|
@notify.command(name='on', aliases=['start,yes'], no_pm=True)
|
||||||
@utils.custom_perms(send_messages=True)
|
@utils.custom_perms(send_messages=True)
|
||||||
|
@ -236,7 +236,7 @@ class Picarto:
|
||||||
|
|
||||||
EXAMPLE: !picarto notify on
|
EXAMPLE: !picarto notify on
|
||||||
RESULT: Notifications are sent when you go live"""
|
RESULT: Notifications are sent when you go live"""
|
||||||
await utils.update_content('picarto', {'notifications_on': 1}, ctx.message.author.id)
|
await utils.update_content('picarto', {'notifications_on': 1}, str(ctx.message.author.id))
|
||||||
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))
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ class Picarto:
|
||||||
|
|
||||||
EXAMPLE: !picarto notify off
|
EXAMPLE: !picarto notify off
|
||||||
RESULT: No more notifications sent when you go live"""
|
RESULT: No more notifications sent when you go live"""
|
||||||
await utils.update_content('picarto', {'notifications_on': 0}, ctx.message.author.id)
|
await utils.update_content('picarto', {'notifications_on': 0}, str(ctx.message.author.id))
|
||||||
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(
|
||||||
|
|
|
@ -87,7 +87,7 @@ class Raffle:
|
||||||
|
|
||||||
EXAMPLE: !raffles
|
EXAMPLE: !raffles
|
||||||
RESULT: A list of the raffles setup on this server"""
|
RESULT: A list of the raffles setup on this server"""
|
||||||
r_filter = {'server_id': ctx.message.guild.id}
|
r_filter = {'server_id': str(ctx.message.guild.id)}
|
||||||
raffles = await utils.filter_content('raffles', r_filter)
|
raffles = await utils.filter_content('raffles', r_filter)
|
||||||
if raffles is None:
|
if raffles is None:
|
||||||
await ctx.send("There are currently no raffles setup on this server!")
|
await ctx.send("There are currently no raffles setup on this server!")
|
||||||
|
@ -110,7 +110,7 @@ class Raffle:
|
||||||
RESULT: You've entered the first raffle!"""
|
RESULT: You've entered the first raffle!"""
|
||||||
# Lets let people use 1 - (length of raffles) and handle 0 base ourselves
|
# Lets let people use 1 - (length of raffles) and handle 0 base ourselves
|
||||||
raffle_id -= 1
|
raffle_id -= 1
|
||||||
r_filter = {'server_id': ctx.message.guild.id}
|
r_filter = {'server_id': str(ctx.message.guild.id)}
|
||||||
author = ctx.message.author
|
author = ctx.message.author
|
||||||
|
|
||||||
raffles = await utils.filter_content('raffles', r_filter)
|
raffles = await utils.filter_content('raffles', r_filter)
|
||||||
|
@ -124,10 +124,10 @@ class Raffle:
|
||||||
if raffle_count == 1:
|
if raffle_count == 1:
|
||||||
entrants = raffles[0]['entrants']
|
entrants = raffles[0]['entrants']
|
||||||
# Lets make sure that the user hasn't already entered the raffle
|
# Lets make sure that the user hasn't already entered the raffle
|
||||||
if author.id in entrants:
|
if str(author.id) in entrants:
|
||||||
await ctx.send("You have already entered this raffle!")
|
await ctx.send("You have already entered this raffle!")
|
||||||
return
|
return
|
||||||
entrants.append(author.id)
|
entrants.append(str(author.id))
|
||||||
|
|
||||||
update = {'entrants': entrants}
|
update = {'entrants': entrants}
|
||||||
await utils.update_content('raffles', update, raffles[0]['id'])
|
await utils.update_content('raffles', update, raffles[0]['id'])
|
||||||
|
@ -137,10 +137,10 @@ class Raffle:
|
||||||
entrants = raffles[raffle_id]['entrants']
|
entrants = raffles[raffle_id]['entrants']
|
||||||
|
|
||||||
# Lets make sure that the user hasn't already entered the raffle
|
# Lets make sure that the user hasn't already entered the raffle
|
||||||
if author.id in entrants:
|
if str(author.id) in entrants:
|
||||||
await ctx.send("You have already entered this raffle!")
|
await ctx.send("You have already entered this raffle!")
|
||||||
return
|
return
|
||||||
entrants.append(author.id)
|
entrants.append(str(author.id))
|
||||||
|
|
||||||
# Since we have no good thing to filter things off of, lets use the internal rethinkdb id
|
# Since we have no good thing to filter things off of, lets use the internal rethinkdb id
|
||||||
update = {'entrants': entrants}
|
update = {'entrants': entrants}
|
||||||
|
@ -231,8 +231,8 @@ class Raffle:
|
||||||
entry = {'title': title,
|
entry = {'title': title,
|
||||||
'expires': expires.to_datetime_string(),
|
'expires': expires.to_datetime_string(),
|
||||||
'entrants': [],
|
'entrants': [],
|
||||||
'author': author.id,
|
'author': str(author.id),
|
||||||
'server_id': server.id}
|
'server_id': str(server.id)}
|
||||||
|
|
||||||
# We don't want to pass a filter to this, because we can have multiple raffles per server
|
# We don't want to pass a filter to this, because we can have multiple raffles per server
|
||||||
await utils.add_content('raffles', entry)
|
await utils.add_content('raffles', entry)
|
||||||
|
|
|
@ -137,7 +137,7 @@ class Stats:
|
||||||
|
|
||||||
EXAMPLE: !mostboops
|
EXAMPLE: !mostboops
|
||||||
RESULT: You've booped @OtherPerson 351253897120935712093572193057310298 times!"""
|
RESULT: You've booped @OtherPerson 351253897120935712093572193057310298 times!"""
|
||||||
boops = await utils.get_content('boops', ctx.message.author.id)
|
boops = await utils.get_content('boops', str(ctx.message.author.id))
|
||||||
if boops is None:
|
if boops is None:
|
||||||
await ctx.send("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention))
|
await ctx.send("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention))
|
||||||
return
|
return
|
||||||
|
@ -146,7 +146,7 @@ class Stats:
|
||||||
boops = boops['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 = [str(member.id) for member in ctx.message.guild.members]
|
||||||
# Then get a sorted list, based on the amount of times they've booped the member
|
# Then get a sorted list, based on the amount of times they've booped the member
|
||||||
# Reverse needs to be true, as we want it to go from highest to lowest
|
# Reverse needs to be true, as we want it to go from highest to lowest
|
||||||
sorted_boops = sorted(boops.items(), key=lambda x: x[1], reverse=True)
|
sorted_boops = sorted(boops.items(), key=lambda x: x[1], reverse=True)
|
||||||
|
@ -156,7 +156,7 @@ class Stats:
|
||||||
# Since this is sorted, we just need to get the following information on the first user in the list
|
# Since this is sorted, we just need to get the following information on the first user in the list
|
||||||
most_id, most_boops = sorted_boops[0]
|
most_id, most_boops = sorted_boops[0]
|
||||||
|
|
||||||
member = discord.utils.find(lambda m: m.id == most_id, self.bot.get_all_members())
|
member = discord.utils.find(lambda m: str(m.id) == most_id, self.bot.get_all_members())
|
||||||
await ctx.send("{0} you have booped {1} the most amount of times, coming in at {2} times".format(
|
await ctx.send("{0} you have booped {1} the most amount of times, coming in at {2} times".format(
|
||||||
ctx.message.author.mention, member.display_name, most_boops))
|
ctx.message.author.mention, member.display_name, most_boops))
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ class Stats:
|
||||||
|
|
||||||
EXAMPLE: !listboops
|
EXAMPLE: !listboops
|
||||||
RESULT: The list of your booped members!"""
|
RESULT: The list of your booped members!"""
|
||||||
boops = await utils.get_content('boops', ctx.message.author.id)
|
boops = await utils.get_content('boops', str(ctx.message.author.id))
|
||||||
if boops is None:
|
if boops is None:
|
||||||
await ctx.send("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention))
|
await ctx.send("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention))
|
||||||
return
|
return
|
||||||
|
@ -176,7 +176,7 @@ class Stats:
|
||||||
boops = boops['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 = [str(member.id )for member in ctx.message.guild.members]
|
||||||
booped_members = {m_id: amt for m_id, amt in boops.items() if m_id in server_member_ids}
|
booped_members = {m_id: amt for m_id, amt in boops.items() if m_id in server_member_ids}
|
||||||
sorted_booped_members = sorted(booped_members.items(), key=lambda k: k[1], reverse=True)
|
sorted_booped_members = sorted(booped_members.items(), key=lambda k: k[1], reverse=True)
|
||||||
# Now we only want the first 10 members, so splice this list
|
# Now we only want the first 10 members, so splice this list
|
||||||
|
@ -201,7 +201,7 @@ class Stats:
|
||||||
EXAMPLE: !leaderboard
|
EXAMPLE: !leaderboard
|
||||||
RESULT: A leaderboard of this server's battle records"""
|
RESULT: A leaderboard of this server's battle records"""
|
||||||
# Create a list of the ID's of all members in this server, for comparison to the records saved
|
# Create a list of the ID's of all members in this server, for comparison to the records saved
|
||||||
server_member_ids = [member.id for member in ctx.message.guild.members]
|
server_member_ids = [str(member.id) for member in ctx.message.guild.members]
|
||||||
battles = await utils.get_content('battle_records')
|
battles = await utils.get_content('battle_records')
|
||||||
battles = [battle for battle in battles if battle['member_id'] in server_member_ids]
|
battles = [battle for battle in battles if battle['member_id'] in server_member_ids]
|
||||||
|
|
||||||
|
@ -235,23 +235,23 @@ class Stats:
|
||||||
all_members = await utils.get_content('battle_records')
|
all_members = await utils.get_content('battle_records')
|
||||||
|
|
||||||
# Make a list comprehension to just check if the user has battled
|
# Make a list comprehension to just check if the user has battled
|
||||||
if len([entry for entry in all_members if entry['member_id'] == member.id]) == 0:
|
if len([entry for entry in all_members if entry['member_id'] == str(member.id)]) == 0:
|
||||||
await ctx.send("That user has not battled yet!")
|
await ctx.send("That user has not battled yet!")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Same concept as the leaderboard
|
# Same concept as the leaderboard
|
||||||
server_member_ids = [member.id for member in ctx.message.guild.members]
|
server_member_ids = [str(member.id) for member in ctx.message.guild.members]
|
||||||
server_members = [stats for stats in all_members if stats['member_id'] in server_member_ids]
|
server_members = [stats for stats in all_members if stats['member_id'] in server_member_ids]
|
||||||
sorted_server_members = sorted(server_members, key=lambda x: x['rating'], reverse=True)
|
sorted_server_members = sorted(server_members, key=lambda x: x['rating'], reverse=True)
|
||||||
sorted_all_members = sorted(all_members, key=lambda x: x['rating'], reverse=True)
|
sorted_all_members = sorted(all_members, key=lambda x: x['rating'], reverse=True)
|
||||||
|
|
||||||
# Enumurate the list so that we can go through, find the user's place in the list
|
# Enumurate the list so that we can go through, find the user's place in the list
|
||||||
# and get just that for the rank
|
# and get just that for the rank
|
||||||
server_rank = [i for i, x in enumerate(sorted_server_members) if x['member_id'] == member.id][0] + 1
|
server_rank = [i for i, x in enumerate(sorted_server_members) if x['member_id'] == str(member.id)][0] + 1
|
||||||
total_rank = [i for i, x in enumerate(sorted_all_members) if x['member_id'] == member.id][0] + 1
|
total_rank = [i for i, x in enumerate(sorted_all_members) if x['member_id'] == str(member.id)][0] + 1
|
||||||
# The rest of this is straight forward, just formatting
|
# The rest of this is straight forward, just formatting
|
||||||
|
|
||||||
entry = [m for m in server_members if m['member_id'] == member.id][0]
|
entry = [m for m in server_members if m['member_id'] == str(member.id)][0]
|
||||||
rating = entry['rating']
|
rating = entry['rating']
|
||||||
record = "{}-{}".format(entry['wins'], entry['losses'])
|
record = "{}-{}".format(entry['wins'], entry['losses'])
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -114,7 +114,7 @@ class Twitch:
|
||||||
if member is None:
|
if member is None:
|
||||||
member = ctx.message.author
|
member = ctx.message.author
|
||||||
|
|
||||||
result = await utils.get_content('twitch', {'member_id': member.id})
|
result = await utils.get_content('twitch', {'member_id': str(member.id)})
|
||||||
if result is None:
|
if result is None:
|
||||||
await ctx.send("{} has not saved their twitch URL yet!".format(member.name))
|
await ctx.send("{} has not saved their twitch URL yet!".format(member.name))
|
||||||
return
|
return
|
||||||
|
@ -162,12 +162,12 @@ class Twitch:
|
||||||
"What would be the point of adding a nonexistant twitch user? Silly")
|
"What would be the point of adding a nonexistant twitch user? Silly")
|
||||||
return
|
return
|
||||||
|
|
||||||
key = ctx.message.author.id
|
key = str(ctx.message.author.id)
|
||||||
entry = {'twitch_url': url,
|
entry = {'twitch_url': url,
|
||||||
'servers': [ctx.message.guild.id],
|
'servers': [str(ctx.message.guild.id)],
|
||||||
'notifications_on': 1,
|
'notifications_on': 1,
|
||||||
'live': 0,
|
'live': 0,
|
||||||
'member_id': ctx.message.author.id}
|
'member_id': key}
|
||||||
update = {'twitch_url': url}
|
update = {'twitch_url': url}
|
||||||
|
|
||||||
# Check to see if this user has already saved a twitch URL
|
# Check to see if this user has already saved a twitch URL
|
||||||
|
@ -185,7 +185,7 @@ class Twitch:
|
||||||
EXAMPLE: !twitch remove
|
EXAMPLE: !twitch remove
|
||||||
RESULT: I stop saving your twitch URL"""
|
RESULT: I stop saving your twitch URL"""
|
||||||
# Just try to remove it, if it doesn't exist, nothing is going to happen
|
# Just try to remove it, if it doesn't exist, nothing is going to happen
|
||||||
await utils.remove_content('twitch', ctx.message.author.id)
|
await utils.remove_content('twitch', str(ctx.message.author.id))
|
||||||
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.group(no_pm=True, invoke_without_command=True)
|
@twitch.group(no_pm=True, invoke_without_command=True)
|
||||||
|
@ -196,7 +196,7 @@ class Twitch:
|
||||||
|
|
||||||
EXAMPLE: !twitch notify
|
EXAMPLE: !twitch notify
|
||||||
RESULT: This server will now be notified when you go live"""
|
RESULT: This server will now be notified when you go live"""
|
||||||
key = ctx.message.author.id
|
key = str(ctx.message.author.id)
|
||||||
result = await utils.get_content('twitch', key)
|
result = await utils.get_content('twitch', key)
|
||||||
# Check if this user is saved at all
|
# Check if this user is saved at all
|
||||||
if result is None:
|
if result is None:
|
||||||
|
@ -204,10 +204,10 @@ 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['servers']:
|
elif str(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(str(ctx.message.guild.id))}, key)
|
||||||
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'], no_pm=True)
|
@notify.command(name='on', aliases=['start,yes'], no_pm=True)
|
||||||
|
@ -217,7 +217,7 @@ class Twitch:
|
||||||
|
|
||||||
EXAMPLE: !twitch notify on
|
EXAMPLE: !twitch notify on
|
||||||
RESULT: Notifications will be sent when you go live"""
|
RESULT: Notifications will be sent when you go live"""
|
||||||
if await utils.update_content('twitch', {"notifications_on": 1}, ctx.message.author.id):
|
if await utils.update_content('twitch', {"notifications_on": 1}, str(ctx.message.author.id)):
|
||||||
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:
|
||||||
|
@ -230,7 +230,7 @@ class Twitch:
|
||||||
|
|
||||||
EXAMPLE: !twitch notify off
|
EXAMPLE: !twitch notify off
|
||||||
RESULT: Notifications will not be sent when you go live"""
|
RESULT: Notifications will not be sent when you go live"""
|
||||||
if await utils.update_content('twitch', {"notifications_on": 1}, ctx.message.author.id):
|
if await utils.update_content('twitch', {"notifications_on": 1}, str(ctx.message.author.id)):
|
||||||
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(
|
||||||
|
|
|
@ -81,7 +81,7 @@ def custom_perms(**perms):
|
||||||
setattr(required_perm, perm, setting)
|
setattr(required_perm, perm, setting)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
server_settings = config.cache.get('server_settings').values[ctx.message.guild.id]
|
server_settings = config.cache.get('server_settings').values[str(ctx.message.guild.id)]
|
||||||
required_perm_value = server_settings['permissions'][ctx.command.qualified_name]
|
required_perm_value = server_settings['permissions'][ctx.command.qualified_name]
|
||||||
required_perm = discord.Permissions(required_perm_value)
|
required_perm = discord.Permissions(required_perm_value)
|
||||||
except (TypeError, IndexError, KeyError):
|
except (TypeError, IndexError, KeyError):
|
||||||
|
|
|
@ -119,7 +119,7 @@ def command_prefix(bot, message):
|
||||||
# If the prefix does exist in the database and isn't in our cache; too bad, something has messed up
|
# If the prefix does exist in the database and isn't in our cache; too bad, something has messed up
|
||||||
# But it is not worth a query for every single message the bot detects, to fix
|
# But it is not worth a query for every single message the bot detects, to fix
|
||||||
try:
|
try:
|
||||||
prefix = cache['server_settings'].values[message.guild.id]['prefix']
|
prefix = cache['server_settings'].values[str(message.guild.id)]['prefix']
|
||||||
return prefix or default_prefix
|
return prefix or default_prefix
|
||||||
except (KeyError, TypeError, IndexError, AttributeError, KeyError):
|
except (KeyError, TypeError, IndexError, AttributeError, KeyError):
|
||||||
return default_prefix
|
return default_prefix
|
||||||
|
|
|
@ -44,8 +44,8 @@ def get_subcommands(command):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def channel_is_nsfw(channel):
|
async def channel_is_nsfw(channel):
|
||||||
server = channel.guild.id
|
server = str(channel.guild.id)
|
||||||
channel = channel.id
|
channel = str(channel.id)
|
||||||
|
|
||||||
server_settings = await config.get_content('server_settings', server)
|
server_settings = await config.get_content('server_settings', server)
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ async def request(url, *, headers=None, payload=None, method='GET', attr='json')
|
||||||
async def update_records(key, winner, loser):
|
async def update_records(key, winner, loser):
|
||||||
# We're using the Harkness scale to rate
|
# We're using the Harkness scale to rate
|
||||||
# http://opnetchessclub.wikidot.com/harkness-rating-system
|
# http://opnetchessclub.wikidot.com/harkness-rating-system
|
||||||
r_filter = lambda row: (row['member_id'] == winner.id) | (row['member_id'] == loser.id)
|
r_filter = lambda row: (row['member_id'] == str(winner.id)) | (row['member_id'] == str(loser.id))
|
||||||
matches = await config.filter_content(key, r_filter)
|
matches = await config.filter_content(key, r_filter)
|
||||||
|
|
||||||
winner_stats = {}
|
winner_stats = {}
|
||||||
|
@ -157,9 +157,9 @@ async def update_records(key, winner, loser):
|
||||||
winner_stats = {'wins': winner_wins, 'losses': winner_losses, 'rating': winner_rating}
|
winner_stats = {'wins': winner_wins, 'losses': winner_losses, 'rating': winner_rating}
|
||||||
loser_stats = {'wins': loser_wins, 'losses': loser_losses, 'rating': loser_rating}
|
loser_stats = {'wins': loser_wins, 'losses': loser_losses, 'rating': loser_rating}
|
||||||
|
|
||||||
if not await config.update_content(key, winner_stats, {'member_id': winner.id}):
|
if not await config.update_content(key, winner_stats, str(winner.id)):
|
||||||
winner_stats['member_id'] = winner.id
|
winner_stats['member_id'] = str(winner.id)
|
||||||
await config.add_content(key, winner_stats)
|
await config.add_content(key, winner_stats)
|
||||||
if not await config.update_content(key, loser_stats, {'member_id': loser.id}):
|
if not await config.update_content(key, loser_stats, str(loser.id)):
|
||||||
loser_stats['member_id'] = loser.id
|
loser_stats['member_id'] = str(loser.id)
|
||||||
await config.add_content(key, loser_stats)
|
await config.add_content(key, loser_stats)
|
||||||
|
|
Loading…
Reference in a new issue