Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/bots/discord/slash_parser.py

26 lines
1.1 KiB
Python
Raw Normal View History

2022-08-16 18:53:43 +00:00
import asyncio
import discord
from bots.discord.slash_message import MessageSession
from core.elements import MsgInfo, Session
from core.logger import Logger
from core.parser.message import parser
async def slash_parser(ctx: discord.ApplicationContext, command: str):
await ctx.defer()
target = "Discord|Channel"
if isinstance(ctx.channel, discord.DMChannel):
target = "Discord|DM|Channel"
targetId = f"{target}|{ctx.channel.id}"
session = MessageSession(target=MsgInfo(targetId=targetId,
senderId=f"Discord|Client|{ctx.author.id}",
senderName=ctx.author.name, targetFrom=target, senderFrom="Discord|Client",
clientName='Discord|Slash',
messageId=0),
session=Session(message=ctx, target=ctx.channel, sender=ctx.author))
2022-08-16 19:06:59 +00:00
session.command = f'/{str(ctx.command).split(" ")[0]} {command}'
2022-08-16 18:53:43 +00:00
Logger.info(f'parsing..')
2022-08-16 19:06:59 +00:00
await parser(session, prefix=['/'])