diff --git a/cogs/interaction.py b/cogs/interaction.py index 4c85fdd..a00d78c 100644 --- a/cogs/interaction.py +++ b/cogs/interaction.py @@ -100,6 +100,7 @@ class Interaction: fmt = "{0.mention} has challenged you to a battle {1.mention}\n!accept or !decline" await self.bot.say(fmt.format(ctx.message.author, player2)) + await self.bot.delete_message(ctx.message) config.loop.call_later(180,battlingOff,ctx.message.author.id) @@ -129,6 +130,7 @@ class Interaction: await self.bot.say(fmt.format(battleP2.mention, battleP1.mention)) updateBattleRecords(battleP2, battleP1) + await self.bot.delete_message(ctx.message) battlingOff(ctx.message.author.id) @commands.command(pass_context=True, no_pm=True) @@ -149,6 +151,7 @@ class Interaction: await self.bot.say("{0} has chickened out! {1} wins by default!".format(battleP2.mention, battleP1.mention)) updateBattleRecords(battleP1, battleP2) + await self.bot.delete_message(ctx.message) battlingOff(ctx.message.author.id) @commands.command(pass_context=True, no_pm=True) @@ -184,12 +187,10 @@ class Interaction: booper_boops[boopee.id] = amount boops[ctx.message.author.id] = booper_boops - if config.saveContent('boops', boops): - fmt = "{0.mention} has just booped you {1.mention}! That's {2} times now!" - await self.bot.say(fmt.format(booper, boopee, amount)) - else: - await self.bot.say("I was unable to save this data") - await self.bot.whisper("```{}```".format(boops)) + config.saveContent('boops', boops): + fmt = "{0.mention} has just booped you {1.mention}! That's {2} times now!" + await self.bot.say(fmt.format(booper, boopee, amount)) + await self.bot.delete_message(ctx.message) def setup(bot): diff --git a/cogs/mod.py b/cogs/mod.py index cca6269..9f267fe 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -28,10 +28,8 @@ class Mod: await self.bot.say("This channel is already registered as 'nsfw'!") else: nsfw_channels.append(ctx.message.channel.id) - if config.saveContent('nsfw_channels', nsfw_channels): - await self.bot.say("This channel has just been registered as 'nsfw'! Have fun you naughties ;)") - else: - await self.bot.say("I was unable to save this data") + config.saveContent('nsfw_channels', nsfw_channels): + await self.bot.say("This channel has just been registered as 'nsfw'! Have fun you naughties ;)") @nsfw.command(name="remove", aliases=["delete"], pass_context=True, no_pm=True) @checks.customPermsOrRole("kick_members") @@ -42,10 +40,8 @@ class Mod: await self.bot.say("This channel is not registered as a ''nsfw' channel!") else: nsfw_channels.remove(ctx.message.channel.id) - if config.saveContent('nsfw_channels', nsfw_channels): - await self.bot.say("This channel has just been unregistered as a nsfw channel") - else: - await self.bot.say("I was unable to save this data") + config.saveContent('nsfw_channels', nsfw_channels): + await self.bot.say("This channel has just been unregistered as a nsfw channel") @commands.command(pass_context=True, no_pm=True) @checks.customPermsOrRole("manage_server") @@ -56,15 +52,14 @@ class Mod: @commands.command(pass_context=True, no_pm=True) @checks.customPermsOrRole("kick_members") - async def say(self, ctx, *msg: str): + async def say(self, ctx, *, msg: str): """Tells the bot to repeat what you say""" - msg = ' '.join(msg) await self.bot.say(msg) await self.bot.delete_message(ctx.message) @commands.group(pass_context=True, invoke_without_command=True, no_pm=True) @checks.customPermsOrRole("send_messages") - async def perms(self, ctx, *command: str): + async def perms(self, ctx, *, command: str): """This command can be used to print the current allowed permissions on a specific command This supports groups as well as subcommands; pass no argument to print a list of available permissions""" if command is None or len(command) == 0: @@ -72,14 +67,12 @@ class Mod: return command = " ".join(command) - custom_perms = config.getContent('custom_permissions') - if custom_perms is None: - await self.bot.say("There are no custom permissions setup on this server yet!") - return + custom_perms = config.getContent('custom_permissions') or {} server_perms = custom_perms.get(ctx.message.server.id) if server_perms is None: await self.bot.say("There are no custom permissions setup on this server yet!") return + command_perms = server_perms.get(command) if command_perms is None: await self.bot.say("That command has no custom permissions setup on it!") diff --git a/cogs/playlist.py b/cogs/playlist.py index 8eee5cd..1143b36 100644 --- a/cogs/playlist.py +++ b/cogs/playlist.py @@ -72,6 +72,7 @@ class Music: def __init__(self, bot): self.bot = bot self.voice_states = {} + self.max_songs = 10 def get_voice_state(self, server): state = self.voice_states.get(server.id) @@ -143,7 +144,11 @@ class Music: success = await ctx.invoke(self.summon) if not success: return - + + if len(state.songs) >= self.max_songs: + await self.bot.say("The queue is currently full! You'll need to wait to add a new song") + return + player = await state.voice.create_ytdl_player(song, ytdl_options=state.opts, after=state.toggle_next) player.volume = 0.6 entry = VoiceEntry(ctx.message, player) diff --git a/cogs/stats.py b/cogs/stats.py index c49bd20..da9272a 100644 --- a/cogs/stats.py +++ b/cogs/stats.py @@ -22,13 +22,12 @@ class Stats: await self.bot.say("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention)) return - most_boops = 0 - for b_id, amt in boops.get(ctx.message.author.id).items(): - member = discord.utils.find(lambda m: m.id == b_id, self.bot.get_all_members()) - if member in members and amt > most_boops: - most_boops = amt - most_id = b_id + server_member_ids = [member.id for member in ctx.message.server.members] + sorted_boops = sorted(boops.get(ctx.message.author.id).items(), key=lambda x: x[1], reverse=True) + sorted_boops = [x for x in sorted_boops if x[0] in server_member_ids] + most_boops = sorted_boops[0][1] + most_id = sorted_boops[0][0] member = discord.utils.find(lambda m: m.id == most_id, self.bot.get_all_members()) await self.bot.say("{0} you have booped {1} the most amount of times, coming in at {2} times".format( ctx.message.author.mention, member.mention, most_boops)) @@ -38,16 +37,17 @@ class Stats: async def listboops(self, ctx): """Lists all the users you have booped and the amount of times""" members = ctx.message.server.members - boops = config.getContent('boops') - if boops is None or boops.get(ctx.message.author.id) is None: + boops = config.getContent('boops') or {} + booped_members = boops.get(ctx.message.author.id) + if booped_members is None: await self.bot.say("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention)) return - output = "You have booped:" - for b_id, amt in boops.get(ctx.message.author.id).items(): - member = discord.utils.find(lambda m: m.id == b_id, self.bot.get_all_members()) - if member in members: - output += "\n{0.name}: {1} times".format(member, amt) - await self.bot.say("```{}```".format(output)) + + server_member_ids = [member.id for member in ctx.message.server.members] + booped_members = {m_id:amt for m_id,amt in booped_members.items() if m_id in server_member_ids] + + output = "\n".join("{0.display_name}: {1} times".format(discord.utils.get(self.bot.get_all_members(),id=m_id),amt) for m_id,amt in booped_members) + await self.bot.say("You have booped:```{}```".format(output)) @commands.command(pass_context=True, no_pm=True) @checks.customPermsOrRole("send_messages") @@ -67,7 +67,7 @@ class Stats: member = discord.utils.get(ctx.message.server.members,id=member_id) fmt += "#{}) {} (Rating: {})\n".format(count,member.display_name,stats.get('rating')) count += 1 - await self.bot.say("```{}```".format(fmt)) + await self.bot.say("You have booped:```{}```".format(fmt)) @commands.command(pass_context=True)