Skip to content

Commit

Permalink
Merge pull request #32 from ITCraftDevelopmentTeam/message-id-fix
Browse files Browse the repository at this point in the history
在使用 Discord Slash Command 时不提供 Message ID
  • Loading branch information
This-is-XiaoDeng authored Apr 11, 2024
2 parents 263ff81 + 62cc842 commit 85a72f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions actions/v12/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ async def send_message(
logger.debug(traceback.format_exc())
return return_object.get(34000, str(e))
message_id = msg.id
await commit_message(message_id, channel.id, int(time.time()))
else:
try:
message_id = await commands.deferred_sessions[_channel_id][0](**parsed_message)
await commands.deferred_sessions[_channel_id][0](**parsed_message)
except discord.HTTPException as e:
logger.debug(traceback.format_exc())
return return_object.get(34000, str(e))
await commit_message(message_id, channel.id, int(time.time()))
message_id = "-1"
return return_object.get(0, message_id=message_id, time=time.time())


Expand Down
5 changes: 2 additions & 3 deletions utils/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
except json.JSONDecodeError:
logger.error(f"无法读取指令列表: {traceback.format_exc()}")
commands = []
deferred_sessions: dict[str, tuple[Callable[..., Awaitable[int]], Callable[[], Awaitable[None]]]] = {}
deferred_sessions: dict[str, tuple[Callable[..., Awaitable[None]], Callable[[], Awaitable[None]]]] = {}

async def handle_command(interaction: Interaction, args: Optional[str]) -> None:
logger.debug(f"收到命令: {interaction.command} ({args=})")
Expand All @@ -33,10 +33,9 @@ async def handle_command(interaction: Interaction, args: Optional[str]) -> None:
def remove() -> None:
deferred_sessions.pop(session_id, None)

async def followup(**kwargs) -> int:
async def followup(**kwargs) -> None:
await interaction.followup.send(**kwargs)
remove()
return interaction.followup.id

async def abandon() -> None:
# 我不知道有没有用,但是它能跑
Expand Down

0 comments on commit 85a72f5

Please sign in to comment.