Discord/cogs/fun.py

59 lines
1.7 KiB
Python
Raw Normal View History

2023-05-07 12:01:28 +03:00
import logging
from discord import ApplicationContext, Embed, User, option, slash_command
from discord.ext import commands
2024-12-16 00:36:48 +02:00
from libbot import config_get
from libbot.sync import config_get as sync_config_get
2023-05-07 12:01:28 +03:00
2024-12-17 23:14:06 +02:00
from classes.holo_bot import HoloBot
2024-12-16 00:36:48 +02:00
from modules.utils_sync import guild_name
from modules.waifu_pics import waifu_pics
2023-05-07 12:01:28 +03:00
logger = logging.getLogger(__name__)
class Fun(commands.Cog):
2024-12-17 23:14:06 +02:00
def __init__(self, client: HoloBot):
self.client: HoloBot = client
2023-05-07 12:01:28 +03:00
@slash_command(
name="action",
description="Провести над користувачем РП дію",
2024-12-16 00:36:48 +02:00
guild_ids=[sync_config_get("guild")],
2023-05-07 12:01:28 +03:00
)
@option(
"type",
description="Тип дії, яку хочете провести з користувачем",
2024-12-16 00:36:48 +02:00
choices=sync_config_get("actions").keys(),
2023-05-07 12:01:28 +03:00
)
@option("user", description="Користувач")
async def action_cmd(self, ctx: ApplicationContext, type: str, user: User) -> None:
2023-05-07 12:01:28 +03:00
await ctx.defer()
action: str = await config_get("category", "actions", type)
action_verb: str = await config_get("action", "actions", type)
2023-05-07 12:01:28 +03:00
image_url: str = await waifu_pics.sfw(action)
2023-05-07 12:01:28 +03:00
logger.info(
2024-06-23 13:05:03 +03:00
"User %s (%s) %s %s (%s) with image %s",
guild_name(ctx.user),
ctx.user.id,
action_verb,
guild_name(user),
user.id,
image_url,
2023-05-07 12:01:28 +03:00
)
embed: Embed = Embed(
2023-05-07 12:01:28 +03:00
description=f"**{guild_name(ctx.user)}** {action_verb} **{guild_name(user)}**",
color=0x2F3136,
)
embed.set_image(url=image_url)
2023-05-07 12:01:28 +03:00
await ctx.respond(embed=embed)
2024-06-23 13:05:03 +03:00
2024-12-17 23:14:06 +02:00
def setup(client: HoloBot) -> None:
2024-06-23 13:05:03 +03:00
client.add_cog(Fun(client))