From 1f22410349226357ec9e5da3ee6226eaa1d01796 Mon Sep 17 00:00:00 2001 From: Ted Chen Date: Thu, 28 Mar 2019 09:00:43 -0700 Subject: [PATCH] Add configure_local command Add configure_local command which configures in same channel instead of using DM, as a workaround for sharding issue --- meowth/__main__.py | 472 ++++++++++++++++++++++++--------------------- 1 file changed, 250 insertions(+), 222 deletions(-) diff --git a/meowth/__main__.py b/meowth/__main__.py index 2aa52d96f..604214d48 100644 --- a/meowth/__main__.py +++ b/meowth/__main__.py @@ -1058,6 +1058,7 @@ async def on_ready(): 'archive': {'enabled':False, 'category':'same','list':None}, 'invite': {'enabled':False}, 'team':{'enabled':False}, + 'meetup': {'enabled':False, 'report_channels': {}, 'categories':'same','category_dict':{}}, 'settings':{'offset':0,'regional':None,'done':False,'prefix':None,'config_sessions':{}} }, 'wildreport_dict:':{}, @@ -1080,6 +1081,7 @@ async def on_ready(): 'archive': {'enabled':False, 'category':'same','list':None}, 'invite': {'enabled':False}, 'team':{'enabled':False}, + 'meetup': {'enabled':False, 'report_channels': {}, 'categories':'same','category_dict':{}}, 'settings':{'offset':0,'regional':None,'done':False,'prefix':None,'config_sessions':{}} }, 'wildreport_dict:':{}, @@ -1798,7 +1800,32 @@ async def configure(ctx, *, configlist: str=""): all, team, welcome, raid, exraid, invite, counters, wild, research, want, archive, timezone""" await _configure(ctx, configlist) -async def _configure(ctx, configlist): +@Meowth.group(case_insensitive=True, invoke_without_command=True) +@commands.has_permissions(manage_guild=True) +async def configure_local(ctx, *, configlist: str=""): + """Meowth Configuration + + Usage: !configure_local [list] + Meowth will reply with instructions on how to configure Meowth for your server. + If it is not your first time configuring, you can choose a section to jump to. + You can also include a comma separated [list] of sections from the following: + all, team, welcome, raid, exraid, invite, counters, wild, research, want, archive, timezone""" + await _configure(ctx, configlist, False) + +async def _configure_reply(ctx, **kwargs): + if guild_dict[ctx.guild.id]['configure_dict']['settings']['useDM']: + await ctx.message.author.send(**kwargs) + else: + await ctx.message.channel.send(**kwargs) + +async def _configure_receive_message(ctx, event): + if guild_dict[ctx.guild.id]['configure_dict']['settings']['useDM']: + myCheck = (lambda message: (message.guild == None) and message.author == ctx.message.author) + else: + myCheck = (lambda message: (message.guild == ctx.message.guild) and (message.channel == ctx.message.channel) and message.author == ctx.message.author) + return await Meowth.wait_for(event, check=myCheck) + +async def _configure(ctx, configlist, useDM=True): guild = ctx.message.guild owner = ctx.message.author try: @@ -1807,6 +1834,7 @@ async def _configure(ctx, configlist): pass config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions + guild_dict[ctx.guild.id]['configure_dict']['settings']['useDM'] = useDM for session in guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].keys(): if not guild.get_member(session): try: @@ -1830,9 +1858,9 @@ async def _configure(ctx, configlist): elif not diff: configreplylist = configlist else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry, I couldn't understand some of what you entered. Let's just start here."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry, I couldn't understand some of what you entered. Let's just start here."))) if config_dict_temp['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(config_dict_temp['settings']['config_sessions'].values()),yoursessions=config_dict_temp['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(config_dict_temp['settings']['config_sessions'].values()),yoursessions=config_dict_temp['settings']['config_sessions'][owner.id]))) configmessage = _("Meowth! That's Right! Welcome to the configuration for Meowth the Pokemon Go Helper Bot! I will be guiding you through some steps to get me setup on your server.\n\n**Role Setup**\nBefore you begin the configuration, please make sure my role is moved to the top end of the server role hierarchy. It can be under admins and mods, but must be above team and general roles. [Here is an example](http://i.imgur.com/c5eaX1u.png)") if not firstconfig and not configreplylist: configmessage += _("\n\n**Welcome Back**\nThis isn't your first time configuring. You can either reconfigure everything by replying with **all** or reply with a comma separated list to configure those commands. Example: `want, raid, wild`") @@ -1842,14 +1870,14 @@ async def _configure(ctx, configlist): configmessage += _("\n\n**Enabled Commands:**\n{enabled_commands}").format(enabled_commands=", ".join(enabled_commands)) configmessage += _("\n\n**All Commands:**\n**all** - To redo configuration\n**team** - For Team Assignment configuration\n**welcome** - For Welcome Message configuration\n**raid** - for raid command configuration\n**exraid** - for EX raid command configuration\n**invite** - for invite command configuration\n**counters** - for automatic counters configuration\n**wild** - for wild command configuration\n**research** - for !research command configuration\n**meetup** - for !meetup command configuration\n**want** - for want/unwant command configuration\n**archive** - For !archive configuration\n**trade** - For trade command configuration\n**timezone** - For timezone configuration") configmessage += _('\n\nReply with **cancel** at any time throughout the questions to cancel the configure process.') - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=configmessage).set_author(name=_('Meowth Configuration - {guild}').format(guild=guild.name), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=configmessage).set_author(name=_('Meowth Configuration - {guild}').format(guild=guild.name), icon_url=Meowth.user.avatar_url)) while True: def check(m): return m.guild == None and m.author == owner - configreply = await Meowth.wait_for('message', check=check) + configreply = await _configure_receive_message(ctx, 'message') configreply.content = configreply.content.replace("timezone", "settings") if configreply.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -1866,13 +1894,13 @@ def check(m): config_error = True break if config_error: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry I don't understand. Please reply with the choices above."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry I don't understand. Please reply with the choices above."))) continue else: break elif firstconfig == True: configmessage += _('\n\nReply with **cancel** at any time throughout the questions to cancel the configure process.') - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=configmessage).set_author(name=_('Meowth Configuration - {guild}').format(guild=guild.name), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=configmessage).set_author(name=_('Meowth Configuration - {guild}').format(guild=guild.name), icon_url=Meowth.user.avatar_url)) configreplylist = all_commands try: if "team" in configreplylist: @@ -1931,7 +1959,7 @@ def check(m): if ctx: ctx.config_dict_temp['settings']['done'] = True guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -1957,11 +1985,11 @@ async def team(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_team(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -1971,9 +1999,9 @@ async def _configure_team(ctx): guild = ctx.message.guild owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Team assignment allows users to assign their Pokemon Go team role using the **!team** command. If you have a bot that handles this already, you may want to disable this feature.\n\nIf you are to use this feature, ensure existing team roles are as follows: mystic, valor, instinct. These must be all lowercase letters. If they don't exist yet, I'll make some for you instead.\n\nRespond here with: **N** to disable, **Y** to enable:")).set_author(name=_('Team Assignments'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Team assignment allows users to assign their Pokemon Go team role using the **!team** command. If you have a bot that handles this already, you may want to disable this feature.\n\nIf you are to use this feature, ensure existing team roles are as follows: mystic, valor, instinct. These must be all lowercase letters. If they don't exist yet, I'll make some for you instead.\n\nRespond here with: **N** to disable, **Y** to enable:")).set_author(name=_('Team Assignments'), icon_url=Meowth.user.avatar_url)) while True: - teamreply = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + teamreply = await _configure_receive_message(ctx, 'message') if teamreply.content.lower() == 'y': config_dict_temp['team']['enabled'] = True high_roles = [] @@ -1990,17 +2018,17 @@ async def _configure_team(ctx): await guild.create_role(name=team, hoist=False, mentionable=True) except discord.errors.HTTPException: pass - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Team Assignments enabled!'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Team Assignments enabled!'))) break elif teamreply.content.lower() == 'n': config_dict_temp['team']['enabled'] = False - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Team Assignments disabled!'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Team Assignments disabled!'))) break elif teamreply.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry I don't understand. Please reply with either **N** to disable, or **Y** to enable."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry I don't understand. Please reply with either **N** to disable, or **Y** to enable."))) continue ctx.config_dict_temp = config_dict_temp return ctx @@ -2020,11 +2048,11 @@ async def welcome(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_welcome(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -2040,13 +2068,13 @@ async def _configure_welcome(ctx): else: welcomeconfig += _('Meowth! Welcome to {server_name}, {owner_name.mention}! If you have any questions just ask an admin.').format(server_name=guild, owner_name=owner) welcomeconfig += _('\n\nThis welcome message can be in a specific channel or a direct message. If you have a bot that handles this already, you may want to disable this feature.\n\nRespond with: **N** to disable, **Y** to enable:') - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=welcomeconfig).set_author(name=_('Welcome Message'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=welcomeconfig).set_author(name=_('Welcome Message'), icon_url=Meowth.user.avatar_url)) while True: - welcomereply = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + welcomereply = await _configure_receive_message(ctx, 'message') if welcomereply.content.lower() == 'y': config_dict_temp['welcome']['enabled'] = True - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Welcome Message enabled!'))) - await owner.send(embed=discord.Embed( + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Welcome Message enabled!'))) + await _configure_reply(ctx, embed=discord.Embed( colour=discord.Colour.lighter_grey(), description=(_("Would you like a custom welcome message? " "You can reply with **N** to use the default message above or enter your own below.\n\n" @@ -2059,18 +2087,18 @@ async def _configure_welcome(ctx): "**{server}** - Will print your server's name\n" "Surround your message with [] to send it as an embed. **Warning:** Mentions within embeds may be broken on mobile, this is a Discord bug."))).set_author(name=_("Welcome Message"), icon_url=Meowth.user.avatar_url)) if config_dict_temp['welcome']['welcomemsg'] != 'default': - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=config_dict_temp['welcome']['welcomemsg']).set_author(name=_("Current Welcome Message"), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=config_dict_temp['welcome']['welcomemsg']).set_author(name=_("Current Welcome Message"), icon_url=Meowth.user.avatar_url)) while True: - welcomemsgreply = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and (message.author == owner))) + welcomemsgreply = await _configure_receive_message(ctx, 'message') if welcomemsgreply.content.lower() == 'n': config_dict_temp['welcome']['welcomemsg'] = 'default' - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_("Default welcome message set"))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_("Default welcome message set"))) break elif welcomemsgreply.content.lower() == "cancel": - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_("**CONFIG CANCELLED!**\n\nNo changes have been made."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_("**CONFIG CANCELLED!**\n\nNo changes have been made."))) return None elif len(welcomemsgreply.content) > 500: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("Please shorten your message to less than 500 characters. You entered {count}.").format(count=len(welcomemsgreply.content)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("Please shorten your message to less than 500 characters. You entered {count}.").format(count=len(welcomemsgreply.content)))) continue else: welcomemessage, errors = do_template(welcomemsgreply.content, owner, guild) @@ -2078,47 +2106,47 @@ async def _configure_welcome(ctx): if welcomemessage.startswith("[") and welcomemessage.endswith("]"): embed = discord.Embed(colour=guild.me.colour, description=welcomemessage[1:-1].format(user=owner.mention)) embed.add_field(name=_('Warning'), value=_('The following could not be found:\n{}').format('\n'.join(errors))) - await owner.send(embed=embed) + await _configure_reply(ctx, embed=embed) else: - await owner.send(_("{msg}\n\n**Warning:**\nThe following could not be found: {errors}").format(msg=welcomemessage, errors=', '.join(errors))) - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("Please check the data given and retry a new welcome message, or reply with **N** to use the default."))) + await _configure_reply(ctx, _("{msg}\n\n**Warning:**\nThe following could not be found: {errors}").format(msg=welcomemessage, errors=', '.join(errors))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("Please check the data given and retry a new welcome message, or reply with **N** to use the default."))) continue else: if welcomemessage.startswith("[") and welcomemessage.endswith("]"): embed = discord.Embed(colour=guild.me.colour, description=welcomemessage[1:-1].format(user=owner.mention)) - question = await owner.send(content=_("Here's what you sent. Does it look ok?"),embed=embed) + question = await _configure_reply(ctx, content=_("Here's what you sent. Does it look ok?"),embed=embed) try: timeout = False res, reactuser = await ask(question, owner, owner.id) except TypeError: timeout = True else: - question = await owner.send(content=_("Here's what you sent. Does it look ok?\n\n{welcome}").format(welcome=welcomemessage.format(user=owner.mention))) + question = await _configure_reply(ctx, content=_("Here's what you sent. Does it look ok?\n\n{welcome}").format(welcome=welcomemessage.format(user=owner.mention))) try: timeout = False res, reactuser = await ask(question, owner, owner.id) except TypeError: timeout = True if timeout or res.emoji == '❎': - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("Please enter a new welcome message, or reply with **N** to use the default."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("Please enter a new welcome message, or reply with **N** to use the default."))) continue else: config_dict_temp['welcome']['welcomemsg'] = welcomemessage - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_("Welcome Message set to:\n\n{}").format(config_dict_temp['welcome']['welcomemsg']))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_("Welcome Message set to:\n\n{}").format(config_dict_temp['welcome']['welcomemsg']))) break break - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Which channel in your server would you like me to post the Welcome Messages? You can also choose to have them sent to the new member via Direct Message (DM) instead.\n\nRespond with: **channel-name** or ID of a channel in your server or **DM** to Direct Message:")).set_author(name=_("Welcome Message Channel"), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Which channel in your server would you like me to post the Welcome Messages? You can also choose to have them sent to the new member via Direct Message (DM) instead.\n\nRespond with: **channel-name** or ID of a channel in your server or **DM** to Direct Message:")).set_author(name=_("Welcome Message Channel"), icon_url=Meowth.user.avatar_url)) while True: - welcomechannelreply = await Meowth.wait_for('message',check=lambda message: message.guild == None and message.author == owner) + welcomechannelreply = await _configure_receive_message(ctx, 'message') if welcomechannelreply.content.lower() == "dm": config_dict_temp['welcome']['welcomechan'] = "dm" - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_("Welcome DM set"))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_("Welcome DM set"))) break elif " " in welcomechannelreply.content.lower(): - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("Channel names can't contain spaces, sorry. Please double check the name and send your response again."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("Channel names can't contain spaces, sorry. Please double check the name and send your response again."))) continue elif welcomechannelreply.content.lower() == "cancel": - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: item = welcomechannelreply.content @@ -2146,23 +2174,23 @@ async def _configure_welcome(ctx): try: await channel.set_permissions(Meowth.user, overwrite = ow) except (discord.errors.Forbidden, discord.errors.HTTPException, discord.errors.InvalidArgument): - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Welcome Channel set to {channel}').format(channel=welcomechannelreply.content.lower()))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Welcome Channel set to {channel}').format(channel=welcomechannelreply.content.lower()))) break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel you provided isn't in your server. Please double check your channel and resend your response."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel you provided isn't in your server. Please double check your channel and resend your response."))) continue break break elif welcomereply.content.lower() == 'n': config_dict_temp['welcome']['enabled'] = False - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Welcome Message disabled!'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Welcome Message disabled!'))) break elif welcomereply.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry I don't understand. Please reply with either **N** to disable, or **Y** to enable."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry I don't understand. Please reply with either **N** to disable, or **Y** to enable."))) continue ctx.config_dict_temp = config_dict_temp return ctx @@ -2182,11 +2210,11 @@ async def raid(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_raid(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -2196,16 +2224,16 @@ async def _configure_raid(ctx): guild = ctx.message.guild owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Raid Reporting allows users to report active raids with **!raid** or raid eggs with **!raidegg**. Pokemon raid reports are contained within one or more channels. Each channel will be able to represent different areas/communities. I'll need you to provide a list of channels in your server you will allow reports from in this format: `channel-name, channel-name, channel-name`\n\nExample: `kansas-city-raids, hull-raids, sydney-raids`\n\nIf you do not require raid or raid egg reporting, you may want to disable this function.\n\nRespond with: **N** to disable, or the **channel-name** list to enable, each seperated with a comma and space:")).set_author(name=_('Raid Reporting Channels'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Raid Reporting allows users to report active raids with **!raid** or raid eggs with **!raidegg**. Pokemon raid reports are contained within one or more channels. Each channel will be able to represent different areas/communities. I'll need you to provide a list of channels in your server you will allow reports from in this format: `channel-name, channel-name, channel-name`\n\nExample: `kansas-city-raids, hull-raids, sydney-raids`\n\nIf you do not require raid or raid egg reporting, you may want to disable this function.\n\nRespond with: **N** to disable, or the **channel-name** list to enable, each seperated with a comma and space:")).set_author(name=_('Raid Reporting Channels'), icon_url=Meowth.user.avatar_url)) citychannel_dict = {} while True: - citychannels = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + citychannels = await _configure_receive_message(ctx, 'message') if citychannels.content.lower() == 'n': config_dict_temp['raid']['enabled'] = False - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Raid Reporting disabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Raid Reporting disabled'))) break elif citychannels.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: config_dict_temp['raid']['enabled'] = True @@ -2234,7 +2262,7 @@ async def _configure_raid(ctx): citychannel_list = [x.id for x in citychannel_objs] diff = set(citychannel_list) - set(guild_channel_list) if (not diff) and (not citychannel_errors): - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Raid Reporting Channels enabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Raid Reporting Channels enabled'))) for channel in citychannel_objs: ow = channel.overwrites_for(Meowth.user) ow.send_messages = True @@ -2243,18 +2271,18 @@ async def _configure_raid(ctx): try: await channel.set_permissions(Meowth.user, overwrite = ow) except (discord.errors.Forbidden, discord.errors.HTTPException, discord.errors.InvalidArgument): - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(citychannel_errors)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(citychannel_errors)))) continue if config_dict_temp['raid']['enabled']: - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('For each report, I generate Google Maps links to give people directions to the raid or egg! To do this, I need to know which suburb/town/region each report channel represents, to ensure we get the right location in the map. For each report channel you provided, I will need its corresponding general location using only letters and spaces, with each location seperated by a comma and space.\n\nExample: `kansas city mo, hull uk, sydney nsw australia`\n\nEach location will have to be in the same order as you provided the channels in the previous question.\n\nRespond with: **location info, location info, location info** each matching the order of the previous channel list below.')).set_author(name=_('Raid Reporting Locations'), icon_url=Meowth.user.avatar_url)) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('For each report, I generate Google Maps links to give people directions to the raid or egg! To do this, I need to know which suburb/town/region each report channel represents, to ensure we get the right location in the map. For each report channel you provided, I will need its corresponding general location using only letters and spaces, with each location seperated by a comma and space.\n\nExample: `kansas city mo, hull uk, sydney nsw australia`\n\nEach location will have to be in the same order as you provided the channels in the previous question.\n\nRespond with: **location info, location info, location info** each matching the order of the previous channel list below.')).set_author(name=_('Raid Reporting Locations'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) while True: - cities = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + cities = await _configure_receive_message(ctx, 'message') if cities.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None city_list = cities.content.split(',') city_list = [x.strip() for x in city_list] @@ -2263,20 +2291,20 @@ async def _configure_raid(ctx): citychannel_dict[citychannel_list[i]] = city_list[i] break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The number of cities doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n{channellist}\n{citylist}\n\nPlease double check that your locations match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), citylist=', '.join(city_list)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The number of cities doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n{channellist}\n{citylist}\n\nPlease double check that your locations match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), citylist=', '.join(city_list)))) continue config_dict_temp['raid']['report_channels'] = citychannel_dict - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Raid Reporting Locations are set'))) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("How would you like me to categorize the raid channels I create? Your options are:\n\n**none** - If you don't want them categorized\n**same** - If you want them in the same category as the reporting channel\n**region** - If you want them categorized by region\n**level** - If you want them categorized by level.")).set_author(name=_('Raid Reporting Categories'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Raid Reporting Locations are set'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("How would you like me to categorize the raid channels I create? Your options are:\n\n**none** - If you don't want them categorized\n**same** - If you want them in the same category as the reporting channel\n**region** - If you want them categorized by region\n**level** - If you want them categorized by level.")).set_author(name=_('Raid Reporting Categories'), icon_url=Meowth.user.avatar_url)) while True: guild = Meowth.get_guild(guild.id) guild_catlist = [] for cat in guild.categories: guild_catlist.append(cat.id) category_dict = {} - categories = await Meowth.wait_for('message', check=lambda message: message.guild == None and message.author == owner) + categories = await _configure_receive_message(ctx, 'message') if categories.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None elif categories.content.lower() == 'none': config_dict_temp['raid']['categories'] = None @@ -2291,11 +2319,11 @@ async def _configure_raid(ctx): for cat in guild.categories: guild_catlist.append(cat.id) config_dict_temp['raid']['categories'] = 'region' - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(),description=_("In the same order as they appear below, please give the names of the categories you would like raids reported in each channel to appear in. You do not need to use different categories for each channel, but they do need to be pre-existing categories. Separate each category name with a comma. Response can be either category name or ID.\n\nExample: `kansas city, hull, 1231231241561337813`\n\nYou have configured the following channels as raid reporting channels.")).set_author(name=_('Raid Reporting Categories'), icon_url=Meowth.user.avatar_url)) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) - regioncats = await Meowth.wait_for('message', check=lambda message: message.guild == None and message.author == owner) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(),description=_("In the same order as they appear below, please give the names of the categories you would like raids reported in each channel to appear in. You do not need to use different categories for each channel, but they do need to be pre-existing categories. Separate each category name with a comma. Response can be either category name or ID.\n\nExample: `kansas city, hull, 1231231241561337813`\n\nYou have configured the following channels as raid reporting channels.")).set_author(name=_('Raid Reporting Categories'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) + regioncats = await _configure_receive_message(ctx, 'message') if regioncats.content.lower() == "cancel": - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None regioncat_list = regioncats.content.split(',') regioncat_list = [x.strip() for x in regioncat_list] @@ -2326,13 +2354,13 @@ async def _configure_raid(ctx): if regioncat_errors: msg += _("\n\nThe following aren't in your server: **{invalid_categories}**").format(invalid_categories=', '.join(regioncat_errors)) msg += _("\n\nPlease double check your category list and resend your response. If you just made these categories, try again.") - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(),description=msg)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(),description=msg)) continue else: msg = _("The number of categories I found in your server doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n**Matched Channels:** {channellist}\n**Matched Categories:** {catlist}\n\nPlease double check that your categories match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), catlist=', '.join(regioncat_names) if len(regioncat_list)>0 else "None") if regioncat_errors: msg += _("\n\nThe following aren't in your server: **{invalid_categories}**").format(invalid_categories=', '.join(regioncat_errors)) - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=msg)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=msg)) continue break elif categories.content.lower() == 'level': @@ -2342,10 +2370,10 @@ async def _configure_raid(ctx): guild_catlist = [] for cat in guild.categories: guild_catlist.append(cat.id) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(),description=_("Pokemon Go currently has five levels of raids. Please provide the names of the categories you would like each level of raid to appear in. Use the following order: 1, 2, 3, 4, 5 \n\nYou do not need to use different categories for each level, but they do need to be pre-existing categories. Separate each category name with a comma. Response can be either category name or ID.\n\nExample: `level 1-3, level 1-3, level 1-3, level 4, 1231231241561337813`")).set_author(name=_('Raid Reporting Categories'), icon_url=Meowth.user.avatar_url)) - levelcats = await Meowth.wait_for('message', check=lambda message: message.guild == None and message.author == owner) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(),description=_("Pokemon Go currently has five levels of raids. Please provide the names of the categories you would like each level of raid to appear in. Use the following order: 1, 2, 3, 4, 5 \n\nYou do not need to use different categories for each level, but they do need to be pre-existing categories. Separate each category name with a comma. Response can be either category name or ID.\n\nExample: `level 1-3, level 1-3, level 1-3, level 4, 1231231241561337813`")).set_author(name=_('Raid Reporting Categories'), icon_url=Meowth.user.avatar_url)) + levelcats = await _configure_receive_message(ctx, 'message') if levelcats.content.lower() == "cancel": - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None levelcat_list = levelcats.content.split(',') levelcat_list = [x.strip() for x in levelcat_list] @@ -2377,19 +2405,19 @@ async def _configure_raid(ctx): if levelcat_errors: msg += _("\n\nThe following aren't in your server: **{invalid_categories}**").format(invalid_categories=', '.join(levelcat_errors)) msg += _("\n\nPlease double check your category list and resend your response. If you just made these categories, try again.") - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(),description=msg)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(),description=msg)) continue else: msg = _("The number of categories I found in your server doesn't match the number of raid levels! Make sure you give me exactly six categories, one for each level of raid. You can use the same category for multiple levels if you want, but I need to see five category names.\n\n**Matched Categories:** {catlist}\n\nPlease double check your categories.").format(catlist=', '.join(levelcat_names) if len(levelcat_list)>0 else "None") if levelcat_errors: msg += _("\n\nThe following aren't in your server: **{invalid_categories}**").format(invalid_categories=', '.join(levelcat_errors)) - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=msg)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=msg)) continue else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(),description=_("Sorry, I didn't understand your answer! Try again."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(),description=_("Sorry, I didn't understand your answer! Try again."))) continue break - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Raid Categories are set'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Raid Categories are set'))) config_dict_temp['raid']['category_dict'] = category_dict ctx.config_dict_temp = config_dict_temp return ctx @@ -2409,11 +2437,11 @@ async def exraid(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_exraid(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -2423,16 +2451,16 @@ async def _configure_exraid(ctx): guild = ctx.message.guild owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("EX Raid Reporting allows users to report EX raids with **!exraid**. Pokemon EX raid reports are contained within one or more channels. Each channel will be able to represent different areas/communities. I'll need you to provide a list of channels in your server you will allow reports from in this format: `channel-name, channel-name, channel-name`\n\nExample: `kansas-city-raids, hull-raids, sydney-raids`\n\nIf you do not require EX raid reporting, you may want to disable this function.\n\nRespond with: **N** to disable, or the **channel-name** list to enable, each seperated with a comma and space:")).set_author(name=_('EX Raid Reporting Channels'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("EX Raid Reporting allows users to report EX raids with **!exraid**. Pokemon EX raid reports are contained within one or more channels. Each channel will be able to represent different areas/communities. I'll need you to provide a list of channels in your server you will allow reports from in this format: `channel-name, channel-name, channel-name`\n\nExample: `kansas-city-raids, hull-raids, sydney-raids`\n\nIf you do not require EX raid reporting, you may want to disable this function.\n\nRespond with: **N** to disable, or the **channel-name** list to enable, each seperated with a comma and space:")).set_author(name=_('EX Raid Reporting Channels'), icon_url=Meowth.user.avatar_url)) citychannel_dict = {} while True: - citychannels = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + citychannels = await _configure_receive_message(ctx, 'message') if citychannels.content.lower() == 'n': config_dict_temp['exraid']['enabled'] = False - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('EX Raid Reporting disabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('EX Raid Reporting disabled'))) break elif citychannels.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: config_dict_temp['exraid']['enabled'] = True @@ -2461,7 +2489,7 @@ async def _configure_exraid(ctx): citychannel_list = [x.id for x in citychannel_objs] diff = set(citychannel_list) - set(guild_channel_list) if (not diff) and (not citychannel_errors): - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('EX Raid Reporting Channels enabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('EX Raid Reporting Channels enabled'))) for channel in citychannel_objs: ow = channel.overwrites_for(Meowth.user) ow.send_messages = True @@ -2470,18 +2498,18 @@ async def _configure_exraid(ctx): try: await channel.set_permissions(Meowth.user, overwrite = ow) except (discord.errors.Forbidden, discord.errors.HTTPException, discord.errors.InvalidArgument): - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(citychannel_errors)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(citychannel_errors)))) continue if config_dict_temp['exraid']['enabled']: - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('For each report, I generate Google Maps links to give people directions to EX raids! To do this, I need to know which suburb/town/region each report channel represents, to ensure we get the right location in the map. For each report channel you provided, I will need its corresponding general location using only letters and spaces, with each location seperated by a comma and space.\n\nExample: `kansas city mo, hull uk, sydney nsw australia`\n\nEach location will have to be in the same order as you provided the channels in the previous question.\n\nRespond with: **location info, location info, location info** each matching the order of the previous channel list below.')).set_author(name=_('EX Raid Reporting Locations'), icon_url=Meowth.user.avatar_url)) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('For each report, I generate Google Maps links to give people directions to EX raids! To do this, I need to know which suburb/town/region each report channel represents, to ensure we get the right location in the map. For each report channel you provided, I will need its corresponding general location using only letters and spaces, with each location seperated by a comma and space.\n\nExample: `kansas city mo, hull uk, sydney nsw australia`\n\nEach location will have to be in the same order as you provided the channels in the previous question.\n\nRespond with: **location info, location info, location info** each matching the order of the previous channel list below.')).set_author(name=_('EX Raid Reporting Locations'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) while True: - cities = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + cities = await _configure_receive_message(ctx, 'message') if cities.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None city_list = cities.content.split(',') city_list = [x.strip() for x in city_list] @@ -2490,20 +2518,20 @@ async def _configure_exraid(ctx): citychannel_dict[citychannel_list[i]] = city_list[i] break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The number of cities doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n{channellist}\n{citylist}\n\nPlease double check that your locations match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), citylist=', '.join(city_list)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The number of cities doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n{channellist}\n{citylist}\n\nPlease double check that your locations match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), citylist=', '.join(city_list)))) continue config_dict_temp['exraid']['report_channels'] = citychannel_dict - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('EX Raid Reporting Locations are set'))) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("How would you like me to categorize the EX raid channels I create? Your options are:\n\n**none** - If you don't want them categorized\n**same** - If you want them in the same category as the reporting channel\n**other** - If you want them categorized in a provided category name or ID")).set_author(name=_('EX Raid Reporting Categories'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('EX Raid Reporting Locations are set'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("How would you like me to categorize the EX raid channels I create? Your options are:\n\n**none** - If you don't want them categorized\n**same** - If you want them in the same category as the reporting channel\n**other** - If you want them categorized in a provided category name or ID")).set_author(name=_('EX Raid Reporting Categories'), icon_url=Meowth.user.avatar_url)) while True: guild = Meowth.get_guild(guild.id) guild_catlist = [] for cat in guild.categories: guild_catlist.append(cat.id) category_dict = {} - categories = await Meowth.wait_for('message', check=lambda message: message.guild == None and message.author == owner) + categories = await _configure_receive_message(ctx, 'message') if categories.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None elif categories.content.lower() == 'none': config_dict_temp['exraid']['categories'] = None @@ -2518,11 +2546,11 @@ async def _configure_exraid(ctx): for cat in guild.categories: guild_catlist.append(cat.id) config_dict_temp['exraid']['categories'] = 'region' - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(),description=_("In the same order as they appear below, please give the names of the categories you would like raids reported in each channel to appear in. You do not need to use different categories for each channel, but they do need to be pre-existing categories. Separate each category name with a comma. Response can be either category name or ID.\n\nExample: `kansas city, hull, 1231231241561337813`\n\nYou have configured the following channels as EX raid reporting channels.")).set_author(name=_('EX Raid Reporting Categories'), icon_url=Meowth.user.avatar_url)) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) - regioncats = await Meowth.wait_for('message', check=lambda message: message.guild == None and message.author == owner) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(),description=_("In the same order as they appear below, please give the names of the categories you would like raids reported in each channel to appear in. You do not need to use different categories for each channel, but they do need to be pre-existing categories. Separate each category name with a comma. Response can be either category name or ID.\n\nExample: `kansas city, hull, 1231231241561337813`\n\nYou have configured the following channels as EX raid reporting channels.")).set_author(name=_('EX Raid Reporting Categories'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) + regioncats = await _configure_receive_message(ctx, 'message') if regioncats.content.lower() == "cancel": - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None regioncat_list = regioncats.content.split(',') regioncat_list = [x.strip() for x in regioncat_list] @@ -2553,37 +2581,37 @@ async def _configure_exraid(ctx): if regioncat_errors: msg += _("\n\nThe following aren't in your server: **{invalid_categories}**").format(invalid_categories=', '.join(regioncat_errors)) msg += _("\n\nPlease double check your category list and resend your response. If you just made these categories, try again.") - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(),description=msg)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(),description=msg)) continue else: msg = _("The number of categories I found in your server doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n**Matched Channels:** {channellist}\n**Matched Categories:** {catlist}\n\nPlease double check that your categories match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), catlist=', '.join(regioncat_names) if len(regioncat_list)>0 else "None") if regioncat_errors: msg += _("\n\nThe following aren't in your server: **{invalid_categories}**").format(invalid_categories=', '.join(regioncat_errors)) - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=msg)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=msg)) continue break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(),description=_("Sorry, I didn't understand your answer! Try again."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(),description=_("Sorry, I didn't understand your answer! Try again."))) continue break - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('EX Raid Categories are set'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('EX Raid Categories are set'))) config_dict_temp['exraid']['category_dict'] = category_dict - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Who do you want to be able to **see** the EX Raid channels? Your options are:\n\n**everyone** - To have everyone be able to see all reported EX Raids\n**same** - To only allow those with access to the reporting channel.")).set_author(name=_('EX Raid Channel Read Permissions'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Who do you want to be able to **see** the EX Raid channels? Your options are:\n\n**everyone** - To have everyone be able to see all reported EX Raids\n**same** - To only allow those with access to the reporting channel.")).set_author(name=_('EX Raid Channel Read Permissions'), icon_url=Meowth.user.avatar_url)) while True: - permsconfigset = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + permsconfigset = await _configure_receive_message(ctx, 'message') if permsconfigset.content.lower() == 'everyone': config_dict_temp['exraid']['permissions'] = "everyone" - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Everyone permission enabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Everyone permission enabled'))) break elif permsconfigset.content.lower() == 'same': config_dict_temp['exraid']['permissions'] = "same" - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Same permission enabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Same permission enabled'))) break elif permsconfigset.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry I don't understand. Please reply with either **N** to disable, or **Y** to enable."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry I don't understand. Please reply with either **N** to disable, or **Y** to enable."))) continue ctx.config_dict_temp = config_dict_temp return ctx @@ -2603,11 +2631,11 @@ async def invite(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_invite(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -2617,22 +2645,22 @@ async def _configure_invite(ctx): guild = ctx.message.guild owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('Do you want access to EX raids controlled through members using the **!invite** command?\nIf enabled, members will have read-only permissions for all EX Raids until they use **!invite** to gain access. If disabled, EX Raids will inherit the permissions from their reporting channels.\n\nRespond with: **N** to disable, or **Y** to enable:')).set_author(name=_('Invite Configuration'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('Do you want access to EX raids controlled through members using the **!invite** command?\nIf enabled, members will have read-only permissions for all EX Raids until they use **!invite** to gain access. If disabled, EX Raids will inherit the permissions from their reporting channels.\n\nRespond with: **N** to disable, or **Y** to enable:')).set_author(name=_('Invite Configuration'), icon_url=Meowth.user.avatar_url)) while True: - inviteconfigset = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + inviteconfigset = await _configure_receive_message(ctx, 'message') if inviteconfigset.content.lower() == 'y': config_dict_temp['invite']['enabled'] = True - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Invite Command enabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Invite Command enabled'))) break elif inviteconfigset.content.lower() == 'n': config_dict_temp['invite']['enabled'] = False - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Invite Command disabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Invite Command disabled'))) break elif inviteconfigset.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry I don't understand. Please reply with either **N** to disable, or **Y** to enable."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("I'm sorry I don't understand. Please reply with either **N** to disable, or **Y** to enable."))) continue ctx.config_dict_temp = config_dict_temp return ctx @@ -2654,7 +2682,7 @@ async def counters(ctx): ctx = await _configure_counters(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -2664,16 +2692,16 @@ async def _configure_counters(ctx): guild = ctx.message.guild owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('Do you want to generate an automatic counters list in newly created raid channels using PokeBattler?\nIf enabled, I will post a message containing the best counters for the raid boss in new raid channels. Users will still be able to use **!counters** to generate this list.\n\nRespond with: **N** to disable, or enable with a comma separated list of boss levels that you would like me to generate counters for. Example:`3,4,5,EX`')).set_author(name=_('Automatic Counters Configuration'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('Do you want to generate an automatic counters list in newly created raid channels using PokeBattler?\nIf enabled, I will post a message containing the best counters for the raid boss in new raid channels. Users will still be able to use **!counters** to generate this list.\n\nRespond with: **N** to disable, or enable with a comma separated list of boss levels that you would like me to generate counters for. Example:`3,4,5,EX`')).set_author(name=_('Automatic Counters Configuration'), icon_url=Meowth.user.avatar_url)) while True: - countersconfigset = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + countersconfigset = await _configure_receive_message(ctx, 'message') if countersconfigset.content.lower() == 'n': config_dict_temp['counters']['enabled'] = False config_dict_temp['counters']['auto_levels'] = [] - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Automatic Counters disabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Automatic Counters disabled'))) break elif countersconfigset.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: raidlevel_list = countersconfigset.content.lower().split(',') @@ -2687,10 +2715,10 @@ async def _configure_counters(ctx): if len(counterlevels) > 0: config_dict_temp['counters']['enabled'] = True config_dict_temp['counters']['auto_levels'] = counterlevels - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Automatic Counter Levels set to: {levels}').format(levels=', '.join((str(x) for x in config_dict_temp['counters']['auto_levels']))))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Automatic Counter Levels set to: {levels}').format(levels=', '.join((str(x) for x in config_dict_temp['counters']['auto_levels']))))) break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("Please enter at least one level from 1 to EX separated by comma. Ex: `4,5,EX` or **N** to turn off automatic counters."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("Please enter at least one level from 1 to EX separated by comma. Ex: `4,5,EX` or **N** to turn off automatic counters."))) continue ctx.config_dict_temp = config_dict_temp return ctx @@ -2710,11 +2738,11 @@ async def wild(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_wild(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -2724,16 +2752,16 @@ async def _configure_wild(ctx): guild = ctx.message.guild owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Wild Reporting allows users to report wild spawns with **!wild**. Pokemon **wild** reports are contained within one or more channels. Each channel will be able to represent different areas/communities. I'll need you to provide a list of channels in your server you will allow reports from in this format: `channel-name, channel-name, channel-name`\n\nExample: `kansas-city-wilds, hull-wilds, sydney-wilds`\n\nIf you do not require **wild** reporting, you may want to disable this function.\n\nRespond with: **N** to disable, or the **channel-name** list to enable, each seperated with a comma and space:")).set_author(name=_('Wild Reporting Channels'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Wild Reporting allows users to report wild spawns with **!wild**. Pokemon **wild** reports are contained within one or more channels. Each channel will be able to represent different areas/communities. I'll need you to provide a list of channels in your server you will allow reports from in this format: `channel-name, channel-name, channel-name`\n\nExample: `kansas-city-wilds, hull-wilds, sydney-wilds`\n\nIf you do not require **wild** reporting, you may want to disable this function.\n\nRespond with: **N** to disable, or the **channel-name** list to enable, each seperated with a comma and space:")).set_author(name=_('Wild Reporting Channels'), icon_url=Meowth.user.avatar_url)) citychannel_dict = {} while True: - citychannels = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + citychannels = await _configure_receive_message(ctx, 'message') if citychannels.content.lower() == 'n': config_dict_temp['wild']['enabled'] = False - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Wild Reporting disabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Wild Reporting disabled'))) break elif citychannels.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: config_dict_temp['wild']['enabled'] = True @@ -2762,7 +2790,7 @@ async def _configure_wild(ctx): citychannel_list = [x.id for x in citychannel_objs] diff = set(citychannel_list) - set(guild_channel_list) if (not diff) and (not citychannel_errors): - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Wild Reporting Channels enabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Wild Reporting Channels enabled'))) for channel in citychannel_objs: ow = channel.overwrites_for(Meowth.user) ow.send_messages = True @@ -2771,18 +2799,18 @@ async def _configure_wild(ctx): try: await channel.set_permissions(Meowth.user, overwrite = ow) except (discord.errors.Forbidden, discord.errors.HTTPException, discord.errors.InvalidArgument): - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(citychannel_errors)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(citychannel_errors)))) continue if config_dict_temp['wild']['enabled']: - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('For each report, I generate Google Maps links to give people directions to wild spawns! To do this, I need to know which suburb/town/region each report channel represents, to ensure we get the right location in the map. For each report channel you provided, I will need its corresponding general location using only letters and spaces, with each location seperated by a comma and space.\n\nExample: `kansas city mo, hull uk, sydney nsw australia`\n\nEach location will have to be in the same order as you provided the channels in the previous question.\n\nRespond with: **location info, location info, location info** each matching the order of the previous channel list below.')).set_author(name=_('Wild Reporting Locations'), icon_url=Meowth.user.avatar_url)) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('For each report, I generate Google Maps links to give people directions to wild spawns! To do this, I need to know which suburb/town/region each report channel represents, to ensure we get the right location in the map. For each report channel you provided, I will need its corresponding general location using only letters and spaces, with each location seperated by a comma and space.\n\nExample: `kansas city mo, hull uk, sydney nsw australia`\n\nEach location will have to be in the same order as you provided the channels in the previous question.\n\nRespond with: **location info, location info, location info** each matching the order of the previous channel list below.')).set_author(name=_('Wild Reporting Locations'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) while True: - cities = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + cities = await _configure_receive_message(ctx, 'message') if cities.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None city_list = cities.content.split(',') city_list = [x.strip() for x in city_list] @@ -2791,10 +2819,10 @@ async def _configure_wild(ctx): citychannel_dict[citychannel_list[i]] = city_list[i] break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The number of cities doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n{channellist}\n{citylist}\n\nPlease double check that your locations match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), citylist=', '.join(city_list)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The number of cities doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n{channellist}\n{citylist}\n\nPlease double check that your locations match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), citylist=', '.join(city_list)))) continue config_dict_temp['wild']['report_channels'] = citychannel_dict - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Wild Reporting Locations are set'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Wild Reporting Locations are set'))) ctx.config_dict_temp = config_dict_temp return ctx @@ -2813,11 +2841,11 @@ async def research(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_research(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -2827,16 +2855,16 @@ async def _configure_research(ctx): guild = ctx.message.guild owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Research Reporting allows users to report field research with **!research**. Pokemon **research** reports are contained within one or more channels. Each channel will be able to represent different areas/communities. I'll need you to provide a list of channels in your server you will allow reports from in this format: `channel-name, channel-name, channel-name`\n\nExample: `kansas-city-research, hull-research, sydney-research`\n\nIf you do not require **research** reporting, you may want to disable this function.\n\nRespond with: **N** to disable, or the **channel-name** list to enable, each seperated with a comma and space:")).set_author(name=_('Research Reporting Channels'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Research Reporting allows users to report field research with **!research**. Pokemon **research** reports are contained within one or more channels. Each channel will be able to represent different areas/communities. I'll need you to provide a list of channels in your server you will allow reports from in this format: `channel-name, channel-name, channel-name`\n\nExample: `kansas-city-research, hull-research, sydney-research`\n\nIf you do not require **research** reporting, you may want to disable this function.\n\nRespond with: **N** to disable, or the **channel-name** list to enable, each seperated with a comma and space:")).set_author(name=_('Research Reporting Channels'), icon_url=Meowth.user.avatar_url)) citychannel_dict = {} while True: - citychannels = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + citychannels = await _configure_receive_message(ctx, 'message') if citychannels.content.lower() == 'n': config_dict_temp['research']['enabled'] = False - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Research Reporting disabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Research Reporting disabled'))) break elif citychannels.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: config_dict_temp['research']['enabled'] = True @@ -2865,7 +2893,7 @@ async def _configure_research(ctx): citychannel_list = [x.id for x in citychannel_objs] diff = set(citychannel_list) - set(guild_channel_list) if (not diff) and (not citychannel_errors): - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Research Reporting Channels enabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Research Reporting Channels enabled'))) for channel in citychannel_objs: ow = channel.overwrites_for(Meowth.user) ow.send_messages = True @@ -2874,18 +2902,18 @@ async def _configure_research(ctx): try: await channel.set_permissions(Meowth.user, overwrite = ow) except (discord.errors.Forbidden, discord.errors.HTTPException, discord.errors.InvalidArgument): - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(citychannel_errors)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(citychannel_errors)))) continue if config_dict_temp['research']['enabled']: - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('For each report, I generate Google Maps links to give people directions to field research! To do this, I need to know which suburb/town/region each report channel represents, to ensure we get the right location in the map. For each report channel you provided, I will need its corresponding general location using only letters and spaces, with each location seperated by a comma and space.\n\nExample: `kansas city mo, hull uk, sydney nsw australia`\n\nEach location will have to be in the same order as you provided the channels in the previous question.\n\nRespond with: **location info, location info, location info** each matching the order of the previous channel list below.')).set_author(name=_('Research Reporting Locations'), icon_url=Meowth.user.avatar_url)) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('For each report, I generate Google Maps links to give people directions to field research! To do this, I need to know which suburb/town/region each report channel represents, to ensure we get the right location in the map. For each report channel you provided, I will need its corresponding general location using only letters and spaces, with each location seperated by a comma and space.\n\nExample: `kansas city mo, hull uk, sydney nsw australia`\n\nEach location will have to be in the same order as you provided the channels in the previous question.\n\nRespond with: **location info, location info, location info** each matching the order of the previous channel list below.')).set_author(name=_('Research Reporting Locations'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) while True: - cities = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + cities = await _configure_receive_message(ctx, 'message') if cities.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None city_list = cities.content.split(',') city_list = [x.strip() for x in city_list] @@ -2894,10 +2922,10 @@ async def _configure_research(ctx): citychannel_dict[citychannel_list[i]] = city_list[i] break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The number of cities doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n{channellist}\n{citylist}\n\nPlease double check that your locations match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), citylist=', '.join(city_list)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The number of cities doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n{channellist}\n{citylist}\n\nPlease double check that your locations match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), citylist=', '.join(city_list)))) continue config_dict_temp['research']['report_channels'] = citychannel_dict - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Research Reporting Locations are set'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Research Reporting Locations are set'))) ctx.config_dict_temp = config_dict_temp return ctx @@ -2916,11 +2944,11 @@ async def meetup(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_meetup(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -2931,16 +2959,16 @@ async def _configure_meetup(ctx): owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) config_dict_temp['meetup'] = {} - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meetup Reporting allows users to report meetups with **!meetup** or **!event**. Meetup reports are contained within one or more channels. Each channel will be able to represent different areas/communities. I'll need you to provide a list of channels in your server you will allow reports from in this format: `channel-name, channel-name, channel-name`\n\nExample: `kansas-city-meetups, hull-meetups, sydney-meetups`\n\nIf you do not require meetup reporting, you may want to disable this function.\n\nRespond with: **N** to disable, or the **channel-name** list to enable, each seperated with a comma and space:")).set_author(name=_('Meetup Reporting Channels'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meetup Reporting allows users to report meetups with **!meetup** or **!event**. Meetup reports are contained within one or more channels. Each channel will be able to represent different areas/communities. I'll need you to provide a list of channels in your server you will allow reports from in this format: `channel-name, channel-name, channel-name`\n\nExample: `kansas-city-meetups, hull-meetups, sydney-meetups`\n\nIf you do not require meetup reporting, you may want to disable this function.\n\nRespond with: **N** to disable, or the **channel-name** list to enable, each seperated with a comma and space:")).set_author(name=_('Meetup Reporting Channels'), icon_url=Meowth.user.avatar_url)) citychannel_dict = {} while True: - citychannels = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + citychannels = await _configure_receive_message(ctx, 'message') if citychannels.content.lower() == 'n': config_dict_temp['meetup']['enabled'] = False - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Meetup Reporting disabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Meetup Reporting disabled'))) break elif citychannels.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: config_dict_temp['meetup']['enabled'] = True @@ -2969,7 +2997,7 @@ async def _configure_meetup(ctx): citychannel_list = [x.id for x in citychannel_objs] diff = set(citychannel_list) - set(guild_channel_list) if (not diff) and (not citychannel_errors): - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Meetup Reporting Channels enabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Meetup Reporting Channels enabled'))) for channel in citychannel_objs: ow = channel.overwrites_for(Meowth.user) ow.send_messages = True @@ -2978,18 +3006,18 @@ async def _configure_meetup(ctx): try: await channel.set_permissions(Meowth.user, overwrite = ow) except (discord.errors.Forbidden, discord.errors.HTTPException, discord.errors.InvalidArgument): - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(citychannel_errors)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(citychannel_errors)))) continue if config_dict_temp['meetup']['enabled']: - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('For each report, I generate Google Maps links to give people directions to meetups! To do this, I need to know which suburb/town/region each report channel represents, to ensure we get the right location in the map. For each report channel you provided, I will need its corresponding general location using only letters and spaces, with each location seperated by a comma and space.\n\nExample: `kansas city mo, hull uk, sydney nsw australia`\n\nEach location will have to be in the same order as you provided the channels in the previous question.\n\nRespond with: **location info, location info, location info** each matching the order of the previous channel list below.')).set_author(name=_('Meetup Reporting Locations'), icon_url=Meowth.user.avatar_url)) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('For each report, I generate Google Maps links to give people directions to meetups! To do this, I need to know which suburb/town/region each report channel represents, to ensure we get the right location in the map. For each report channel you provided, I will need its corresponding general location using only letters and spaces, with each location seperated by a comma and space.\n\nExample: `kansas city mo, hull uk, sydney nsw australia`\n\nEach location will have to be in the same order as you provided the channels in the previous question.\n\nRespond with: **location info, location info, location info** each matching the order of the previous channel list below.')).set_author(name=_('Meetup Reporting Locations'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) while True: - cities = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + cities = await _configure_receive_message(ctx, 'message') if cities.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None city_list = cities.content.split(',') city_list = [x.strip() for x in city_list] @@ -2998,20 +3026,20 @@ async def _configure_meetup(ctx): citychannel_dict[citychannel_list[i]] = city_list[i] break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The number of cities doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n{channellist}\n{citylist}\n\nPlease double check that your locations match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), citylist=', '.join(city_list)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The number of cities doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n{channellist}\n{citylist}\n\nPlease double check that your locations match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), citylist=', '.join(city_list)))) continue config_dict_temp['meetup']['report_channels'] = citychannel_dict - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Meetup Reporting Locations are set'))) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("How would you like me to categorize the meetup channels I create? Your options are:\n\n**none** - If you don't want them categorized\n**same** - If you want them in the same category as the reporting channel\n**other** - If you want them categorized in a provided category name or ID")).set_author(name=_('Meetup Reporting Categories'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Meetup Reporting Locations are set'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("How would you like me to categorize the meetup channels I create? Your options are:\n\n**none** - If you don't want them categorized\n**same** - If you want them in the same category as the reporting channel\n**other** - If you want them categorized in a provided category name or ID")).set_author(name=_('Meetup Reporting Categories'), icon_url=Meowth.user.avatar_url)) while True: guild = Meowth.get_guild(guild.id) guild_catlist = [] for cat in guild.categories: guild_catlist.append(cat.id) category_dict = {} - categories = await Meowth.wait_for('message', check=lambda message: message.guild == None and message.author == owner) + categories = await _configure_receive_message(ctx, 'message') if categories.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None elif categories.content.lower() == 'none': config_dict_temp['meetup']['categories'] = None @@ -3026,11 +3054,11 @@ async def _configure_meetup(ctx): for cat in guild.categories: guild_catlist.append(cat.id) config_dict_temp['meetup']['categories'] = 'region' - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(),description=_("In the same order as they appear below, please give the names of the categories you would like raids reported in each channel to appear in. You do not need to use different categories for each channel, but they do need to be pre-existing categories. Separate each category name with a comma. Response can be either category name or ID.\n\nExample: `kansas city, hull, 1231231241561337813`\n\nYou have configured the following channels as meetup reporting channels.")).set_author(name=_('Meetup Reporting Categories'), icon_url=Meowth.user.avatar_url)) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) - regioncats = await Meowth.wait_for('message', check=lambda message: message.guild == None and message.author == owner) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(),description=_("In the same order as they appear below, please give the names of the categories you would like raids reported in each channel to appear in. You do not need to use different categories for each channel, but they do need to be pre-existing categories. Separate each category name with a comma. Response can be either category name or ID.\n\nExample: `kansas city, hull, 1231231241561337813`\n\nYou have configured the following channels as meetup reporting channels.")).set_author(name=_('Meetup Reporting Categories'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_('{citychannel_list}').format(citychannel_list=citychannels.content.lower()[:2000])).set_author(name=_('Entered Channels'), icon_url=Meowth.user.avatar_url)) + regioncats = await _configure_receive_message(ctx, 'message') if regioncats.content.lower() == "cancel": - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None regioncat_list = regioncats.content.split(',') regioncat_list = [x.strip() for x in regioncat_list] @@ -3061,20 +3089,20 @@ async def _configure_meetup(ctx): if regioncat_errors: msg += _("\n\nThe following aren't in your server: **{invalid_categories}**").format(invalid_categories=', '.join(regioncat_errors)) msg += _("\n\nPlease double check your category list and resend your response. If you just made these categories, try again.") - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(),description=msg)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(),description=msg)) continue else: msg = _("The number of categories I found in your server doesn't match the number of channels you gave me earlier!\n\nI'll show you the two lists to compare:\n\n**Matched Channels:** {channellist}\n**Matched Categories:** {catlist}\n\nPlease double check that your categories match up with your provided channels and resend your response.").format(channellist=', '.join(citychannel_names), catlist=', '.join(regioncat_names) if len(regioncat_list)>0 else "None") if regioncat_errors: msg += _("\n\nThe following aren't in your server: **{invalid_categories}**").format(invalid_categories=', '.join(regioncat_errors)) - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=msg)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=msg)) continue break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(),description=_("Sorry, I didn't understand your answer! Try again."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(),description=_("Sorry, I didn't understand your answer! Try again."))) continue break - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Meetup Categories are set'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Meetup Categories are set'))) config_dict_temp['meetup']['category_dict'] = category_dict ctx.config_dict_temp = config_dict_temp return ctx @@ -3094,11 +3122,11 @@ async def want(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_want(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -3108,15 +3136,15 @@ async def _configure_want(ctx): guild = ctx.message.guild owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("The **!want** and **!unwant** commands let you add or remove roles for Pokemon that will be mentioned in reports. This let you get notifications on the Pokemon you want to track. I just need to know what channels you want to allow people to manage their pokemon with the **!want** and **!unwant** command.\n\nIf you don't want to allow the management of tracked Pokemon roles, then you may want to disable this feature.\n\nRepond with: **N** to disable, or the **channel-name** list to enable, each seperated by a comma and space.")).set_author(name=_('Pokemon Notifications'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("The **!want** and **!unwant** commands let you add or remove roles for Pokemon that will be mentioned in reports. This let you get notifications on the Pokemon you want to track. I just need to know what channels you want to allow people to manage their pokemon with the **!want** and **!unwant** command.\n\nIf you don't want to allow the management of tracked Pokemon roles, then you may want to disable this feature.\n\nRepond with: **N** to disable, or the **channel-name** list to enable, each seperated by a comma and space.")).set_author(name=_('Pokemon Notifications'), icon_url=Meowth.user.avatar_url)) while True: - wantchs = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + wantchs = await _configure_receive_message(ctx, 'message') if wantchs.content.lower() == 'n': config_dict_temp['want']['enabled'] = False - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Pokemon Notifications disabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Pokemon Notifications disabled'))) break elif wantchs.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: want_list = wantchs.content.lower().split(',') @@ -3154,11 +3182,11 @@ async def _configure_want(ctx): try: await channel.set_permissions(Meowth.user, overwrite = ow) except (discord.errors.Forbidden, discord.errors.HTTPException, discord.errors.InvalidArgument): - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Pokemon Notifications enabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Pokemon Notifications enabled'))) break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(want_list_errors)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(want_list_errors)))) continue ctx.config_dict_temp = config_dict_temp return ctx @@ -3178,11 +3206,11 @@ async def archive(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_archive(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -3192,21 +3220,21 @@ async def _configure_archive(ctx): guild = ctx.message.guild owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("The **!archive** command marks temporary raid channels for archival rather than deletion. This can be useful for investigating potential violations of your server's rules in these channels.\n\nIf you would like to disable this feature, reply with **N**. Otherwise send the category you would like me to place archived channels in. You can say **same** to keep them in the same category, or type the name or ID of a category in your server.")).set_author(name=_('Archive Configuration'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("The **!archive** command marks temporary raid channels for archival rather than deletion. This can be useful for investigating potential violations of your server's rules in these channels.\n\nIf you would like to disable this feature, reply with **N**. Otherwise send the category you would like me to place archived channels in. You can say **same** to keep them in the same category, or type the name or ID of a category in your server.")).set_author(name=_('Archive Configuration'), icon_url=Meowth.user.avatar_url)) config_dict_temp['archive'] = {} while True: - archivemsg = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + archivemsg = await _configure_receive_message(ctx, 'message') if archivemsg.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None if archivemsg.content.lower() == 'same': config_dict_temp['archive']['category'] = 'same' config_dict_temp['archive']['enabled'] = True - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Archived channels will remain in the same category.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Archived channels will remain in the same category.'))) break if archivemsg.content.lower() == 'n': config_dict_temp['archive']['enabled'] = False - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Archived Channels disabled.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Archived Channels disabled.'))) break else: item = archivemsg.content @@ -3217,27 +3245,27 @@ async def _configure_archive(ctx): name = await letter_case(guild.categories, item.lower()) category = discord.utils.get(guild.categories, name=name) if not category: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("I couldn't find the category you replied with! Please reply with **same** to leave archived channels in the same category, or give the name or ID of an existing category."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("I couldn't find the category you replied with! Please reply with **same** to leave archived channels in the same category, or give the name or ID of an existing category."))) continue config_dict_temp['archive']['category'] = category.id config_dict_temp['archive']['enabled'] = True - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Archive category set.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Archive category set.'))) break if config_dict_temp['archive']['enabled']: - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("I can also listen in your raid channels for words or phrases that you want to trigger an automatic archival. For example, if discussion of spoofing is against your server rules, you might tell me to listen for the word 'spoofing'.\n\nReply with **none** to disable this feature, or reply with a comma separated list of phrases you want me to listen in raid channels for.")).set_author(name=_('Archive Configuration'), icon_url=Meowth.user.avatar_url)) - phrasemsg = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("I can also listen in your raid channels for words or phrases that you want to trigger an automatic archival. For example, if discussion of spoofing is against your server rules, you might tell me to listen for the word 'spoofing'.\n\nReply with **none** to disable this feature, or reply with a comma separated list of phrases you want me to listen in raid channels for.")).set_author(name=_('Archive Configuration'), icon_url=Meowth.user.avatar_url)) + phrasemsg = await _configure_receive_message(ctx, 'message') if phrasemsg.content.lower() == 'none': config_dict_temp['archive']['list'] = None - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Phrase list disabled.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Phrase list disabled.'))) elif phrasemsg.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: phrase_list = phrasemsg.content.lower().split(",") for i in range(len(phrase_list)): phrase_list[i] = phrase_list[i].strip() config_dict_temp['archive']['list'] = phrase_list - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Archive Phrase list set.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Archive Phrase list set.'))) ctx.config_dict_temp = config_dict_temp return ctx @@ -3256,11 +3284,11 @@ async def timezone(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_settings(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -3270,25 +3298,25 @@ async def _configure_settings(ctx): guild = ctx.message.guild owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("There are a few settings available that are not within **!configure**. To set these, use **!set ** in any channel to set that setting.\n\nThese include:\n**!set regional ** - To set a server's regional raid boss\n**!set prefix ** - To set my command prefix\n**!set timezone ** - To set offset outside of **!configure**\n**!set silph ** - To set a trainer's SilphRoad card (usable by members)\n**!set pokebattler ** - To set a trainer's pokebattler ID (usable by members)\n\nHowever, we can do your timezone now to help coordinate reports for you. For others, use the **!set** command.\n\nThe current 24-hr time UTC is {utctime}. How many hours off from that are you?\n\nRespond with: A number from **-12** to **12**:").format(utctime=strftime('%H:%M', time.gmtime()))).set_author(name=_('Timezone Configuration and Other Settings'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("There are a few settings available that are not within **!configure**. To set these, use **!set ** in any channel to set that setting.\n\nThese include:\n**!set regional ** - To set a server's regional raid boss\n**!set prefix ** - To set my command prefix\n**!set timezone ** - To set offset outside of **!configure**\n**!set silph ** - To set a trainer's SilphRoad card (usable by members)\n**!set pokebattler ** - To set a trainer's pokebattler ID (usable by members)\n\nHowever, we can do your timezone now to help coordinate reports for you. For others, use the **!set** command.\n\nThe current 24-hr time UTC is {utctime}. How many hours off from that are you?\n\nRespond with: A number from **-12** to **12**:").format(utctime=strftime('%H:%M', time.gmtime()))).set_author(name=_('Timezone Configuration and Other Settings'), icon_url=Meowth.user.avatar_url)) while True: - offsetmsg = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + offsetmsg = await _configure_receive_message(ctx, 'message') if offsetmsg.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None else: try: offset = float(offsetmsg.content) except ValueError: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("I couldn't convert your answer to an appropriate timezone!\n\nPlease double check what you sent me and resend a number strarting from **-12** to **12**."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("I couldn't convert your answer to an appropriate timezone!\n\nPlease double check what you sent me and resend a number strarting from **-12** to **12**."))) continue if (not ((- 12) <= offset <= 14)): - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("I couldn't convert your answer to an appropriate timezone!\n\nPlease double check what you sent me and resend a number strarting from **-12** to **12**."))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("I couldn't convert your answer to an appropriate timezone!\n\nPlease double check what you sent me and resend a number strarting from **-12** to **12**."))) continue else: break config_dict_temp['settings']['offset'] = offset - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Timezone set'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Timezone set'))) ctx.config_dict_temp = config_dict_temp return ctx @@ -3307,11 +3335,11 @@ async def trade(ctx): config_sessions = guild_dict[ctx.guild.id]['configure_dict']['settings'].setdefault('config_sessions',{}).setdefault(owner.id,0) + 1 guild_dict[ctx.guild.id]['configure_dict']['settings']['config_sessions'][owner.id] = config_sessions if guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] > 1: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("**MULTIPLE SESSIONS!**\n\nIt looks like you have **{yoursessions}** active configure sessions. I recommend you send **cancel** first and then send your request again to avoid confusing me.\n\nYour Sessions: **{yoursessions}** | Total Sessions: **{allsessions}**").format(allsessions=sum(guild_dict[guild.id]['configure_dict']['settings']['config_sessions'].values()),yoursessions=guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id]))) ctx = await _configure_trade(ctx) if ctx: guild_dict[guild.id]['configure_dict'] = ctx.config_dict_temp - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("Meowth! Alright! Your settings have been saved and I'm ready to go! If you need to change any of these settings, just type **!configure** in your server again.")).set_author(name=_('Configuration Complete'), icon_url=Meowth.user.avatar_url)) try: del guild_dict[guild.id]['configure_dict']['settings']['config_sessions'][owner.id] except KeyError: @@ -3321,15 +3349,15 @@ async def _configure_trade(ctx): guild = ctx.message.guild owner = ctx.message.author config_dict_temp = getattr(ctx, 'config_dict_temp',copy.deepcopy(guild_dict[guild.id]['configure_dict'])) - await owner.send(embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("The **!trade** command allows your users to organize and coordinate trades. This command requires at least one channel specifically for trades.\n\nIf you would like to disable this feature, reply with **N**. Otherwise, just send the names or IDs of the channels you want to allow the **!trade** command in, separated by commas.")).set_author(name=_('Trade Configuration'), icon_url=Meowth.user.avatar_url)) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.lighter_grey(), description=_("The **!trade** command allows your users to organize and coordinate trades. This command requires at least one channel specifically for trades.\n\nIf you would like to disable this feature, reply with **N**. Otherwise, just send the names or IDs of the channels you want to allow the **!trade** command in, separated by commas.")).set_author(name=_('Trade Configuration'), icon_url=Meowth.user.avatar_url)) while True: - trademsg = await Meowth.wait_for('message', check=(lambda message: (message.guild == None) and message.author == owner)) + trademsg = await _configure_receive_message(ctx, 'message') if trademsg.content.lower() == 'cancel': - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('**CONFIG CANCELLED!**\n\nNo changes have been made.'))) return None elif trademsg.content.lower() == 'n': config_dict_temp['trade'] = {'enabled': False, 'report_channels': []} - await owner.send(embed=discord.Embed(colour=discord.Colour.red(), description=_('Trade disabled.'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.red(), description=_('Trade disabled.'))) break else: trade_list = trademsg.content.lower().split(',') @@ -3367,11 +3395,11 @@ async def _configure_trade(ctx): try: await channel.set_permissions(Meowth.user, overwrite = ow) except (discord.errors.Forbidden, discord.errors.HTTPException, discord.errors.InvalidArgument): - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) - await owner.send(embed=discord.Embed(colour=discord.Colour.green(), description=_('Pokemon Trades enabled'))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_('I couldn\'t set my own permissions in this channel. Please ensure I have the correct permissions in {channel} using **{prefix}get perms**.').format(prefix=ctx.prefix, channel=channel.mention))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.green(), description=_('Pokemon Trades enabled'))) break else: - await owner.send(embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(trade_list_errors)))) + await _configure_reply(ctx, embed=discord.Embed(colour=discord.Colour.orange(), description=_("The channel list you provided doesn't match with your servers channels.\n\nThe following aren't in your server: **{invalid_channels}**\n\nPlease double check your channel list and resend your reponse.").format(invalid_channels=', '.join(trade_list_errors)))) continue ctx.config_dict_temp = config_dict_temp return ctx @@ -4925,7 +4953,7 @@ async def _invite(ctx): await channel.send(_('Meowth! No EX Raids have been reported in this server! Use **!exraid** to report one!')) return exraidchoice = await channel.send(_("Meowth! {0}, you've told me you have an invite to an EX Raid, and I'm just going to take your word for it! The following {1} EX Raids have been reported:\n{2}\nReply with **the number** (1, 2, etc) of the EX Raid you have been invited to. If none of them match your invite, type 'N' and report it with **!exraid**").format(author.mention, str(exraidcount), exraidlist)) - reply = await bot.wait_for('message', check=(lambda message: (message.author == author))) + reply = await _configure_receive_message(ctx, 'message') if reply.content.lower() == 'n': await exraidchoice.delete() exraidmsg = await channel.send(_('Meowth! Be sure to report your EX Raid with **!exraid**!')) @@ -4989,7 +5017,7 @@ async def research(ctx, *, details = None): research_embed.add_field(name=_('**New Research Report**'), value=_("Meowth! I'll help you report a research quest!\n\nFirst, I'll need to know what **pokestop** you received the quest from. Reply with the name of the **pokestop**. You can reply with **cancel** to stop anytime."), inline=False) pokestopwait = await channel.send(embed=research_embed) try: - pokestopmsg = await Meowth.wait_for('message', timeout=60, check=(lambda reply: reply.author == message.author)) + pokestopmsg = await _configure_receive_message(ctx, 'message') except asyncio.TimeoutError: pokestopmsg = None await pokestopwait.delete()