mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 11:48:55 -05:00
[Core] Embeds toggle for channels. (#3418)
* [Core] Embedset toggle for channels. * Typo fix * Add to contact as well Thanks Jack. * Add guild only and check.
This commit is contained in:
parent
de4804863a
commit
41fdcb2ae8
1
changelog.d/3152.feature.rst
Normal file
1
changelog.d/3152.feature.rst
Normal file
@ -0,0 +1 @@
|
||||
Adds toggle for channels for embedset.
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user