diff --git a/changelog.d/3152.feature.rst b/changelog.d/3152.feature.rst new file mode 100644 index 000000000..ae12fe46f --- /dev/null +++ b/changelog.d/3152.feature.rst @@ -0,0 +1 @@ +Adds toggle for channels for embedset. \ No newline at end of file diff --git a/redbot/core/bot.py b/redbot/core/bot.py index 5eb2b027b..d113c9475 100644 --- a/redbot/core/bot.py +++ b/redbot/core/bot.py @@ -121,6 +121,7 @@ class RedBase(commands.GroupMixin, BotBase, RPCMixin): # pylint: disable=no-mem autoimmune_ids=[], ) + self._config.register_channel(embeds=None) self._config.register_user(embeds=None) self._config.init_custom(CUSTOM_GROUPS, 2) @@ -622,6 +623,9 @@ class RedBase(commands.GroupMixin, BotBase, RPCMixin): # pylint: disable=no-mem if user_setting is not None: return user_setting else: + channel_setting = await self._config.channel(channel).embeds() + if channel_setting is not None: + return channel_setting guild_setting = await self._config.guild(channel.guild).embeds() if guild_setting is not None: return guild_setting diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 0cee0ce2c..5eb7d6091 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -388,6 +388,9 @@ class Core(commands.Cog, CoreLogic): if ctx.guild: guild_setting = await self.bot._config.guild(ctx.guild).embeds() text += _("Guild setting: {}\n").format(guild_setting) + if ctx.channel: + channel_setting = await self.bot._config.channel(ctx.channel).embeds() + text += _("Channel setting: {}\n").format(channel_setting) user_setting = await self.bot._config.user(ctx.author).embeds() text += _("User setting: {}").format(user_setting) await ctx.send(box(text)) @@ -433,6 +436,31 @@ class Core(commands.Cog, CoreLogic): ) ) + @embedset.command(name="channel") + @checks.guildowner_or_permissions(administrator=True) + @commands.guild_only() + async def embedset_channel(self, ctx: commands.Context, enabled: bool = None): + """ + Toggle the channel's embed setting. + + If enabled is None, the setting will be unset and + the guild default will be used instead. + + If set, this is used instead of the guild default + to determine whether or not to use embeds. This is + used for all commands done in a channel except + for help commands. + """ + await self.bot._config.channel(ctx.channel).embeds.set(enabled) + if enabled is None: + await ctx.send(_("Embeds will now fall back to the global setting.")) + else: + await ctx.send( + _("Embeds are now {} for this channel.").format( + _("enabled") if enabled else _("disabled") + ) + ) + @embedset.command(name="user") async def embedset_user(self, ctx: commands.Context, enabled: bool = None): """ @@ -1484,7 +1512,9 @@ class Core(commands.Cog, CoreLogic): if not destination.permissions_for(destination.guild.me).send_messages: continue if destination.permissions_for(destination.guild.me).embed_links: - send_embed = await ctx.bot._config.guild(destination.guild).embeds() + send_embed = await ctx.bot._config.channel(destination).embeds() + if send_embed is None: + send_embed = await ctx.bot._config.guild(destination.guild).embeds() else: send_embed = False