Discord/cogs/fun.py

61 lines
1.7 KiB
Python
Raw Normal View History

2023-05-07 12:01:28 +03:00
import logging
2024-12-16 00:36:48 +02:00
from WaifuPicsPython import WaifuAsync
2023-05-07 12:01:28 +03:00
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
2024-06-23 13:05:03 +03:00
from libbot.pycord.classes import PycordBot
2024-12-16 00:36:48 +02:00
from libbot.sync import config_get as sync_config_get
2023-05-07 12:01:28 +03:00
2024-12-16 00:36:48 +02:00
from modules.utils_sync import guild_name
2023-05-07 12:01:28 +03:00
logger = logging.getLogger(__name__)
wafiu_pics = WaifuAsync()
class Fun(commands.Cog):
2024-06-23 13:05:03 +03:00
def __init__(self, client: PycordBot):
2023-05-07 12:01:28 +03:00
self.client = client
@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):
await ctx.defer()
action = await config_get("category", "actions", type)
action_verb = await config_get("action", "actions", type)
image = await wafiu_pics.sfw(action)
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,
2023-05-07 12:01:28 +03:00
)
embed = Embed(
description=f"**{guild_name(ctx.user)}** {action_verb} **{guild_name(user)}**",
color=0x2F3136,
)
embed.set_image(url=image)
await ctx.respond(embed=embed)
2024-06-23 13:05:03 +03:00
def setup(client: PycordBot):
client.add_cog(Fun(client))