Skip to content

Commit

Permalink
Add act command
Browse files Browse the repository at this point in the history
  • Loading branch information
MycroftKang committed Sep 25, 2024
1 parent c938c4d commit 177c0a8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions locales/mkbot.pot
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,9 @@ msgstr ""
msgid "Your enemy is not ready yet, please wait until they are"
msgstr ""

msgid "[MK Bot]({url}) acted like {member}."
msgstr ""

msgid "[MK Bot]({url}) said on behalf of {author}"
msgstr ""

Expand Down
41 changes: 41 additions & 0 deletions src/bot/core/controllers/discord/act.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import discord
from discord.ext import commands

from mgylabs.i18n import __
from mgylabs.utils.config import VERSION, is_development_mode

from .utils.feature import Feature
from .utils.MGCert import Level, MGCertificate

if is_development_mode(False) or VERSION.is_canary():
enabled = True
else:
enabled = False


@commands.hybrid_command(hidden=True, enabled=enabled, with_app_command=enabled)
@MGCertificate.verify(level=Level.TRUSTED_USERS)
@Feature.Experiment()
async def act(ctx: commands.Context, member: discord.Member, *, message):
webhooks = await ctx.channel.webhooks()

if webhooks:
webhook = webhooks[0]
else:
webhook = await ctx.channel.create_webhook(name=member.name)

await webhook.send(
str(message), username=member.display_name, avatar_url=member.avatar.url
)

if ctx.interaction:
await ctx.send(
__("[MK Bot]({url}) acted like {member}.").format(
url="<https://github.com/mgylabs/mkbot>", member=member.mention
),
ephemeral=True,
)


async def setup(bot: commands.Bot):
bot.add_command(act)
1 change: 1 addition & 0 deletions src/bot/discord_ext.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import platform

discord_extensions = (
"core.controllers.discord.act",
"core.controllers.discord.dev",
# "core.controllers.discord.admin",
"core.controllers.discord.delete",
Expand Down

0 comments on commit 177c0a8

Please sign in to comment.