|
1 | 1 | import copy |
2 | | -from typing import Any |
| 2 | +from typing import Any, override |
3 | 3 |
|
4 | 4 | import pytest |
5 | 5 |
|
6 | 6 | import discord |
7 | 7 | from discord import MISSING, Bot, SlashCommandGroup |
| 8 | +from discord.bot import COMMAND_DEFAULTS, DefaultSetComparison |
8 | 9 | from discord.types.interactions import ApplicationCommand, ApplicationCommandOption |
9 | 10 |
|
10 | 11 | pytestmark = pytest.mark.asyncio |
@@ -56,10 +57,20 @@ async def dummy_callback(ctx): |
56 | 57 | } |
57 | 58 |
|
58 | 59 |
|
| 60 | +class DummyBot(Bot): |
| 61 | + @override |
| 62 | + async def _get_command_defaults(self): |
| 63 | + command_defaults = COMMAND_DEFAULTS.copy() |
| 64 | + command_defaults["integration_types"] = DefaultSetComparison( |
| 65 | + (MISSING, {0}), lambda x, y: set(x) == set(y) |
| 66 | + ) |
| 67 | + return command_defaults |
| 68 | + |
| 69 | + |
59 | 70 | async def edit_needed( |
60 | 71 | local: SlashCommand | SlashCommandGroup, remote: ApplicationCommand |
61 | 72 | ): |
62 | | - b = Bot() |
| 73 | + b = DummyBot() |
63 | 74 | b.add_application_command(local) |
64 | 75 | r = await b.get_desynced_commands(prefetched=[remote]) |
65 | 76 | return r[0]["action"] == "edit" |
@@ -954,7 +965,7 @@ async def test_parent_name(self): |
954 | 965 | async def edit_needed( |
955 | 966 | local: SlashCommand | SlashCommandGroup, remote: ApplicationCommand |
956 | 967 | ): |
957 | | - b = Bot() |
| 968 | + b = DummyBot() |
958 | 969 | b.add_application_command(local) |
959 | 970 | r = await b.get_desynced_commands(prefetched=[remote]) |
960 | 971 | return r[0]["action"] == "upsert" and r[1]["action"] == "delete" |
|
0 commit comments