@discordjs/core 0.4.0-dev.1671969841-22e2bbb.0 → 0.4.0-dev.1672661054-be294ea.0

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.
package/dist/index.mjs CHANGED
@@ -570,9 +570,58 @@ var InvitesAPI = class {
570
570
  };
571
571
  __name(InvitesAPI, "InvitesAPI");
572
572
 
573
+ // src/api/oauth2.ts
574
+ import { URL } from "node:url";
575
+ import { makeURLSearchParams as makeURLSearchParams5 } from "@discordjs/rest";
576
+ import {
577
+ Routes as Routes6,
578
+ RouteBases
579
+ } from "discord-api-types/v10";
580
+ var OAuth2API = class {
581
+ constructor(rest) {
582
+ this.rest = rest;
583
+ }
584
+ generateAuthorizationURL(options) {
585
+ const url = new URL(`${RouteBases.api}${Routes6.oauth2Authorization()}`);
586
+ url.search = makeURLSearchParams5(options).toString();
587
+ return url.toString();
588
+ }
589
+ async tokenExchange(options) {
590
+ return this.rest.post(Routes6.oauth2TokenExchange(), {
591
+ body: makeURLSearchParams5(options),
592
+ headers: {
593
+ "Content-Type": "application/x-www-form-urlencoded"
594
+ }
595
+ });
596
+ }
597
+ async refreshToken(options) {
598
+ return this.rest.post(Routes6.oauth2TokenExchange(), {
599
+ body: makeURLSearchParams5(options),
600
+ headers: {
601
+ "Content-Type": "application/x-www-form-urlencoded"
602
+ }
603
+ });
604
+ }
605
+ async getToken(options) {
606
+ return this.rest.post(Routes6.oauth2TokenExchange(), {
607
+ body: makeURLSearchParams5(options),
608
+ headers: {
609
+ "Content-Type": "application/x-www-form-urlencoded"
610
+ }
611
+ });
612
+ }
613
+ async getCurrentBotApplicationInformation() {
614
+ return this.rest.get(Routes6.oauth2CurrentApplication());
615
+ }
616
+ async getCurrentAuthorizationInformation() {
617
+ return this.rest.get(Routes6.oauth2CurrentAuthorization());
618
+ }
619
+ };
620
+ __name(OAuth2API, "OAuth2API");
621
+
573
622
  // src/api/roleConnections.ts
574
623
  import {
575
- Routes as Routes6
624
+ Routes as Routes7
576
625
  } from "discord-api-types/v10";
577
626
  var RoleConnectionsAPI = class {
578
627
  constructor(rest) {
@@ -580,11 +629,11 @@ var RoleConnectionsAPI = class {
580
629
  }
581
630
  async getMetadataRecords(applicationId) {
582
631
  return this.rest.get(
583
- Routes6.applicationRoleConnectionMetadata(applicationId)
632
+ Routes7.applicationRoleConnectionMetadata(applicationId)
584
633
  );
585
634
  }
586
635
  async updateMetadataRecords(applicationId, options) {
587
- return this.rest.put(Routes6.applicationRoleConnectionMetadata(applicationId), {
636
+ return this.rest.put(Routes7.applicationRoleConnectionMetadata(applicationId), {
588
637
  body: options
589
638
  });
590
639
  }
@@ -593,34 +642,34 @@ __name(RoleConnectionsAPI, "RoleConnectionsAPI");
593
642
 
594
643
  // src/api/sticker.ts
595
644
  import {
596
- Routes as Routes7
645
+ Routes as Routes8
597
646
  } from "discord-api-types/v10";
598
647
  var StickersAPI = class {
599
648
  constructor(rest) {
600
649
  this.rest = rest;
601
650
  }
602
651
  async getNitroStickers() {
603
- return this.rest.get(Routes7.nitroStickerPacks());
652
+ return this.rest.get(Routes8.nitroStickerPacks());
604
653
  }
605
654
  async get(stickerId) {
606
- return this.rest.get(Routes7.sticker(stickerId));
655
+ return this.rest.get(Routes8.sticker(stickerId));
607
656
  }
608
657
  };
609
658
  __name(StickersAPI, "StickersAPI");
610
659
 
611
660
  // src/api/thread.ts
612
661
  import {
613
- Routes as Routes8
662
+ Routes as Routes9
614
663
  } from "discord-api-types/v10";
615
664
  var ThreadsAPI = class {
616
665
  constructor(rest) {
617
666
  this.rest = rest;
618
667
  }
619
668
  async get(threadId) {
620
- return this.rest.get(Routes8.channel(threadId));
669
+ return this.rest.get(Routes9.channel(threadId));
621
670
  }
622
671
  async create(channelId, { message_id, ...body }) {
623
- return this.rest.post(Routes8.threads(channelId, message_id), { body });
672
+ return this.rest.post(Routes9.threads(channelId, message_id), { body });
624
673
  }
625
674
  async createForumThread(channelId, { message, ...optionsBody }) {
626
675
  const { files, ...messageBody } = message;
@@ -628,84 +677,84 @@ var ThreadsAPI = class {
628
677
  ...optionsBody,
629
678
  message: messageBody
630
679
  };
631
- return this.rest.post(Routes8.threads(channelId), { files, body });
680
+ return this.rest.post(Routes9.threads(channelId), { files, body });
632
681
  }
633
682
  async join(threadId) {
634
- await this.rest.put(Routes8.threadMembers(threadId, "@me"));
683
+ await this.rest.put(Routes9.threadMembers(threadId, "@me"));
635
684
  }
636
685
  async addMember(threadId, userId) {
637
- await this.rest.put(Routes8.threadMembers(threadId, userId));
686
+ await this.rest.put(Routes9.threadMembers(threadId, userId));
638
687
  }
639
688
  async leave(threadId) {
640
- await this.rest.delete(Routes8.threadMembers(threadId, "@me"));
689
+ await this.rest.delete(Routes9.threadMembers(threadId, "@me"));
641
690
  }
642
691
  async removeMember(threadId, userId) {
643
- await this.rest.delete(Routes8.threadMembers(threadId, userId));
692
+ await this.rest.delete(Routes9.threadMembers(threadId, userId));
644
693
  }
645
694
  async getMember(threadId, userId) {
646
- return this.rest.get(Routes8.threadMembers(threadId, userId));
695
+ return this.rest.get(Routes9.threadMembers(threadId, userId));
647
696
  }
648
697
  async getAllMembers(threadId) {
649
- return this.rest.get(Routes8.threadMembers(threadId));
698
+ return this.rest.get(Routes9.threadMembers(threadId));
650
699
  }
651
700
  };
652
701
  __name(ThreadsAPI, "ThreadsAPI");
653
702
 
654
703
  // src/api/user.ts
655
- import { makeURLSearchParams as makeURLSearchParams5 } from "@discordjs/rest";
704
+ import { makeURLSearchParams as makeURLSearchParams6 } from "@discordjs/rest";
656
705
  import {
657
- Routes as Routes9
706
+ Routes as Routes10
658
707
  } from "discord-api-types/v10";
659
708
  var UsersAPI = class {
660
709
  constructor(rest) {
661
710
  this.rest = rest;
662
711
  }
663
712
  async get(userId) {
664
- return this.rest.get(Routes9.user(userId));
713
+ return this.rest.get(Routes10.user(userId));
665
714
  }
666
715
  async getCurrent() {
667
- return this.rest.get(Routes9.user("@me"));
716
+ return this.rest.get(Routes10.user("@me"));
668
717
  }
669
718
  async getGuilds(options = {}) {
670
- return this.rest.get(Routes9.userGuilds(), {
671
- query: makeURLSearchParams5(options)
719
+ return this.rest.get(Routes10.userGuilds(), {
720
+ query: makeURLSearchParams6(options)
672
721
  });
673
722
  }
674
723
  async leaveGuild(guildId) {
675
- await this.rest.delete(Routes9.userGuild(guildId));
724
+ await this.rest.delete(Routes10.userGuild(guildId));
676
725
  }
677
726
  async edit(user) {
678
- return this.rest.patch(Routes9.user("@me"), { body: user });
727
+ return this.rest.patch(Routes10.user("@me"), { body: user });
679
728
  }
680
729
  async getGuildMember(guildId) {
681
- return this.rest.get(Routes9.userGuildMember(guildId));
730
+ return this.rest.get(Routes10.userGuildMember(guildId));
682
731
  }
683
732
  async editGuildMember(guildId, member = {}, reason) {
684
- return this.rest.patch(Routes9.guildMember(guildId, "@me"), {
733
+ return this.rest.patch(Routes10.guildMember(guildId, "@me"), {
685
734
  reason,
686
735
  body: member
687
736
  });
688
737
  }
689
738
  async setVoiceState(guildId, options = {}) {
690
- return this.rest.patch(Routes9.guildVoiceState(guildId, "@me"), {
739
+ return this.rest.patch(Routes10.guildVoiceState(guildId, "@me"), {
691
740
  body: options
692
741
  });
693
742
  }
694
743
  async createDM(userId) {
695
- return this.rest.post(Routes9.userChannels(), {
744
+ return this.rest.post(Routes10.userChannels(), {
696
745
  body: { recipient_id: userId }
697
746
  });
698
747
  }
699
748
  async getConnections() {
700
- return this.rest.get(Routes9.userConnections());
749
+ return this.rest.get(Routes10.userConnections());
701
750
  }
702
751
  async getApplicationRoleConnection(applicationId) {
703
752
  return this.rest.get(
704
- Routes9.userApplicationRoleConnection(applicationId)
753
+ Routes10.userApplicationRoleConnection(applicationId)
705
754
  );
706
755
  }
707
756
  async updateApplicationRoleConnection(applicationId, options) {
708
- return this.rest.put(Routes9.userApplicationRoleConnection(applicationId), {
757
+ return this.rest.put(Routes10.userApplicationRoleConnection(applicationId), {
709
758
  body: options
710
759
  });
711
760
  }
@@ -713,40 +762,40 @@ var UsersAPI = class {
713
762
  __name(UsersAPI, "UsersAPI");
714
763
 
715
764
  // src/api/voice.ts
716
- import { Routes as Routes10 } from "discord-api-types/v10";
765
+ import { Routes as Routes11 } from "discord-api-types/v10";
717
766
  var VoiceAPI = class {
718
767
  constructor(rest) {
719
768
  this.rest = rest;
720
769
  }
721
770
  async getVoiceRegions() {
722
- return this.rest.get(Routes10.voiceRegions());
771
+ return this.rest.get(Routes11.voiceRegions());
723
772
  }
724
773
  };
725
774
  __name(VoiceAPI, "VoiceAPI");
726
775
 
727
776
  // src/api/webhook.ts
728
- import { makeURLSearchParams as makeURLSearchParams6 } from "@discordjs/rest";
777
+ import { makeURLSearchParams as makeURLSearchParams7 } from "@discordjs/rest";
729
778
  import {
730
- Routes as Routes11
779
+ Routes as Routes12
731
780
  } from "discord-api-types/v10";
732
781
  var WebhooksAPI = class {
733
782
  constructor(rest) {
734
783
  this.rest = rest;
735
784
  }
736
785
  async get(id, token) {
737
- return this.rest.get(Routes11.webhook(id, token));
786
+ return this.rest.get(Routes12.webhook(id, token));
738
787
  }
739
788
  async create(channelId, data, reason) {
740
- return this.rest.post(Routes11.channelWebhooks(channelId), {
789
+ return this.rest.post(Routes12.channelWebhooks(channelId), {
741
790
  reason,
742
791
  body: data
743
792
  });
744
793
  }
745
794
  async edit(id, webhook, { token, reason } = {}) {
746
- return this.rest.patch(Routes11.webhook(id, token), { reason, body: webhook });
795
+ return this.rest.patch(Routes12.webhook(id, token), { reason, body: webhook });
747
796
  }
748
797
  async delete(id, { token, reason } = {}) {
749
- await this.rest.delete(Routes11.webhook(id, token), { reason });
798
+ await this.rest.delete(Routes12.webhook(id, token), { reason });
750
799
  }
751
800
  async execute(id, token, {
752
801
  wait,
@@ -754,43 +803,43 @@ var WebhooksAPI = class {
754
803
  files,
755
804
  ...body
756
805
  }) {
757
- return this.rest.post(Routes11.webhook(id, token), {
758
- query: makeURLSearchParams6({ wait, thread_id }),
806
+ return this.rest.post(Routes12.webhook(id, token), {
807
+ query: makeURLSearchParams7({ wait, thread_id }),
759
808
  files,
760
809
  body,
761
810
  auth: false
762
811
  });
763
812
  }
764
813
  async executeSlack(id, token, body, options = {}) {
765
- await this.rest.post(Routes11.webhookPlatform(id, token, "slack"), {
766
- query: makeURLSearchParams6(options),
814
+ await this.rest.post(Routes12.webhookPlatform(id, token, "slack"), {
815
+ query: makeURLSearchParams7(options),
767
816
  body,
768
817
  auth: false
769
818
  });
770
819
  }
771
820
  async executeGitHub(id, token, body, options = {}) {
772
- await this.rest.post(Routes11.webhookPlatform(id, token, "github"), {
773
- query: makeURLSearchParams6(options),
821
+ await this.rest.post(Routes12.webhookPlatform(id, token, "github"), {
822
+ query: makeURLSearchParams7(options),
774
823
  body,
775
824
  auth: false
776
825
  });
777
826
  }
778
827
  async getMessage(id, token, messageId, options = {}) {
779
- return this.rest.get(Routes11.webhookMessage(id, token, messageId), {
780
- query: makeURLSearchParams6(options),
828
+ return this.rest.get(Routes12.webhookMessage(id, token, messageId), {
829
+ query: makeURLSearchParams7(options),
781
830
  auth: false
782
831
  });
783
832
  }
784
833
  async editMessage(id, token, messageId, { thread_id, ...body }) {
785
- return this.rest.patch(Routes11.webhookMessage(id, token, messageId), {
786
- query: makeURLSearchParams6({ thread_id }),
834
+ return this.rest.patch(Routes12.webhookMessage(id, token, messageId), {
835
+ query: makeURLSearchParams7({ thread_id }),
787
836
  auth: false,
788
837
  body
789
838
  });
790
839
  }
791
840
  async deleteMessage(id, token, messageId, options = {}) {
792
- await this.rest.delete(Routes11.webhookMessage(id, token, messageId), {
793
- query: makeURLSearchParams6(options),
841
+ await this.rest.delete(Routes12.webhookMessage(id, token, messageId), {
842
+ query: makeURLSearchParams7(options),
794
843
  auth: false
795
844
  });
796
845
  }
@@ -806,6 +855,7 @@ var API = class {
806
855
  this.guilds = new GuildsAPI(rest);
807
856
  this.invites = new InvitesAPI(rest);
808
857
  this.roleConnections = new RoleConnectionsAPI(rest);
858
+ this.oauth2 = new OAuth2API(rest);
809
859
  this.stickers = new StickersAPI(rest);
810
860
  this.threads = new ThreadsAPI(rest);
811
861
  this.users = new UsersAPI(rest);
@@ -818,6 +868,7 @@ var API = class {
818
868
  guilds;
819
869
  interactions;
820
870
  invites;
871
+ oauth2;
821
872
  roleConnections;
822
873
  stickers;
823
874
  threads;
@@ -874,6 +925,7 @@ export {
874
925
  GuildsAPI,
875
926
  InteractionsAPI,
876
927
  InvitesAPI,
928
+ OAuth2API,
877
929
  RoleConnectionsAPI,
878
930
  StickersAPI,
879
931
  ThreadsAPI,