Merge branch 'rewrite' into release
This commit is contained in:
@@ -230,7 +230,7 @@ class BabelCog(LionCog):
|
|||||||
supported = self.bot.translator.supported_locales
|
supported = self.bot.translator.supported_locales
|
||||||
formatted = []
|
formatted = []
|
||||||
for locale in supported:
|
for locale in supported:
|
||||||
name = locale_names.get(locale, None)
|
name = locale_names.get(locale.replace('_', '-'), None)
|
||||||
if name:
|
if name:
|
||||||
localestr = f"{locale} ({t(name)})"
|
localestr = f"{locale} ({t(name)})"
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class LocaleMap(Enum):
|
|||||||
turkish = 'tr'
|
turkish = 'tr'
|
||||||
ukrainian = 'uk'
|
ukrainian = 'uk'
|
||||||
vietnamese = 'vi'
|
vietnamese = 'vi'
|
||||||
|
hebrew = 'he-IL'
|
||||||
|
|
||||||
|
|
||||||
locale_names = {
|
locale_names = {
|
||||||
@@ -68,4 +69,6 @@ locale_names = {
|
|||||||
'tr': _p('localenames|locale:tr', "Turkish"),
|
'tr': _p('localenames|locale:tr', "Turkish"),
|
||||||
'uk': _p('localenames|locale:uk', "Ukrainian"),
|
'uk': _p('localenames|locale:uk', "Ukrainian"),
|
||||||
'vi': _p('localenames|locale:vi', "Vietnamese"),
|
'vi': _p('localenames|locale:vi', "Vietnamese"),
|
||||||
|
'he': _p('localenames|locale:he', "Hebrew"),
|
||||||
|
'he-IL': _p('localenames|locale:he_IL', "Hebrew (Israel)"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,3 +2,5 @@ CONFIG_FILE = "config/bot.conf"
|
|||||||
DATA_VERSION = 13
|
DATA_VERSION = 13
|
||||||
|
|
||||||
MAX_COINS = 2147483647 - 1
|
MAX_COINS = 2147483647 - 1
|
||||||
|
|
||||||
|
HINT_ICON = "https://projects.iamcal.com/emoji-data/img-apple-64/1f4a1.png"
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ class MessageSetting(StringSetting):
|
|||||||
|
|
||||||
value = cls._data_to_value(parent_id, data, **kwargs)
|
value = cls._data_to_value(parent_id, data, **kwargs)
|
||||||
content = value.get('content', "")
|
content = value.get('content', "")
|
||||||
if 'embed' in value or 'embeds' in value or len(content) > 1024:
|
if 'embed' in value or 'embeds' in value or len(content) > 100:
|
||||||
t = ctx_translator.get().t
|
t = ctx_translator.get().t
|
||||||
formatted = t(_p(
|
formatted = t(_p(
|
||||||
'settype:message|format:too_long',
|
'settype:message|format:too_long',
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import discord
|
|||||||
from discord.ui.select import select, Select, SelectOption
|
from discord.ui.select import select, Select, SelectOption
|
||||||
from discord.ui.button import button, Button, ButtonStyle
|
from discord.ui.button import button, Button, ButtonStyle
|
||||||
|
|
||||||
|
from constants import HINT_ICON
|
||||||
from meta import conf, LionBot
|
from meta import conf, LionBot
|
||||||
from utils.lib import MessageArgs
|
from utils.lib import MessageArgs, utc_now
|
||||||
from utils.ui import BasePager
|
from utils.ui import BasePager
|
||||||
|
|
||||||
from modules.economy.settingui import EconomyDashboard
|
from modules.economy.settingui import EconomyDashboard
|
||||||
@@ -72,6 +73,16 @@ class GuildDashboard(BasePager):
|
|||||||
instance.deregister_callback(self.id)
|
instance.deregister_callback(self.id)
|
||||||
self._listening.clear()
|
self._listening.clear()
|
||||||
|
|
||||||
|
try:
|
||||||
|
if self._original is not None and not self._original.is_expired():
|
||||||
|
await self._original.edit_original_response(view=None)
|
||||||
|
self._original = None
|
||||||
|
if self._message is not None:
|
||||||
|
await self._message.edit(view=None)
|
||||||
|
self._message = None
|
||||||
|
except discord.HTTPException:
|
||||||
|
pass
|
||||||
|
|
||||||
await super().cleanup()
|
await super().cleanup()
|
||||||
|
|
||||||
# ----- Pager Control -----
|
# ----- Pager Control -----
|
||||||
@@ -80,10 +91,24 @@ class GuildDashboard(BasePager):
|
|||||||
if (page := self._cached_pages.get(page_id, None)) is not None:
|
if (page := self._cached_pages.get(page_id, None)) is not None:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
t = self.bot.translator.t
|
||||||
# Format settings into a dashboard embed
|
# Format settings into a dashboard embed
|
||||||
|
dashboard_title = t(_p(
|
||||||
|
'ui:dashboard|title',
|
||||||
|
"Guild Dashboard (Page {page}/{total})"
|
||||||
|
)).format(page=page_id + 1, total=len(self.pages))
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="Guild Dashboard",
|
title=dashboard_title,
|
||||||
colour=discord.Colour.orange()
|
colour=discord.Colour.orange(),
|
||||||
|
timestamp=utc_now()
|
||||||
|
)
|
||||||
|
embed.set_footer(
|
||||||
|
text=t(_p(
|
||||||
|
'ui:dashboard|footer',
|
||||||
|
"Hover over setting names for a brief description"
|
||||||
|
)),
|
||||||
|
icon_url=HINT_ICON
|
||||||
)
|
)
|
||||||
|
|
||||||
section_classes = self.pages[page_id]
|
section_classes = self.pages[page_id]
|
||||||
@@ -160,6 +185,7 @@ class GuildDashboard(BasePager):
|
|||||||
# ----- UI Control -----
|
# ----- UI Control -----
|
||||||
async def reload(self, *args):
|
async def reload(self, *args):
|
||||||
self._cached_pages.clear()
|
self._cached_pages.clear()
|
||||||
|
if not self._original.is_expired():
|
||||||
await self.redraw()
|
await self.redraw()
|
||||||
|
|
||||||
async def refresh(self):
|
async def refresh(self):
|
||||||
|
|||||||
@@ -262,3 +262,35 @@ class MemberAdminDashboard(DashboardSection):
|
|||||||
)
|
)
|
||||||
configui = MemberAdminUI
|
configui = MemberAdminUI
|
||||||
setting_classes = MemberAdminUI.setting_classes
|
setting_classes = MemberAdminUI.setting_classes
|
||||||
|
|
||||||
|
def apply_to(self, page: discord.Embed):
|
||||||
|
"""
|
||||||
|
Overriding DashboardSection apply_to to split into two sections.
|
||||||
|
"""
|
||||||
|
t = self.bot.translator.t
|
||||||
|
sections = [
|
||||||
|
self.instances[:3],
|
||||||
|
self.instances[3:]
|
||||||
|
]
|
||||||
|
|
||||||
|
# Greeting messages
|
||||||
|
table = self._make_table(sections[0])
|
||||||
|
page.add_field(
|
||||||
|
name=t(_p(
|
||||||
|
'dash:member_admin|section:greeting_messages|name',
|
||||||
|
"Greeting Messages ({commands[configure welcome]})"
|
||||||
|
)).format(commands=self.bot.core.mention_cache),
|
||||||
|
value=table,
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
|
||||||
|
# Initial Roles
|
||||||
|
table = self._make_table(sections[1])
|
||||||
|
page.add_field(
|
||||||
|
name=t(_p(
|
||||||
|
'dash:member_admin|section:initial_roles|name',
|
||||||
|
"Initial Roles ({commands[configure welcome]})"
|
||||||
|
)).format(commands=self.bot.core.mention_cache),
|
||||||
|
value=table,
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
|||||||
@@ -142,14 +142,22 @@ class Timer:
|
|||||||
if not hook:
|
if not hook:
|
||||||
# Attempt to create and save webhook
|
# Attempt to create and save webhook
|
||||||
# TODO: Localise
|
# TODO: Localise
|
||||||
|
t = self.bot.translator.t
|
||||||
|
ctx_locale.set(self.locale.value)
|
||||||
try:
|
try:
|
||||||
if channel.permissions_for(channel.guild.me).manage_webhooks:
|
if channel.permissions_for(channel.guild.me).manage_webhooks:
|
||||||
avatar = self.bot.user.avatar
|
avatar = self.bot.user.avatar
|
||||||
avatar_data = (await avatar.to_file()).fp.read() if avatar else None
|
avatar_data = (await avatar.to_file()).fp.read() if avatar else None
|
||||||
webhook = await channel.create_webhook(
|
webhook = await channel.create_webhook(
|
||||||
avatar=avatar_data,
|
avatar=avatar_data,
|
||||||
name=f"{self.bot.user.name} Pomodoro",
|
name=t(_p(
|
||||||
reason="Pomodoro Notifications"
|
'timer|webhook|name',
|
||||||
|
"{bot_name} Pomodoro"
|
||||||
|
)).format(bot_name=self.bot.user.name),
|
||||||
|
reason=t(_p(
|
||||||
|
'timer|webhook|audit_reason',
|
||||||
|
"Pomodoro Notifications"
|
||||||
|
))
|
||||||
)
|
)
|
||||||
hook = await self.bot.core.data.LionHook.create(
|
hook = await self.bot.core.data.LionHook.create(
|
||||||
channelid=channel.id,
|
channelid=channel.id,
|
||||||
@@ -157,9 +165,10 @@ class Timer:
|
|||||||
webhookid=webhook.id
|
webhookid=webhook.id
|
||||||
)
|
)
|
||||||
elif channel.permissions_for(channel.guild.me).send_messages:
|
elif channel.permissions_for(channel.guild.me).send_messages:
|
||||||
await channel.send(
|
await channel.send(t(_p(
|
||||||
"I require the `manage_webhooks` permission to send pomodoro notifications here!"
|
'timer|webhook|error:insufficient_permissions',
|
||||||
)
|
"I require the `MANAGE_WEBHOOKS` permission to send pomodoro notifications here!"
|
||||||
|
)))
|
||||||
except discord.HTTPException:
|
except discord.HTTPException:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Unexpected Exception caught while creating timer notification webhook "
|
"Unexpected Exception caught while creating timer notification webhook "
|
||||||
|
|||||||
@@ -300,7 +300,6 @@ class DashboardSection:
|
|||||||
commands=self.bot.core.mention_cache
|
commands=self.bot.core.mention_cache
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def load(self):
|
async def load(self):
|
||||||
"""
|
"""
|
||||||
Initialise the contained settings.
|
Initialise the contained settings.
|
||||||
@@ -322,9 +321,18 @@ class DashboardSection:
|
|||||||
|
|
||||||
# TODO: Header/description field
|
# TODO: Header/description field
|
||||||
table = self.make_table()
|
table = self.make_table()
|
||||||
|
if len(table) > 1024:
|
||||||
|
value = t(_p(
|
||||||
|
'ui:dashboard|error:section_too_long',
|
||||||
|
"Oops, the settings in this configuration section are too large, "
|
||||||
|
"and I can not display them here! "
|
||||||
|
"Please view the settings in the linked configuration panel instead."
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
value = table
|
||||||
page.add_field(
|
page.add_field(
|
||||||
name=t(self.section_name).format(bot=self.bot, commands=self.bot.core.mention_cache),
|
name=t(self.section_name).format(bot=self.bot, commands=self.bot.core.mention_cache),
|
||||||
value=table,
|
value=value,
|
||||||
inline=False
|
inline=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user