[V3 Core] Fix error on [p]set command when used in DM (#1748)

* issue #1741 fix

* requested changes
This commit is contained in:
Michael H 2018-06-01 19:26:12 -04:00 committed by Tobotimus
parent 34bd5ead15
commit 9f0e752318

View File

@ -515,28 +515,25 @@ class Core:
async def _set(self, ctx): async def _set(self, ctx):
"""Changes Red's settings""" """Changes Red's settings"""
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
admin_role_id = await ctx.bot.db.guild(ctx.guild).admin_role() if ctx.guild:
admin_role = discord.utils.get(ctx.guild.roles, id=admin_role_id) admin_role_id = await ctx.bot.db.guild(ctx.guild).admin_role()
mod_role_id = await ctx.bot.db.guild(ctx.guild).mod_role() admin_role = discord.utils.get(ctx.guild.roles, id=admin_role_id) or "Not set"
mod_role = discord.utils.get(ctx.guild.roles, id=mod_role_id) mod_role_id = await ctx.bot.db.guild(ctx.guild).mod_role()
prefixes = await ctx.bot.db.guild(ctx.guild).prefix() mod_role = discord.utils.get(ctx.guild.roles, id=mod_role_id) or "Not set"
prefixes = await ctx.bot.db.guild(ctx.guild).prefix()
guild_settings = f"Admin role: {admin_role}\nMod role: {mod_role}\n"
else:
guild_settings = ""
if not prefixes: if not prefixes:
prefixes = await ctx.bot.db.prefix() prefixes = await ctx.bot.db.prefix()
locale = await ctx.bot.db.locale() locale = await ctx.bot.db.locale()
prefix_string = " ".join(prefixes)
settings = ( settings = (
"{} Settings:\n\n" f"{ctx.bot.user.name} Settings:\n\n"
"Prefixes: {}\n" f"Prefixes: {prefix_string}\n"
"Admin role: {}\n" f"{guild_settings}"
"Mod role: {}\n" f"Locale: {locale}"
"Locale: {}"
"".format(
ctx.bot.user.name,
" ".join(prefixes),
admin_role.name if admin_role else "Not set",
mod_role.name if mod_role else "Not set",
locale,
)
) )
await ctx.send(box(settings)) await ctx.send(box(settings))
await ctx.send_help() await ctx.send_help()