diff --git a/cogs/da.py b/cogs/da.py index 533f30d..5b5ab0c 100644 --- a/cogs/da.py +++ b/cogs/da.py @@ -102,7 +102,7 @@ class Deviantart: # 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 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: tb = traceback.format_exc() fmt = "{1}\n{0.__class__.__name__}: {0}".format(tb, e) @@ -123,12 +123,12 @@ class Deviantart: EXAMPLE: !da sub MyFavoriteArtistEva<3 RESULT: Notifications of amazing pics c:""" - key = ctx.message.author.id + key = str(ctx.message.author.id) content = await utils.get_content('deviantart', key) # TODO: Ensure the user provided is a real user 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 ctx.send("You have just subscribed to {}!".format(username)) elif content['subbed'] is None or username not in content['subbed']: @@ -149,7 +149,7 @@ class Deviantart: EXAMPLE: !da unsub TheArtistWhoBetrayedMe 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) if content is None or content['subbed'] is None: diff --git a/cogs/events.py b/cogs/events.py index 41ebeba..a2d2804 100644 --- a/cogs/events.py +++ b/cogs/events.py @@ -54,7 +54,7 @@ class StatsUpdate: async def on_member_join(self, member): 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: join_leave_on = server_settings['join_leave'] @@ -65,12 +65,12 @@ class StatsUpdate: except (IndexError, TypeError): 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)) async def on_member_remove(self, member): 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: join_leave_on = server_settings['join_leave'] @@ -81,7 +81,7 @@ class StatsUpdate: except (IndexError, TypeError): 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)) diff --git a/cogs/interaction.py b/cogs/interaction.py index 98330e0..addd501 100644 --- a/cogs/interaction.py +++ b/cogs/interaction.py @@ -259,7 +259,7 @@ class Interaction: await ctx.send("Why the heck are you booping me? Get away from me >:c") return - key = booper.id + key = str(booper.id) boops = await utils.get_content('boops', key) if boops is not None: boops = boops['boops'] @@ -269,7 +269,7 @@ class Interaction: await utils.update_content('boops', {'boops': boops}, key) else: - entry = {'member_id': booper.id, + entry = {'member_id': str(booper.id), 'boops': {str(boopee.id): 1}} await utils.add_content('boops', entry) diff --git a/cogs/mod.py b/cogs/mod.py index e3eb177..634c4fe 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -107,9 +107,9 @@ class Mod: EXAMPLE: !alerts #alerts RESULT: No more alerts spammed in #general!""" - key = ctx.message.guild.id - entry = {'server_id': ctx.message.guild.id, - 'notification_channel': channel.id} + key = str(ctx.message.guild.id) + entry = {'server_id': key, + 'notification_channel': str(channel.id)} if not await utils.update_content('server_alerts', entry, key): await utils.add_content('server_alerts', entry) 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 # 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 - key = ctx.message.guild.id - entry = {'server_id': ctx.message.guild.id, + key = str(ctx.message.guild.id) + entry = {'server_id': key, 'join_leave': on_off} if not await utils.update_content('user_notifications', entry, key): await utils.add_content('user_notifications', entry) @@ -149,10 +149,10 @@ class Mod: EXAMPLE: !nsfw add RESULT: ;)""" - key = ctx.message.guild.id + key = str(ctx.message.guild.id) entry = {'server_id': key, - 'nsfw_channels': [ctx.message.channel.id]} - update = {'nsfw_channels': r.row['nsfw_channels'].append(ctx.message.channel.id)} + 'nsfw_channels': [str(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) if server_settings and 'nsfw_channels' in server_settings.keys(): @@ -172,9 +172,9 @@ class Mod: EXAMPLE: !nsfw remove RESULT: ;(""" - key = ctx.message.guild.id + key = str(ctx.message.guild.id) server_settings = await utils.get_content('server_settings', key) - channel = ctx.message.channel.id + channel = str(ctx.message.channel.id) try: channels = server_settings['nsfw_channels'] if channel in channels: @@ -222,7 +222,7 @@ class Mod: await ctx.send("That is not a valid command!") 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: server_perms = server_settings['permissions'] except (TypeError, IndexError): @@ -309,8 +309,8 @@ class Mod: await ctx.send("This command cannot have custom permissions setup!") return - key = ctx.message.guild.id - entry = {'server_id': ctx.message.guild.id, + key = str(ctx.message.guild.id) + entry = {'server_id': key, 'permissions': {cmd.qualified_name: perm_value}} if not await utils.update_content('server_settings', entry, key): @@ -335,7 +335,7 @@ class Mod: return 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)) @commands.command(no_pm=True) @@ -345,11 +345,11 @@ class Mod: EXAMPLE: !prefix new_prefix 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": prefix = None - entry = {'server_id': ctx.message.guild.id, + entry = {'server_id': key, 'prefix': prefix} if not await utils.update_content('server_settings', entry, key): @@ -451,8 +451,8 @@ class Mod: EXAMPLE: !rules 5 RESULT: Rule 5 is printed""" - server_settings = await utils.get_content('server_settings', ctx.message.guild.id) - rules = server_settings['rules'] + server_settings = await utils.get_content('server_settings', str(ctx.message.guild.id)) + rules = server_settings.get('rules') 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...") @@ -480,8 +480,8 @@ class Mod: EXAMPLE: !rules add No fun allowed in this server >:c RESULT: No more fun...unless they break the rules!""" - key = ctx.message.guild.id - entry = {'server_id': ctx.message.guild.id, + key = str(ctx.message.guild.id) + entry = {'server_id': key, 'rules': [rule]} update = {'rules': r.row['rules'].append(rule)} @@ -504,7 +504,7 @@ class Mod: EXAMPLE: !rules delete 5 RESULT: Freedom from opression!""" 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.") else: await ctx.send("I have just removed that rule from your list of rules!") diff --git a/cogs/overwatch.py b/cogs/overwatch.py index 4909749..fee2cbd 100644 --- a/cogs/overwatch.py +++ b/cogs/overwatch.py @@ -38,7 +38,7 @@ class Overwatch: await ctx.message.channel.trigger_typing() 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: 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 # However the API needs this to be a -, so repliace # with - if it exists 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 await ctx.send("Looking up your profile information....") @@ -109,7 +109,7 @@ class Overwatch: return # Now just save the battletag - entry = {'member_id': ctx.message.author.id, 'battletag': bt} + entry = {'member_id': key, 'battletag': bt} update = {'battletag': bt} # Try adding this first, if that fails, update the saved entry if not await utils.add_content('overwatch', entry): @@ -123,7 +123,7 @@ class Overwatch: EXAMPLE: !ow delete 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)) else: await ctx.send("I don't even have your battletag saved {}".format(ctx.message.author.mention)) diff --git a/cogs/picarto.py b/cogs/picarto.py index 92054cb..4adffa1 100644 --- a/cogs/picarto.py +++ b/cogs/picarto.py @@ -14,7 +14,7 @@ log = logging.getLogger() BASE_URL = 'https://ptvappapi.picarto.tv' # 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(): @@ -24,7 +24,7 @@ async def online_users(): # 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 url = BASE_URL + '/online/all' - payload = {'key': key} + payload = {'key': api_key} return await utils.request(url, payload=payload) except: return {} @@ -123,7 +123,7 @@ class Picarto: RESULT: Info about their picarto stream""" # If member is not given, base information on the 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: await ctx.send("That user does not have a picarto url setup!") return @@ -133,7 +133,7 @@ class Picarto: # 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) url = BASE_URL + '/channel/{}'.format(stream) - payload = {'key': key} + payload = {'key': api_key} data = await utils.request(url, payload=payload) @@ -176,19 +176,19 @@ class Picarto: url = "https://www.{}".format(url) channel = re.search("https://www.picarto.tv/(.*)", url).group(1) url = BASE_URL + '/channel/{}'.format(channel) - payload = {'key': key} + payload = {'key': api_key} data = await utils.request(url, payload=payload) if not data: await ctx.send("That Picarto user does not exist! What would be the point of adding a nonexistant Picarto " "user? Silly") return - key = ctx.message.author.id + key = str(ctx.message.author.id) entry = {'picarto_url': url, - 'servers': [ctx.message.guild.id], + 'servers': [str(ctx.message.guild.id)], 'notifications_on': 1, 'live': 0, - 'member_id': ctx.message.author.id} + 'member_id': key} if await utils.add_content('picarto', entry): await ctx.send( "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) async def remove_picarto_url(self, ctx): """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)) else: await ctx.send( @@ -216,7 +216,8 @@ class Picarto: EXAMPLE: !picarto notify 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 if result is None: await ctx.send( @@ -226,8 +227,7 @@ class Picarto: elif ctx.message.guild.id in result['servers']: await ctx.send("I am already set to notify in this guild...") else: - await utils.update_content('picarto', {'servers': r.row['servers'].append(ctx.message.guild.id)}, - ctx.message.author.id) + await utils.update_content('picarto', {'servers': r.row['servers'].append(str(ctx.message.guild.id))}, key) @notify.command(name='on', aliases=['start,yes'], no_pm=True) @utils.custom_perms(send_messages=True) @@ -236,7 +236,7 @@ class Picarto: EXAMPLE: !picarto notify on 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( ctx.message.author.mention)) @@ -247,7 +247,7 @@ class Picarto: EXAMPLE: !picarto notify off 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( "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( diff --git a/cogs/raffle.py b/cogs/raffle.py index bf555a3..6c0ee71 100644 --- a/cogs/raffle.py +++ b/cogs/raffle.py @@ -87,7 +87,7 @@ class Raffle: EXAMPLE: !raffles 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) if raffles is None: 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!""" # Lets let people use 1 - (length of raffles) and handle 0 base ourselves raffle_id -= 1 - r_filter = {'server_id': ctx.message.guild.id} + r_filter = {'server_id': str(ctx.message.guild.id)} author = ctx.message.author raffles = await utils.filter_content('raffles', r_filter) @@ -124,10 +124,10 @@ class Raffle: if raffle_count == 1: entrants = raffles[0]['entrants'] # 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!") return - entrants.append(author.id) + entrants.append(str(author.id)) update = {'entrants': entrants} await utils.update_content('raffles', update, raffles[0]['id']) @@ -137,10 +137,10 @@ class Raffle: entrants = raffles[raffle_id]['entrants'] # 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!") 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 update = {'entrants': entrants} @@ -231,8 +231,8 @@ class Raffle: entry = {'title': title, 'expires': expires.to_datetime_string(), 'entrants': [], - 'author': author.id, - 'server_id': server.id} + 'author': str(author.id), + 'server_id': str(server.id)} # We don't want to pass a filter to this, because we can have multiple raffles per server await utils.add_content('raffles', entry) diff --git a/cogs/stats.py b/cogs/stats.py index 9991279..8c11fff 100644 --- a/cogs/stats.py +++ b/cogs/stats.py @@ -137,7 +137,7 @@ class Stats: EXAMPLE: !mostboops 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: await ctx.send("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention)) return @@ -146,7 +146,7 @@ class Stats: boops = boops['boops'] # 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 # 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) @@ -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 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( ctx.message.author.mention, member.display_name, most_boops)) @@ -167,7 +167,7 @@ class Stats: EXAMPLE: !listboops 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: await ctx.send("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention)) return @@ -176,7 +176,7 @@ class Stats: boops = boops['boops'] # 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} 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 @@ -201,7 +201,7 @@ class Stats: EXAMPLE: !leaderboard 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 - 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 = [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') # 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!") return # 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] 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) # Enumurate the list so that we can go through, find the user's place in the list # 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 - total_rank = [i for i, x in enumerate(sorted_all_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'] == str(member.id)][0] + 1 # 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'] record = "{}-{}".format(entry['wins'], entry['losses']) try: diff --git a/cogs/twitch.py b/cogs/twitch.py index d52eb95..c52242b 100644 --- a/cogs/twitch.py +++ b/cogs/twitch.py @@ -114,7 +114,7 @@ class Twitch: if member is None: 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: await ctx.send("{} has not saved their twitch URL yet!".format(member.name)) return @@ -162,12 +162,12 @@ class Twitch: "What would be the point of adding a nonexistant twitch user? Silly") return - key = ctx.message.author.id + key = str(ctx.message.author.id) entry = {'twitch_url': url, - 'servers': [ctx.message.guild.id], + 'servers': [str(ctx.message.guild.id)], 'notifications_on': 1, 'live': 0, - 'member_id': ctx.message.author.id} + 'member_id': key} update = {'twitch_url': url} # Check to see if this user has already saved a twitch URL @@ -185,7 +185,7 @@ class Twitch: EXAMPLE: !twitch remove RESULT: I stop saving your twitch URL""" # 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)) @twitch.group(no_pm=True, invoke_without_command=True) @@ -196,7 +196,7 @@ class Twitch: EXAMPLE: !twitch notify 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) # Check if this user is saved at all 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( ctx.message.author.mention)) # 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...") 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") @notify.command(name='on', aliases=['start,yes'], no_pm=True) @@ -217,7 +217,7 @@ class Twitch: EXAMPLE: !twitch notify on 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( ctx.message.author.mention)) else: @@ -230,7 +230,7 @@ class Twitch: EXAMPLE: !twitch notify off 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( "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( diff --git a/cogs/utils/checks.py b/cogs/utils/checks.py index 51302cc..425d38d 100644 --- a/cogs/utils/checks.py +++ b/cogs/utils/checks.py @@ -81,7 +81,7 @@ def custom_perms(**perms): setattr(required_perm, perm, setting) 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 = discord.Permissions(required_perm_value) except (TypeError, IndexError, KeyError): diff --git a/cogs/utils/config.py b/cogs/utils/config.py index 5dac4ac..fc4cad4 100644 --- a/cogs/utils/config.py +++ b/cogs/utils/config.py @@ -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 # But it is not worth a query for every single message the bot detects, to fix 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 except (KeyError, TypeError, IndexError, AttributeError, KeyError): return default_prefix diff --git a/cogs/utils/utilities.py b/cogs/utils/utilities.py index b07a326..f465d9f 100644 --- a/cogs/utils/utilities.py +++ b/cogs/utils/utilities.py @@ -44,8 +44,8 @@ def get_subcommands(command): pass async def channel_is_nsfw(channel): - server = channel.guild.id - channel = channel.id + server = str(channel.guild.id) + channel = str(channel.id) 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): # We're using the Harkness scale to rate # 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) winner_stats = {} @@ -157,9 +157,9 @@ async def update_records(key, winner, loser): winner_stats = {'wins': winner_wins, 'losses': winner_losses, 'rating': winner_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}): - winner_stats['member_id'] = winner.id + if not await config.update_content(key, winner_stats, str(winner.id)): + winner_stats['member_id'] = str(winner.id) await config.add_content(key, winner_stats) - if not await config.update_content(key, loser_stats, {'member_id': loser.id}): - loser_stats['member_id'] = loser.id + if not await config.update_content(key, loser_stats, str(loser.id)): + loser_stats['member_id'] = str(loser.id) await config.add_content(key, loser_stats)