60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
import logging
|
|
|
|
from discord import ApplicationContext, Embed, User, option, slash_command
|
|
from discord.ext import commands
|
|
from libbot.pycord.classes import PycordBot
|
|
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: PycordBot):
|
|
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(
|
|
"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))
|