[V3 Core] implement commands and settings for embeds (#1437)

* [V3 Core] add settings for whether to use embeds or not

* Implement commands to toggle embed settings

* Add a function to context for finding whether to use embeds or not

* Hide [p]embedset for now

* Move embed_requested to bot

* Add a simple helper in context
This commit is contained in:
palmtree5
2018-03-20 16:17:40 -08:00
committed by Kowlin
parent 01b9843883
commit 83471e0866
3 changed files with 135 additions and 2 deletions

View File

@@ -58,7 +58,8 @@ class RedBase(BotBase, RpcMethodMixin):
whitelist=[],
blacklist=[],
enable_sentry=None,
locale='en'
locale='en',
embeds=True
)
self.db.register_guild(
@@ -66,7 +67,12 @@ class RedBase(BotBase, RpcMethodMixin):
whitelist=[],
blacklist=[],
admin_role=None,
mod_role=None
mod_role=None,
embeds=None
)
self.db.register_user(
embeds=None
)
async def prefix_manager(bot, message):
@@ -136,6 +142,38 @@ class RedBase(BotBase, RpcMethodMixin):
indict['owner_id'] = await self.db.owner()
i18n.set_locale(await self.db.locale())
async def embed_requested(self, channel, user, command=None) -> bool:
"""
Determine if an embed is requested for a response.
Parameters
----------
channel : `discord.abc.GuildChannel` or `discord.abc.PrivateChannel`
The channel to check embed settings for.
user : `discord.abc.User`
The user to check embed settings for.
command
(Optional) the command ran.
Returns
-------
bool
:code:`True` if an embed is requested
"""
if isinstance(channel, discord.abc.PrivateChannel) or (
command and command == self.get_command("help")
):
user_setting = await self.db.user(user).embeds()
if user_setting is not None:
return user_setting
else:
guild_setting = await self.db.guild(channel.guild).embeds()
if command and command != self.get_command("help"):
if guild_setting is not None:
return guild_setting
global_setting = await self.db.embeds()
return global_setting
async def is_owner(self, user):
if user.id in self._co_owners:
return True