feat(meta): Implement join_message.
This commit is contained in:
@@ -96,7 +96,7 @@ class GeneralSettingUI(ConfigUI):
|
|||||||
class GeneralDashboard(DashboardSection):
|
class GeneralDashboard(DashboardSection):
|
||||||
section_name = _p(
|
section_name = _p(
|
||||||
"dash:general|title",
|
"dash:general|title",
|
||||||
"General Configuration ({commands[admin config general]})"
|
"General Configuration ({commands[config general]})"
|
||||||
)
|
)
|
||||||
_option_name = _p(
|
_option_name = _p(
|
||||||
"dash:general|option|name",
|
"dash:general|option|name",
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ class MemberAdminUI(ConfigUI):
|
|||||||
class MemberAdminDashboard(DashboardSection):
|
class MemberAdminDashboard(DashboardSection):
|
||||||
section_name = _p(
|
section_name = _p(
|
||||||
"dash:member_admin|title",
|
"dash:member_admin|title",
|
||||||
"Greetings and Initial Roles ({commands[admin config welcome]})"
|
"Greetings and Initial Roles ({commands[config welcome]})"
|
||||||
)
|
)
|
||||||
_option_name = _p(
|
_option_name = _p(
|
||||||
"dash:member_admin|dropdown|placeholder",
|
"dash:member_admin|dropdown|placeholder",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from typing import Optional
|
|||||||
import gc
|
import gc
|
||||||
import sys
|
import sys
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands as cmds
|
from discord.ext import commands as cmds
|
||||||
@@ -20,8 +21,15 @@ from .helpui import HelpUI
|
|||||||
|
|
||||||
_p = babel._p
|
_p = babel._p
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
created = utc_now()
|
created = utc_now()
|
||||||
|
guide_link = "https://discord.studylions.com/tutorial"
|
||||||
|
|
||||||
|
animation_link = (
|
||||||
|
"https://media.discordapp.net/attachments/879412267731542047/926837189814419486/ezgif.com-resize.gif"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MetaCog(LionCog):
|
class MetaCog(LionCog):
|
||||||
@@ -47,6 +55,51 @@ class MetaCog(LionCog):
|
|||||||
)
|
)
|
||||||
await ui.run(ctx.interaction)
|
await ui.run(ctx.interaction)
|
||||||
|
|
||||||
|
@LionCog.listener('on_guild_join')
|
||||||
|
async def post_join_message(self, guild: discord.Guild):
|
||||||
|
logger.debug(f"Sending join message to <gid: {guild.id}>")
|
||||||
|
# Send join message
|
||||||
|
t = self.bot.translator.t
|
||||||
|
message = t(_p(
|
||||||
|
'new_guild_join_message|desc',
|
||||||
|
"Thank you for inviting me to your community!\n"
|
||||||
|
"Get started by typing {help_cmd} to see my commands,"
|
||||||
|
" and {dash_cmd} to view and set up my configuration options!\n\n"
|
||||||
|
"If you need any help configuring me,"
|
||||||
|
" or would like to suggest a feature,"
|
||||||
|
" report a bug, and stay updated,"
|
||||||
|
" make sure to join our main support server by [clicking here]({support})."
|
||||||
|
)).format(
|
||||||
|
dash_cmd=self.bot.core.mention_cmd('dashboard'),
|
||||||
|
help_cmd=self.bot.core.mention_cmd('help'),
|
||||||
|
support=self.bot.config.bot.support_guild,
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
await guild.me.edit(nick="Leo")
|
||||||
|
except discord.HTTPException:
|
||||||
|
pass
|
||||||
|
if (channel := guild.system_channel) and channel.permissions_for(guild.me).embed_links:
|
||||||
|
embed = discord.Embed(
|
||||||
|
description=message,
|
||||||
|
colour=discord.Colour.orange(),
|
||||||
|
)
|
||||||
|
embed.set_author(
|
||||||
|
name=t(_p(
|
||||||
|
'new_guild_join_message|name',
|
||||||
|
"Hello everyone! My name is Leo, the LionBot!"
|
||||||
|
)),
|
||||||
|
icon_url="https://cdn.discordapp.com/emojis/933610591459872868.webp"
|
||||||
|
)
|
||||||
|
embed.set_image(url=animation_link)
|
||||||
|
|
||||||
|
try:
|
||||||
|
await channel.send(embed=embed)
|
||||||
|
except discord.HTTPException:
|
||||||
|
logger.warning(
|
||||||
|
f"Could not send join message to <gid: {guild.id}>",
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
|
||||||
@cmds.hybrid_command(
|
@cmds.hybrid_command(
|
||||||
name=_p('cmd:invite', "invite"),
|
name=_p('cmd:invite', "invite"),
|
||||||
description=_p(
|
description=_p(
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class TimerConfigUI(ConfigUI):
|
|||||||
class TimerDashboard(DashboardSection):
|
class TimerDashboard(DashboardSection):
|
||||||
section_name = _p(
|
section_name = _p(
|
||||||
'dash:pomodoro|title',
|
'dash:pomodoro|title',
|
||||||
"Pomodoro Configuration ({commands[admin config pomodoro]})"
|
"Pomodoro Configuration ({commands[config pomodoro]})"
|
||||||
)
|
)
|
||||||
_option_name = _p(
|
_option_name = _p(
|
||||||
"dash:stats|dropdown|placeholder",
|
"dash:stats|dropdown|placeholder",
|
||||||
|
|||||||
Reference in New Issue
Block a user