Skip to content

Commit

Permalink
🐛 Fix Delete Message With Delay
Browse files Browse the repository at this point in the history
  • Loading branch information
foxwhite25 committed Jul 16, 2023
1 parent c873b51 commit edf3877
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions qq/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ def category(self) -> Optional[CategoryChannel]:
return self.guild.get_channel(self.category_id) # type: ignore

async def delete(self, *, reason: Optional[str] = None) -> None:
"""|coro|
删除频道。
"""
await self._state.http.delete_channel(self.id, reason=reason)

async def _clone_impl(
Expand Down
2 changes: 1 addition & 1 deletion qq/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ async def create_text_channel(
if private_type is not MISSING:
options['private_type'] = private_type
if private_type == 2 and private_members is not MISSING:
options['private_user_ids'] = [n.id for n in private_members]
options['private_user_ids'] = [str(n.id) for n in private_members]

data = await self._create_channel(
name, channel_type=ChannelType.text, category=category, reason=reason, **options
Expand Down
2 changes: 1 addition & 1 deletion qq/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def mute_guild(
return self.request(r, json=payload, reason=reason)

def delete_message(
self, channel_id: int, message_id: str, hidetip: bool, *, reason: Optional[str] = None,
self, channel_id: int, message_id: str, *, reason: Optional[str] = None, hidetip: bool = False
) -> Response[None]:
r = Route('DELETE', '/channels/{channel_id}/messages/{message_id}', channel_id=channel_id,
message_id=message_id)
Expand Down
4 changes: 2 additions & 2 deletions qq/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,13 +865,13 @@ async def delete(self, *, delay: Optional[float] = None, hidetip: bool = False)
async def delete(delay: float):
await asyncio.sleep(delay)
try:
await self._state.http.delete_message(self.channel.id, self.id)
await self._state.http.delete_message(self.channel.id, self.id, hidetip=hidetip)
except HTTPException:
pass

asyncio.create_task(delete(delay))
else:
await self._state.http.delete_message(self.channel.id, self.id, hidetip)
await self._state.http.delete_message(self.channel.id, self.id, hidetip=hidetip)

@property
def edited_at(self) -> Optional[datetime.datetime]:
Expand Down

0 comments on commit edf3877

Please sign in to comment.