import logging from discord import ApplicationContext, Embed, User, option, slash_command from discord.ext import commands from libbot import config_get from libbot.pycord.classes import PycordBot from libbot.sync import config_get as sync_config_get 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: PycordBot): self.client = 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): await ctx.defer() action = await config_get("category", "actions", type) action_verb = await config_get("action", "actions", type) image = 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, ) 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) def setup(client: PycordBot): client.add_cog(Fun(client))