diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index a90bef4e9..0ac261a07 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -515,28 +515,25 @@ class Core: async def _set(self, ctx): """Changes Red's settings""" if ctx.invoked_subcommand is None: - admin_role_id = await ctx.bot.db.guild(ctx.guild).admin_role() - admin_role = discord.utils.get(ctx.guild.roles, id=admin_role_id) - mod_role_id = await ctx.bot.db.guild(ctx.guild).mod_role() - mod_role = discord.utils.get(ctx.guild.roles, id=mod_role_id) - prefixes = await ctx.bot.db.guild(ctx.guild).prefix() + if ctx.guild: + admin_role_id = await ctx.bot.db.guild(ctx.guild).admin_role() + admin_role = discord.utils.get(ctx.guild.roles, id=admin_role_id) or "Not set" + mod_role_id = await ctx.bot.db.guild(ctx.guild).mod_role() + 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: prefixes = await ctx.bot.db.prefix() locale = await ctx.bot.db.locale() + prefix_string = " ".join(prefixes) settings = ( - "{} Settings:\n\n" - "Prefixes: {}\n" - "Admin role: {}\n" - "Mod role: {}\n" - "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, - ) + f"{ctx.bot.user.name} Settings:\n\n" + f"Prefixes: {prefix_string}\n" + f"{guild_settings}" + f"Locale: {locale}" ) await ctx.send(box(settings)) await ctx.send_help()