


























@@ -150,6 +150,117 @@ describe("Client.deployCommands", () => {
150150expect(deleteRequest).not.toHaveBeenCalled();
151151});
152152153+it("does not patch live-only command metadata or reordered unordered arrays", async () => {
154+const client = createInternalTestClient([
155+createTestCommand({
156+name: "one",
157+options: [
158+{
159+type: 3,
160+name: "value",
161+description: "Value",
162+required: false,
163+autocomplete: false,
164+channel_types: [1, 0],
165+},
166+],
167+}),
168+]);
169+const get = vi.fn(async () => [
170+{
171+id: "cmd1",
172+application_id: "app1",
173+type: ApplicationCommandType.ChatInput,
174+name: "one",
175+name_localized: "one",
176+description: "one command",
177+description_localized: "one command",
178+options: [
179+{
180+type: 3,
181+name: "value",
182+description: "Value",
183+description_localized: "Value",
184+channel_types: [0, 1],
185+},
186+],
187+default_member_permissions: null,
188+dm_permission: true,
189+integration_types: [1, 0],
190+contexts: [2, 1, 0],
191+guild_id: undefined,
192+version: "1",
193+},
194+]);
195+const patch = vi.fn(async () => undefined);
196+const post = vi.fn(async () => undefined);
197+const deleteRequest = vi.fn(async () => undefined);
198+attachRestMock(client, { get, patch, post, delete: deleteRequest });
199+200+await client.deployCommands({ mode: "reconcile" });
201+202+expect(patch).not.toHaveBeenCalled();
203+expect(post).not.toHaveBeenCalled();
204+expect(deleteRequest).not.toHaveBeenCalled();
205+});
206+207+it("patches changed option localization maps", async () => {
208+const client = createInternalTestClient([
209+createTestCommand({
210+name: "one",
211+options: [
212+{
213+type: 3,
214+name: "value",
215+name_localizations: { de: "wert" },
216+description: "Value",
217+description_localizations: { de: "Wert" },
218+},
219+],
220+}),
221+]);
222+const get = vi.fn(async () => [
223+{
224+id: "cmd1",
225+application_id: "app1",
226+type: ApplicationCommandType.ChatInput,
227+name: "one",
228+description: "one command",
229+options: [
230+{
231+type: 3,
232+name: "value",
233+name_localizations: { de: "alter-wert" },
234+description: "Value",
235+description_localizations: { de: "Alter Wert" },
236+},
237+],
238+},
239+]);
240+const patch = vi.fn(async () => undefined);
241+const post = vi.fn(async () => undefined);
242+const deleteRequest = vi.fn(async () => undefined);
243+attachRestMock(client, { get, patch, post, delete: deleteRequest });
244+245+await client.deployCommands({ mode: "reconcile" });
246+247+expect(patch).toHaveBeenCalledWith(
248+Routes.applicationCommand("app1", "cmd1"),
249+expect.objectContaining({
250+body: expect.objectContaining({
251+options: [
252+expect.objectContaining({
253+name_localizations: { de: "wert" },
254+description_localizations: { de: "Wert" },
255+}),
256+],
257+}),
258+}),
259+);
260+expect(post).not.toHaveBeenCalled();
261+expect(deleteRequest).not.toHaveBeenCalled();
262+});
263+153264it("skips command deploy when the serialized command set is unchanged", async () => {
154265const client = createInternalTestClient([createTestCommand({ name: "one" })]);
155266const get = vi.fn(async () => []);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。