Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sync command to work in discord.py 2.4 #235

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions jishaku/features/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,18 @@ async def jsk_sync(self, ctx: ContextA, *targets: str):
guild=discord.Object(guild) if guild else None
)
translator = getattr(self.bot.tree, 'translator', None)
if translator:
payload = [await command.get_translated_payload(translator) for command in slash_commands]
needs_dpy_2_4_signature_changes = discord.version_info.major >= 2 and discord.version_info.minor >= 4

if needs_dpy_2_4_signature_changes:
if translator:
payload = [await command.get_translated_payload(self.bot.tree, translator) for command in slash_commands]
else:
payload = [command.to_dict(self.bot.tree) for command in slash_commands]
else:
payload = [command.to_dict() for command in slash_commands]
if translator:
payload = [await command.get_translated_payload(translator) for command in slash_commands]
else:
payload = [command.to_dict() for command in slash_commands]

try:
if guild is None:
Expand Down