Discord/cogs/fun.py

59 lines
1.7 KiB
Python

import logging
from discord import ApplicationContext, Embed, User, option, slash_command
from discord.ext import commands
from libbot import config_get
from libbot.sync import config_get as sync_config_get
from classes.holo_bot import HoloBot
from modules.utils_sync import guild_name
from modules.waifu_pics import waifu_pics
logger = logging.getLogger(__name__)
class Fun(commands.Cog):
def __init__(self, client: HoloBot):
self.client: HoloBot = client
@slash_command(
name="action",
description="Провести над користувачем РП дію",
guild_ids=[sync_config_get("guild")],
)
@option(
"type",
description="Тип дії, яку хочете провести з користувачем",
choices=sync_config_get("actions").keys(),
)
@option("user", description="Користувач")
async def action_cmd(self, ctx: ApplicationContext, type: str, user: User) -> None:
await ctx.defer()
action: str = await config_get("category", "actions", type)
action_verb: str = await config_get("action", "actions", type)
image_url: str = await waifu_pics.sfw(action)
logger.info(
"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,
)
embed: Embed = Embed(
description=f"**{guild_name(ctx.user)}** {action_verb} **{guild_name(user)}**",
color=0x2F3136,
)
embed.set_image(url=image_url)
await ctx.respond(embed=embed)
def setup(client: HoloBot) -> None:
client.add_cog(Fun(client))