@discordeno/rest 19.0.0-next.6ee061d → 19.0.0-next.6ffb584

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../src/manager.ts"],"names":[],"mappings":"AAmEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAA;AAK3F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,CA2nDhF"}
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../src/manager.ts"],"names":[],"mappings":"AAqEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAA;AAK3F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,CA8qDhF"}
package/dist/manager.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable no-const-assign */ import { InteractionResponseTypes } from '@discordeno/types';
2
- import { calculateBits, camelize, camelToSnakeCase, delay, findFiles, getBotIdFromToken, isGetMessagesAfter, isGetMessagesAround, isGetMessagesBefore, isGetMessagesLimit, logger, processReactionString, urlToBase64 } from '@discordeno/utils';
2
+ import { calculateBits, camelize, camelToSnakeCase, delay, encode, findFiles, getBotIdFromToken, isGetMessagesAfter, isGetMessagesAround, isGetMessagesBefore, isGetMessagesLimit, logger, processReactionString, urlToBase64 } from '@discordeno/utils';
3
3
  import fetch from 'node-fetch';
4
4
  import { createInvalidRequestBucket } from './invalidBucket.js';
5
5
  import { Queue } from './queue.js';
@@ -12,7 +12,7 @@ export function createRestManager(options) {
12
12
  token: options.token,
13
13
  applicationId: options.applicationId ? BigInt(options.applicationId) : getBotIdFromToken(options.token),
14
14
  version: options.version ?? 10,
15
- baseUrl: options.baseUrl ?? 'https://discord.com/api',
15
+ baseUrl: options.proxy?.baseUrl ?? 'https://discord.com/api',
16
16
  maxRetryCount: Infinity,
17
17
  globallyRateLimited: false,
18
18
  processingRateLimitedPaths: false,
@@ -20,6 +20,7 @@ export function createRestManager(options) {
20
20
  queues: new Map(),
21
21
  rateLimitedPaths: new Map(),
22
22
  invalidBucket: createInvalidRequestBucket({}),
23
+ authorization: options.proxy?.authorization,
23
24
  routes: {
24
25
  webhooks: {
25
26
  id: (webhookId)=>{
@@ -656,8 +657,8 @@ export function createRestManager(options) {
656
657
  }
657
658
  // IF THERE IS NO REMAINING GLOBAL LIMIT, MARK IT RATE LIMITED GLOBALLY
658
659
  if (global) {
659
- const retryAfter1 = headers.get('retry-after');
660
- const globalReset = Date.now() + Number(retryAfter1) * 1000;
660
+ const retryAfter = headers.get('retry-after');
661
+ const globalReset = Date.now() + Number(retryAfter) * 1000;
661
662
  // rest.debug(
662
663
  // `[REST = Globally Rate Limited] URL: ${url} | Global Rest: ${globalReset}`
663
664
  // )
@@ -713,11 +714,12 @@ export function createRestManager(options) {
713
714
  logger.debug(`Request to ${url} exceeded the maximum allowed retries.`, 'with payload:', payload);
714
715
  // rest.debug(`[REST - RetriesMaxed] ${JSON.stringify(options)}`)
715
716
  // Remove item from queue to prevent retry
716
- return options.reject({
717
+ options.reject({
717
718
  ok: false,
718
719
  status: response.status,
719
720
  error: 'The options was rate limited and it maxed out the retries limit.'
720
721
  });
722
+ return;
721
723
  }
722
724
  // Rate limited, add back to queue
723
725
  rest.invalidBucket.handleCompletedRequest(response.status, response.headers.get('X-RateLimit-Scope') === 'shared');
@@ -727,16 +729,17 @@ export function createRestManager(options) {
727
729
  await response.json();
728
730
  return await options.retryRequest?.(options);
729
731
  }
730
- return options.reject({
732
+ options.reject({
731
733
  ok: false,
732
734
  status: response.status,
733
735
  body: JSON.stringify(await response.json())
734
736
  });
737
+ return;
735
738
  }
736
739
  const is204 = response.status === 204;
737
740
  const json = is204 ? undefined : await response.json();
738
741
  // Discord sometimes sends no response with 204 code
739
- return options.resolve({
742
+ options.resolve({
740
743
  ok: true,
741
744
  status: response.status,
742
745
  body: JSON.stringify(json)
@@ -787,6 +790,42 @@ export function createRestManager(options) {
787
790
  }
788
791
  },
789
792
  async makeRequest (method, url, body, options) {
793
+ if (!rest.baseUrl.startsWith('https://discord.com') && url[0] === '/') {
794
+ // Special handling for sending blobs across http to proxy
795
+ if (body?.file) {
796
+ if (!Array.isArray(body.file)) {
797
+ body.file = [
798
+ body.file
799
+ ];
800
+ }
801
+ // convert blobs to string before sending to proxy
802
+ body.file = await Promise.all(body.file.map(async (f)=>{
803
+ const url = encode(await f.blob.arrayBuffer());
804
+ return {
805
+ name: f.name,
806
+ blob: `data:${f.blob.type};base64,${url}`
807
+ };
808
+ }));
809
+ }
810
+ const headers = {
811
+ Authorization: rest.authorization ?? ""
812
+ };
813
+ if (body) {
814
+ headers['Content-Type'] = 'application/json';
815
+ }
816
+ const result = await fetch(`${rest.baseUrl}${url}`, {
817
+ body: body ? JSON.stringify(body) : undefined,
818
+ headers,
819
+ method
820
+ });
821
+ if (!result.ok) {
822
+ const err = await result.json().catch(()=>{});
823
+ // Legacy Handling to not break old code or when body is missing
824
+ if (!err?.body) throw new Error(`Error: ${err.message ?? result.statusText}`);
825
+ throw new Error(JSON.stringify(err));
826
+ }
827
+ return result.status !== 204 ? await result.json() : undefined;
828
+ }
790
829
  return await new Promise((resolve, reject)=>{
791
830
  const payload = {
792
831
  url,
@@ -796,7 +835,9 @@ export function createRestManager(options) {
796
835
  retryRequest: async function(options) {
797
836
  rest.processRequest(payload);
798
837
  },
799
- resolve: (data)=>resolve(data.status !== 204 ? JSON.parse(data.body ?? '{}') : undefined),
838
+ resolve: (data)=>{
839
+ resolve(data.status !== 204 ? JSON.parse(data.body ?? '{}') : undefined);
840
+ },
800
841
  reject,
801
842
  options
802
843
  };
@@ -810,7 +851,7 @@ export function createRestManager(options) {
810
851
  return camelize(await rest.makeRequest('POST', url, body));
811
852
  },
812
853
  async delete (url, body) {
813
- return camelize(await rest.makeRequest('DELETE', url, body));
854
+ camelize(await rest.makeRequest('DELETE', url, body));
814
855
  },
815
856
  async patch (url, body) {
816
857
  return camelize(await rest.makeRequest('PATCH', url, body));
@@ -820,11 +861,13 @@ export function createRestManager(options) {
820
861
  },
821
862
  async addReaction (channelId, messageId, reaction) {
822
863
  reaction = processReactionString(reaction);
823
- return await rest.put(rest.routes.channels.reactions.bot(channelId, messageId, reaction));
864
+ await rest.put(rest.routes.channels.reactions.bot(channelId, messageId, reaction));
824
865
  },
825
866
  async addReactions (channelId, messageId, reactions, ordered = false) {
826
867
  if (!ordered) {
827
- await Promise.all(reactions.map(async (reaction)=>await rest.addReaction(channelId, messageId, reaction)));
868
+ await Promise.all(reactions.map(async (reaction)=>{
869
+ await rest.addReaction(channelId, messageId, reaction);
870
+ }));
828
871
  return;
829
872
  }
830
873
  for (const reaction of reactions){
@@ -832,12 +875,12 @@ export function createRestManager(options) {
832
875
  }
833
876
  },
834
877
  async addRole (guildId, userId, roleId, reason) {
835
- return await rest.put(rest.routes.guilds.roles.member(guildId, userId, roleId), {
878
+ await rest.put(rest.routes.guilds.roles.member(guildId, userId, roleId), {
836
879
  reason
837
880
  });
838
881
  },
839
882
  async addThreadMember (channelId, userId) {
840
- return await rest.put(rest.routes.channels.threads.user(channelId, userId));
883
+ await rest.put(rest.routes.channels.threads.user(channelId, userId));
841
884
  },
842
885
  async createAutomodRule (guildId, options) {
843
886
  return await rest.post(rest.routes.guilds.automod.rules(guildId), options);
@@ -895,103 +938,103 @@ export function createRestManager(options) {
895
938
  });
896
939
  },
897
940
  async deleteAutomodRule (guildId, ruleId, reason) {
898
- return await rest.delete(rest.routes.guilds.automod.rule(guildId, ruleId), {
941
+ await rest.delete(rest.routes.guilds.automod.rule(guildId, ruleId), {
899
942
  reason
900
943
  });
901
944
  },
902
945
  async deleteChannel (channelId, reason) {
903
- return await rest.delete(rest.routes.channels.channel(channelId), {
946
+ await rest.delete(rest.routes.channels.channel(channelId), {
904
947
  reason
905
948
  });
906
949
  },
907
950
  async deleteChannelPermissionOverride (channelId, overwriteId, reason) {
908
- return await rest.delete(rest.routes.channels.overwrite(channelId, overwriteId), reason ? {
951
+ await rest.delete(rest.routes.channels.overwrite(channelId, overwriteId), reason ? {
909
952
  reason
910
953
  } : undefined);
911
954
  },
912
955
  async deleteEmoji (guildId, id, reason) {
913
- return await rest.delete(rest.routes.guilds.emoji(guildId, id), {
956
+ await rest.delete(rest.routes.guilds.emoji(guildId, id), {
914
957
  reason
915
958
  });
916
959
  },
917
960
  async deleteFollowupMessage (token, messageId) {
918
- return await rest.delete(rest.routes.interactions.responses.message(rest.applicationId, token, messageId));
961
+ await rest.delete(rest.routes.interactions.responses.message(rest.applicationId, token, messageId));
919
962
  },
920
963
  async deleteGlobalApplicationCommand (commandId) {
921
- return await rest.delete(rest.routes.interactions.commands.command(rest.applicationId, commandId));
964
+ await rest.delete(rest.routes.interactions.commands.command(rest.applicationId, commandId));
922
965
  },
923
966
  async deleteGuild (guildId) {
924
- return await rest.delete(rest.routes.guilds.guild(guildId));
967
+ await rest.delete(rest.routes.guilds.guild(guildId));
925
968
  },
926
969
  async deleteGuildApplicationCommand (commandId, guildId) {
927
- return await rest.delete(rest.routes.interactions.commands.guilds.one(rest.applicationId, guildId, commandId));
970
+ await rest.delete(rest.routes.interactions.commands.guilds.one(rest.applicationId, guildId, commandId));
928
971
  },
929
972
  async deleteGuildSticker (guildId, stickerId, reason) {
930
- return await rest.delete(rest.routes.guilds.sticker(guildId, stickerId), reason ? {
973
+ await rest.delete(rest.routes.guilds.sticker(guildId, stickerId), reason ? {
931
974
  reason
932
975
  } : undefined);
933
976
  },
934
977
  async deleteGuildTemplate (guildId, templateCode) {
935
- return await rest.delete(rest.routes.guilds.templates.guild(guildId, templateCode));
978
+ await rest.delete(rest.routes.guilds.templates.guild(guildId, templateCode));
936
979
  },
937
980
  async deleteIntegration (guildId, integrationId) {
938
- return await rest.delete(rest.routes.guilds.integration(guildId, integrationId));
981
+ await rest.delete(rest.routes.guilds.integration(guildId, integrationId));
939
982
  },
940
983
  async deleteInvite (inviteCode, reason) {
941
- return await rest.delete(rest.routes.guilds.invite(inviteCode), reason ? {
984
+ await rest.delete(rest.routes.guilds.invite(inviteCode), reason ? {
942
985
  reason
943
986
  } : undefined);
944
987
  },
945
988
  async deleteMessage (channelId, messageId, reason) {
946
- return await rest.delete(rest.routes.channels.message(channelId, messageId), {
989
+ await rest.delete(rest.routes.channels.message(channelId, messageId), {
947
990
  reason
948
991
  });
949
992
  },
950
993
  async deleteMessages (channelId, messageIds, reason) {
951
- return await rest.post(rest.routes.channels.bulk(channelId), {
994
+ await rest.post(rest.routes.channels.bulk(channelId), {
952
995
  messages: messageIds.slice(0, 100).map((id)=>id.toString()),
953
996
  reason
954
997
  });
955
998
  },
956
999
  async deleteOriginalInteractionResponse (token) {
957
- return await rest.delete(rest.routes.interactions.responses.original(rest.applicationId, token));
1000
+ await rest.delete(rest.routes.interactions.responses.original(rest.applicationId, token));
958
1001
  },
959
1002
  async deleteOwnReaction (channelId, messageId, reaction) {
960
1003
  reaction = processReactionString(reaction);
961
- return await rest.delete(rest.routes.channels.reactions.bot(channelId, messageId, reaction));
1004
+ await rest.delete(rest.routes.channels.reactions.bot(channelId, messageId, reaction));
962
1005
  },
963
1006
  async deleteReactionsAll (channelId, messageId) {
964
- return await rest.delete(rest.routes.channels.reactions.all(channelId, messageId));
1007
+ await rest.delete(rest.routes.channels.reactions.all(channelId, messageId));
965
1008
  },
966
1009
  async deleteReactionsEmoji (channelId, messageId, reaction) {
967
1010
  reaction = processReactionString(reaction);
968
- return await rest.delete(rest.routes.channels.reactions.emoji(channelId, messageId, reaction));
1011
+ await rest.delete(rest.routes.channels.reactions.emoji(channelId, messageId, reaction));
969
1012
  },
970
1013
  async deleteRole (guildId, roleId) {
971
- return await rest.delete(rest.routes.guilds.roles.one(guildId, roleId));
1014
+ await rest.delete(rest.routes.guilds.roles.one(guildId, roleId));
972
1015
  },
973
1016
  async deleteScheduledEvent (guildId, eventId) {
974
- return await rest.delete(rest.routes.guilds.events.event(guildId, eventId));
1017
+ await rest.delete(rest.routes.guilds.events.event(guildId, eventId));
975
1018
  },
976
1019
  async deleteStageInstance (channelId, reason) {
977
- return await rest.delete(rest.routes.channels.stage(channelId), reason ? {
1020
+ await rest.delete(rest.routes.channels.stage(channelId), reason ? {
978
1021
  reason
979
1022
  } : undefined);
980
1023
  },
981
1024
  async deleteUserReaction (channelId, messageId, userId, reaction) {
982
1025
  reaction = processReactionString(reaction);
983
- return await rest.delete(rest.routes.channels.reactions.user(channelId, messageId, reaction, userId));
1026
+ await rest.delete(rest.routes.channels.reactions.user(channelId, messageId, reaction, userId));
984
1027
  },
985
1028
  async deleteWebhook (webhookId, reason) {
986
- return await rest.delete(rest.routes.webhooks.id(webhookId), {
1029
+ await rest.delete(rest.routes.webhooks.id(webhookId), {
987
1030
  reason
988
1031
  });
989
1032
  },
990
1033
  async deleteWebhookMessage (webhookId, token, messageId, options) {
991
- return await rest.delete(rest.routes.webhooks.message(webhookId, token, messageId, options));
1034
+ await rest.delete(rest.routes.webhooks.message(webhookId, token, messageId, options));
992
1035
  },
993
1036
  async deleteWebhookWithToken (webhookId, token) {
994
- return await rest.delete(rest.routes.webhooks.webhook(webhookId, token));
1037
+ await rest.delete(rest.routes.webhooks.webhook(webhookId, token));
995
1038
  },
996
1039
  async editApplicationCommandPermissions (guildId, commandId, bearerToken, options) {
997
1040
  return await rest.put(rest.routes.interactions.commands.permission(rest.applicationId, guildId, commandId), {
@@ -1016,10 +1059,10 @@ export function createRestManager(options) {
1016
1059
  return await rest.patch(rest.routes.channels.channel(channelId), options);
1017
1060
  },
1018
1061
  async editChannelPermissionOverrides (channelId, options) {
1019
- return await rest.put(rest.routes.channels.overwrite(channelId, options.id), options);
1062
+ await rest.put(rest.routes.channels.overwrite(channelId, options.id), options);
1020
1063
  },
1021
1064
  async editChannelPositions (guildId, channelPositions) {
1022
- return await rest.patch(rest.routes.guilds.channels(guildId), channelPositions);
1065
+ await rest.patch(rest.routes.guilds.channels(guildId), channelPositions);
1023
1066
  },
1024
1067
  async editEmoji (guildId, id, options) {
1025
1068
  return await rest.patch(rest.routes.guilds.emoji(guildId, id), options);
@@ -1037,7 +1080,7 @@ export function createRestManager(options) {
1037
1080
  return await rest.patch(rest.routes.interactions.commands.guilds.one(rest.applicationId, guildId, commandId), options);
1038
1081
  },
1039
1082
  async editGuildMfaLevel (guildId, mfaLevel, reason) {
1040
- return await rest.post(rest.routes.guilds.mfa(guildId), {
1083
+ await rest.post(rest.routes.guilds.mfa(guildId), {
1041
1084
  level: mfaLevel,
1042
1085
  reason
1043
1086
  });
@@ -1061,7 +1104,7 @@ export function createRestManager(options) {
1061
1104
  });
1062
1105
  },
1063
1106
  async editOwnVoiceState (guildId, options) {
1064
- return await rest.patch(rest.routes.guilds.voice(guildId), {
1107
+ await rest.patch(rest.routes.guilds.voice(guildId), {
1065
1108
  channel_id: options.channelId,
1066
1109
  suppress: options.suppress,
1067
1110
  request_to_speak_timestamp: options.requestToSpeakTimestamp ? new Date(options.requestToSpeakTimestamp).toISOString() : options.requestToSpeakTimestamp
@@ -1082,7 +1125,7 @@ export function createRestManager(options) {
1082
1125
  });
1083
1126
  },
1084
1127
  async editUserVoiceState (guildId, options) {
1085
- return await rest.patch(rest.routes.guilds.voice(guildId, options.userId), {
1128
+ await rest.patch(rest.routes.guilds.voice(guildId, options.userId), {
1086
1129
  channel_id: options.channelId,
1087
1130
  suppress: options.suppress,
1088
1131
  user_id: options.userId
@@ -1299,24 +1342,24 @@ export function createRestManager(options) {
1299
1342
  return await rest.get(rest.routes.guilds.widget(guildId));
1300
1343
  },
1301
1344
  async joinThread (channelId) {
1302
- return await rest.put(rest.routes.channels.threads.me(channelId));
1345
+ await rest.put(rest.routes.channels.threads.me(channelId));
1303
1346
  },
1304
1347
  async leaveGuild (guildId) {
1305
- return await rest.delete(rest.routes.guilds.leave(guildId));
1348
+ await rest.delete(rest.routes.guilds.leave(guildId));
1306
1349
  },
1307
1350
  async leaveThread (channelId) {
1308
- return await rest.delete(rest.routes.channels.threads.me(channelId));
1351
+ await rest.delete(rest.routes.channels.threads.me(channelId));
1309
1352
  },
1310
1353
  async publishMessage (channelId, messageId) {
1311
1354
  return await rest.post(rest.routes.channels.crosspost(channelId, messageId));
1312
1355
  },
1313
1356
  async removeRole (guildId, userId, roleId, reason) {
1314
- return await rest.delete(rest.routes.guilds.roles.member(guildId, userId, roleId), {
1357
+ await rest.delete(rest.routes.guilds.roles.member(guildId, userId, roleId), {
1315
1358
  reason
1316
1359
  });
1317
1360
  },
1318
1361
  async removeThreadMember (channelId, userId) {
1319
- return await rest.delete(rest.routes.channels.threads.user(channelId, userId));
1362
+ await rest.delete(rest.routes.channels.threads.user(channelId, userId));
1320
1363
  },
1321
1364
  async sendFollowupMessage (token, options) {
1322
1365
  return await new Promise((resolve, reject)=>{
@@ -1329,13 +1372,15 @@ export function createRestManager(options) {
1329
1372
  // TODO: should change to reprocess queue item
1330
1373
  await rest.sendRequest(options);
1331
1374
  },
1332
- resolve: (data)=>resolve(data.status !== 204 ? JSON.parse(data.body ?? '{}') : undefined),
1375
+ resolve: (data)=>{
1376
+ resolve(data.status !== 204 ? JSON.parse(data.body ?? '{}') : undefined);
1377
+ },
1333
1378
  reject
1334
1379
  });
1335
1380
  });
1336
1381
  },
1337
1382
  async sendInteractionResponse (interactionId, token, options) {
1338
- return await new Promise((resolve, reject)=>{
1383
+ await new Promise((resolve, reject)=>{
1339
1384
  rest.sendRequest({
1340
1385
  url: rest.routes.interactions.responses.callback(interactionId, token),
1341
1386
  method: 'POST',
@@ -1345,7 +1390,9 @@ export function createRestManager(options) {
1345
1390
  // TODO: should change to reprocess queue item
1346
1391
  await rest.sendRequest(options);
1347
1392
  },
1348
- resolve: (data)=>resolve(data.status !== 204 ? JSON.parse(data.body ?? '{}') : undefined),
1393
+ resolve: (data)=>{
1394
+ resolve(data.status !== 204 ? JSON.parse(data.body ?? '{}') : undefined);
1395
+ },
1349
1396
  reject
1350
1397
  });
1351
1398
  });
@@ -1363,7 +1410,7 @@ export function createRestManager(options) {
1363
1410
  return await rest.put(rest.routes.guilds.templates.all(guildId));
1364
1411
  },
1365
1412
  async banMember (guildId, userId, options) {
1366
- return await rest.put(rest.routes.guilds.members.ban(guildId, userId), options);
1413
+ await rest.put(rest.routes.guilds.members.ban(guildId, userId), options);
1367
1414
  },
1368
1415
  async editBotMember (guildId, options) {
1369
1416
  return await rest.patch(rest.routes.guilds.members.bot(guildId), options);
@@ -1378,12 +1425,12 @@ export function createRestManager(options) {
1378
1425
  return await rest.get(rest.routes.guilds.members.members(guildId, options));
1379
1426
  },
1380
1427
  async kickMember (guildId, userId, reason) {
1381
- return await rest.delete(rest.routes.guilds.members.member(guildId, userId), {
1428
+ await rest.delete(rest.routes.guilds.members.member(guildId, userId), {
1382
1429
  reason
1383
1430
  });
1384
1431
  },
1385
1432
  async pinMessage (channelId, messageId, reason) {
1386
- return await rest.put(rest.routes.channels.pin(channelId, messageId), reason ? {
1433
+ await rest.put(rest.routes.channels.pin(channelId, messageId), reason ? {
1387
1434
  reason
1388
1435
  } : undefined);
1389
1436
  },
@@ -1394,15 +1441,15 @@ export function createRestManager(options) {
1394
1441
  return await rest.get(rest.routes.guilds.members.search(guildId, query, options));
1395
1442
  },
1396
1443
  async unbanMember (guildId, userId) {
1397
- return await rest.delete(rest.routes.guilds.members.ban(guildId, userId));
1444
+ await rest.delete(rest.routes.guilds.members.ban(guildId, userId));
1398
1445
  },
1399
1446
  async unpinMessage (channelId, messageId, reason) {
1400
- return await rest.delete(rest.routes.channels.pin(channelId, messageId), reason ? {
1447
+ await rest.delete(rest.routes.channels.pin(channelId, messageId), reason ? {
1401
1448
  reason
1402
1449
  } : undefined);
1403
1450
  },
1404
1451
  async triggerTypingIndicator (channelId) {
1405
- return await rest.post(rest.routes.channels.typing(channelId));
1452
+ await rest.post(rest.routes.channels.typing(channelId));
1406
1453
  },
1407
1454
  async upsertGlobalApplicationCommands (commands) {
1408
1455
  return await rest.put(rest.routes.interactions.commands.commands(rest.applicationId), commands);