import logging from discord import ApplicationContext, Embed, User, option, slash_command from discord.ext import commands from WaifuPicsPython import WaifuAsync from modules.utils import config_get from modules.utils_sync import config_get_sync, guild_name logger = logging.getLogger(__name__) wafiu_pics = WaifuAsync() class Fun(commands.Cog): def __init__(self, client): self.client = client @slash_command( name="action", description="Провести над користувачем РП дію", guild_ids=[config_get_sync("guild")], ) @option( "type", description="Тип дії, яку хочете провести з користувачем", choices=config_get_sync("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 wafiu_pics.sfw(action) logger.info( f"User {guild_name(ctx.user)} ({ctx.user.id}) {action_verb} {guild_name(user)} ({user.id}) with image {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)