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
|
2024-12-16 21:00:32 +02:00
|
|
|
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="Користувач")
|
2024-12-16 21:34:37 +02:00
|
|
|
async def action_cmd(self, ctx: ApplicationContext, type: str, user: User) -> None:
|
2023-05-07 12:01:28 +03:00
|
|
|
await ctx.defer()
|
|
|
|
|
2024-12-16 21:34:37 +02:00
|
|
|
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
|
|
|
|
2024-12-16 21:34:37 +02: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,
|
2024-12-16 21:34:37 +02:00
|
|
|
image_url,
|
2023-05-07 12:01:28 +03:00
|
|
|
)
|
|
|
|
|
2024-12-16 21:34:37 +02: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,
|
|
|
|
)
|
2024-12-16 21:34:37 +02:00
|
|
|
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))
|