[Core] Add bot.set_prefixes() (#3890)

* Add bot.set_prefixes; change set serverprefix and set prefix to new method

* Address requested changes

* Apply suggestions from code review

* One more

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Neuro Assassin
2020-05-30 18:57:49 -04:00
committed by GitHub
parent f1ba57b78b
commit 7a86cc4bf3
2 changed files with 26 additions and 4 deletions

View File

@@ -261,7 +261,7 @@ class CoreLogic:
The current (or new) list of prefixes.
"""
if prefixes:
await self.bot._prefix_cache.set_prefixes(guild=None, prefixes=prefixes)
await self.bot.set_prefixes(guild=None, prefixes=prefixes)
return prefixes
return await self.bot._prefix_cache.get_prefixes(guild=None)
@@ -1284,7 +1284,7 @@ class Core(commands.Cog, CoreLogic):
if not prefixes:
await ctx.send_help()
return
await self._prefixes(prefixes)
await ctx.bot.set_prefixes(guild=None, prefixes=prefixes)
await ctx.send(_("Prefix set."))
@_set.command(aliases=["serverprefixes"])
@@ -1293,11 +1293,11 @@ class Core(commands.Cog, CoreLogic):
async def serverprefix(self, ctx: commands.Context, *prefixes: str):
"""Sets [botname]'s server prefix(es)"""
if not prefixes:
await ctx.bot._prefix_cache.set_prefixes(guild=ctx.guild, prefixes=[])
await ctx.bot.set_prefixes(guild=ctx.guild, prefixes=[])
await ctx.send(_("Guild prefixes have been reset."))
return
prefixes = sorted(prefixes, reverse=True)
await ctx.bot._prefix_cache.set_prefixes(guild=ctx.guild, prefixes=prefixes)
await ctx.bot.set_prefixes(guild=ctx.guild, prefixes=prefixes)
await ctx.send(_("Prefix set."))
@_set.command()