oceanic.js 1.0.0-dev.3cfdac7 → 1.0.0-dev.3d69a0f

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.
Files changed (184) hide show
  1. package/.github/workflows/dev-publish.yml +6 -4
  2. package/.github/workflows/docs.yml +2 -6
  3. package/.github/workflows/should-publish-dev.yml +29 -0
  4. package/README.md +5 -3
  5. package/dist/lib/Client.d.ts +21 -10
  6. package/dist/lib/Client.js +65 -31
  7. package/dist/lib/Constants.d.ts +1 -1
  8. package/dist/lib/Constants.js +3 -2
  9. package/dist/lib/gateway/GatewayError.d.ts +2 -0
  10. package/dist/lib/gateway/GatewayError.js +3 -1
  11. package/dist/lib/gateway/Shard.d.ts +1 -1
  12. package/dist/lib/gateway/Shard.js +280 -435
  13. package/dist/lib/gateway/ShardManager.d.ts +2 -0
  14. package/dist/lib/gateway/ShardManager.js +6 -4
  15. package/dist/lib/rest/Bucket.d.ts +1 -0
  16. package/dist/lib/rest/Bucket.js +4 -3
  17. package/dist/lib/rest/DiscordHTTPError.d.ts +2 -0
  18. package/dist/lib/rest/DiscordHTTPError.js +3 -2
  19. package/dist/lib/rest/DiscordRESTError.d.ts +2 -0
  20. package/dist/lib/rest/DiscordRESTError.js +3 -2
  21. package/dist/lib/rest/RESTManager.d.ts +6 -2
  22. package/dist/lib/rest/RESTManager.js +10 -8
  23. package/dist/lib/rest/RequestHandler.d.ts +1 -0
  24. package/dist/lib/rest/RequestHandler.js +10 -9
  25. package/dist/lib/rest/SequentialBucket.d.ts +1 -0
  26. package/dist/lib/rest/SequentialBucket.js +3 -2
  27. package/dist/lib/routes/ApplicationCommands.d.ts +1 -0
  28. package/dist/lib/routes/ApplicationCommands.js +3 -1
  29. package/dist/lib/routes/Channels.d.ts +26 -17
  30. package/dist/lib/routes/Channels.js +155 -30
  31. package/dist/lib/routes/Guilds.d.ts +6 -3
  32. package/dist/lib/routes/Guilds.js +65 -41
  33. package/dist/lib/routes/Interactions.d.ts +9 -6
  34. package/dist/lib/routes/Interactions.js +2 -1
  35. package/dist/lib/routes/OAuth.d.ts +2 -0
  36. package/dist/lib/routes/OAuth.js +4 -3
  37. package/dist/lib/routes/Users.d.ts +2 -0
  38. package/dist/lib/routes/Users.js +2 -1
  39. package/dist/lib/routes/Webhooks.d.ts +9 -6
  40. package/dist/lib/routes/Webhooks.js +2 -1
  41. package/dist/lib/structures/AnnouncementChannel.d.ts +6 -5
  42. package/dist/lib/structures/AnnouncementChannel.js +4 -3
  43. package/dist/lib/structures/AnnouncementThreadChannel.d.ts +2 -1
  44. package/dist/lib/structures/AnnouncementThreadChannel.js +3 -2
  45. package/dist/lib/structures/Application.d.ts +6 -3
  46. package/dist/lib/structures/Application.js +14 -6
  47. package/dist/lib/structures/ApplicationCommand.d.ts +7 -4
  48. package/dist/lib/structures/ApplicationCommand.js +17 -12
  49. package/dist/lib/structures/Attachment.d.ts +1 -0
  50. package/dist/lib/structures/Attachment.js +2 -1
  51. package/dist/lib/structures/AuditLogEntry.d.ts +2 -1
  52. package/dist/lib/structures/AuditLogEntry.js +3 -2
  53. package/dist/lib/structures/AutoModerationRule.d.ts +6 -4
  54. package/dist/lib/structures/AutoModerationRule.js +16 -7
  55. package/dist/lib/structures/AutocompleteInteraction.d.ts +25 -15
  56. package/dist/lib/structures/AutocompleteInteraction.js +39 -17
  57. package/dist/lib/structures/Base.d.ts +1 -0
  58. package/dist/lib/structures/Base.js +7 -6
  59. package/dist/lib/structures/CategoryChannel.d.ts +2 -1
  60. package/dist/lib/structures/CategoryChannel.js +9 -5
  61. package/dist/lib/structures/Channel.d.ts +1 -0
  62. package/dist/lib/structures/Channel.js +2 -1
  63. package/dist/lib/structures/ClientApplication.d.ts +1 -0
  64. package/dist/lib/structures/ClientApplication.js +2 -1
  65. package/dist/lib/structures/CommandInteraction.d.ts +29 -19
  66. package/dist/lib/structures/CommandInteraction.js +49 -27
  67. package/dist/lib/structures/ComponentInteraction.d.ts +31 -21
  68. package/dist/lib/structures/ComponentInteraction.js +47 -25
  69. package/dist/lib/structures/ExtendedUser.d.ts +2 -1
  70. package/dist/lib/structures/ExtendedUser.js +3 -2
  71. package/dist/lib/structures/ForumChannel.d.ts +6 -3
  72. package/dist/lib/structures/ForumChannel.js +14 -7
  73. package/dist/lib/structures/GroupChannel.d.ts +14 -10
  74. package/dist/lib/structures/GroupChannel.js +19 -12
  75. package/dist/lib/structures/Guild.d.ts +37 -15
  76. package/dist/lib/structures/Guild.js +111 -41
  77. package/dist/lib/structures/GuildChannel.d.ts +5 -3
  78. package/dist/lib/structures/GuildChannel.js +18 -9
  79. package/dist/lib/structures/GuildPreview.d.ts +2 -1
  80. package/dist/lib/structures/GuildPreview.js +4 -3
  81. package/dist/lib/structures/GuildScheduledEvent.d.ts +8 -3
  82. package/dist/lib/structures/GuildScheduledEvent.js +22 -9
  83. package/dist/lib/structures/GuildTemplate.d.ts +5 -2
  84. package/dist/lib/structures/GuildTemplate.js +21 -7
  85. package/dist/lib/structures/Integration.d.ts +12 -3
  86. package/dist/lib/structures/Integration.js +16 -6
  87. package/dist/lib/structures/Interaction.d.ts +6 -3
  88. package/dist/lib/structures/Interaction.js +9 -4
  89. package/dist/lib/structures/Invite.d.ts +10 -5
  90. package/dist/lib/structures/Invite.js +35 -21
  91. package/dist/lib/structures/Member.d.ts +5 -3
  92. package/dist/lib/structures/Member.js +22 -12
  93. package/dist/lib/structures/Message.d.ts +30 -13
  94. package/dist/lib/structures/Message.js +74 -58
  95. package/dist/lib/structures/ModalSubmitInteraction.d.ts +29 -19
  96. package/dist/lib/structures/ModalSubmitInteraction.js +45 -23
  97. package/dist/lib/structures/PartialApplication.d.ts +2 -0
  98. package/dist/lib/structures/PartialApplication.js +3 -1
  99. package/dist/lib/structures/Permission.d.ts +4 -2
  100. package/dist/lib/structures/Permission.js +18 -11
  101. package/dist/lib/structures/PermissionOverwrite.d.ts +3 -1
  102. package/dist/lib/structures/PermissionOverwrite.js +3 -1
  103. package/dist/lib/structures/PingInteraction.d.ts +1 -0
  104. package/dist/lib/structures/PingInteraction.js +2 -1
  105. package/dist/lib/structures/PrivateChannel.d.ts +6 -4
  106. package/dist/lib/structures/PrivateChannel.js +10 -6
  107. package/dist/lib/structures/PrivateThreadChannel.d.ts +2 -1
  108. package/dist/lib/structures/PrivateThreadChannel.js +3 -2
  109. package/dist/lib/structures/PublicThreadChannel.d.ts +2 -1
  110. package/dist/lib/structures/PublicThreadChannel.js +3 -2
  111. package/dist/lib/structures/Role.d.ts +4 -2
  112. package/dist/lib/structures/Role.js +17 -8
  113. package/dist/lib/structures/StageChannel.d.ts +10 -6
  114. package/dist/lib/structures/StageChannel.js +25 -7
  115. package/dist/lib/structures/StageInstance.d.ts +11 -6
  116. package/dist/lib/structures/StageInstance.js +25 -9
  117. package/dist/lib/structures/Team.d.ts +3 -1
  118. package/dist/lib/structures/Team.js +5 -4
  119. package/dist/lib/structures/TextChannel.d.ts +1 -0
  120. package/dist/lib/structures/TextChannel.js +3 -3
  121. package/dist/lib/structures/TextableChannel.d.ts +19 -12
  122. package/dist/lib/structures/TextableChannel.js +26 -12
  123. package/dist/lib/structures/ThreadChannel.d.ts +20 -11
  124. package/dist/lib/structures/ThreadChannel.js +33 -14
  125. package/dist/lib/structures/UnavailableGuild.d.ts +1 -0
  126. package/dist/lib/structures/UnavailableGuild.js +2 -1
  127. package/dist/lib/structures/User.d.ts +1 -0
  128. package/dist/lib/structures/User.js +2 -1
  129. package/dist/lib/structures/VoiceChannel.d.ts +20 -10
  130. package/dist/lib/structures/VoiceChannel.js +34 -9
  131. package/dist/lib/structures/VoiceState.d.ts +6 -3
  132. package/dist/lib/structures/VoiceState.js +13 -11
  133. package/dist/lib/structures/Webhook.d.ts +7 -4
  134. package/dist/lib/structures/Webhook.js +20 -15
  135. package/dist/lib/types/application-commands.d.ts +4 -2
  136. package/dist/lib/types/audit-log.d.ts +1 -0
  137. package/dist/lib/types/auto-moderation.d.ts +1 -0
  138. package/dist/lib/types/channels.d.ts +29 -4
  139. package/dist/lib/types/client.d.ts +1 -7
  140. package/dist/lib/types/events.d.ts +25 -27
  141. package/dist/lib/types/gateway-raw.d.ts +2 -1
  142. package/dist/lib/types/gateway.d.ts +3 -2
  143. package/dist/lib/types/guild-template.d.ts +1 -0
  144. package/dist/lib/types/guilds.d.ts +19 -4
  145. package/dist/lib/types/index.d.ts +1 -0
  146. package/dist/lib/types/interactions.d.ts +12 -11
  147. package/dist/lib/types/json.d.ts +47 -46
  148. package/dist/lib/types/oauth.d.ts +1 -0
  149. package/dist/lib/types/request-handler.d.ts +1 -0
  150. package/dist/lib/types/scheduled-events.d.ts +3 -2
  151. package/dist/lib/types/shared.d.ts +2 -2
  152. package/dist/lib/types/users.d.ts +1 -0
  153. package/dist/lib/types/voice.d.ts +20 -0
  154. package/dist/lib/types/webhooks.d.ts +1 -0
  155. package/dist/lib/util/Collection.d.ts +1 -0
  156. package/dist/lib/util/Collection.js +2 -1
  157. package/dist/lib/util/InteractionOptionsWrapper.d.ts +7 -0
  158. package/dist/lib/util/InteractionOptionsWrapper.js +23 -2
  159. package/dist/lib/util/Routes.d.ts +1 -0
  160. package/dist/lib/util/Routes.js +2 -1
  161. package/dist/lib/util/TypedCollection.d.ts +1 -0
  162. package/dist/lib/util/TypedCollection.js +5 -4
  163. package/dist/lib/util/TypedEmitter.d.ts +1 -0
  164. package/dist/lib/util/TypedEmitter.js +2 -1
  165. package/dist/lib/util/Util.d.ts +3 -1
  166. package/dist/lib/util/Util.js +28 -2
  167. package/dist/package.json +6 -2
  168. package/examples/applicationCommand.js +20 -20
  169. package/examples/audio.mp3 +0 -0
  170. package/examples/components.js +17 -17
  171. package/examples/embeds.js +25 -24
  172. package/examples/intents.js +10 -11
  173. package/examples/interactions.js +171 -0
  174. package/examples/voice.js +47 -0
  175. package/package.json +6 -2
  176. package/build.js +0 -6
  177. package/dist/lib/types/stage-instances.d.ts +0 -12
  178. package/dist/lib/util/Properties.d.ts +0 -9
  179. package/dist/lib/util/Properties.js +0 -27
  180. package/dist/lib/voice/VoiceConnection.d.ts +0 -7
  181. package/dist/lib/voice/VoiceConnection.js +0 -16
  182. package/dist/lib/voice/VoiceConnectionManager.d.ts +0 -7
  183. package/dist/lib/voice/VoiceConnectionManager.js +0 -15
  184. package/doc-test.js +0 -39
@@ -1,6 +1,6 @@
1
- // the application command management functions are on ClientApplication (client.application) & client.rest.applicationCommands
2
- // https://oceanic.owo-whats-this.dev/classes/structures_ClientApplication.ClientApplication.html
3
- // https://oceanic.owo-whats-this.dev/classes/routes_ApplicationCommands.ApplicationCommands.html
1
+ // The application command management functions are on ClientApplication (client.application) & client.rest.applicationCommands
2
+ // https://oceanic.owo-whats-this.dev/latest/classes/ClientApplication.ClientApplication.html
3
+ // https://oceanic.owo-whats-this.dev/latest/classes/Routes_ApplicationCommands.ApplicationCommands.html
4
4
  const { ApplicationCommandOptionTypes, ApplicationCommandTypes, Client } = require("oceanic.js");
5
5
 
6
6
  const client = new Client({
@@ -13,24 +13,24 @@ const client = new Client({
13
13
  client.on("ready", async() => {
14
14
  console.log("Ready as", client.user.tag);
15
15
 
16
- // https://oceanic.owo-whats-this.dev/classes/structures_ClientApplication.ClientApplication.html#createGlobalCommand
16
+ // https://oceanic.owo-whats-this.dev/classes/ClientApplication.ClientApplication.html#createGlobalCommand
17
17
  // Create a single command
18
18
  await client.application.createGlobalCommand({
19
- type: ApplicationCommandTypes.CHAT_INPUT, // CHAT_INPUT = slash commands - full list: https://oceanic.owo-whats-this.dev/enums/Constants.ApplicationCommandTypes.html
19
+ type: ApplicationCommandTypes.CHAT_INPUT, // CHAT_INPUT = slash commands - full list: https://oceanic.owo-whats-this.dev/latest/enums/Constants.ApplicationCommandTypes.html
20
20
  name: "global-command",
21
21
  description: "A global command.",
22
22
  options: [
23
23
  {
24
- type: ApplicationCommandOptionTypes.STRING, // A string input - full list: https://oceanic.owo-whats-this.dev/enums/Constants.ApplicationCommandOptionTypes.html
24
+ type: ApplicationCommandOptionTypes.STRING, // A string input - full list: https://oceanic.owo-whats-this.dev/latest/enums/Constants.ApplicationCommandOptionTypes.html
25
25
  name: "suspicious",
26
26
  nameLocalizations: { // (optional) a dictionary of locales to localized names (see: https://discord.com/developers/docs/reference#locales)
27
27
  "es-ES": "sospechoso"
28
28
  },
29
29
  description: "Are you sus?",
30
- descriptionLocalizations: { // same as above
30
+ descriptionLocalizations: { // Same as above
31
31
  "es-ES": "¿Eres sus?"
32
32
  },
33
- choices: [ // a BOOLEAN can also be used instead
33
+ choices: [ // A BOOLEAN can also be used instead
34
34
  {
35
35
  name: "Yes",
36
36
  nameLocalizations: {
@@ -49,10 +49,10 @@ client.on("ready", async() => {
49
49
  }
50
50
  ],
51
51
  dmPermission: false, // false = usable in guilds only, true = both guild & direct message
52
- defaultMemberPermissions: "8" // The default permissions required to use this command (8 = Administrator)
52
+ defaultMemberPermissions: "8" // The bitfield of the default permissions required to use this command (8 = Administrator)
53
53
  });
54
54
 
55
- // https://oceanic.owo-whats-this.dev/classes/structures_ClientApplication.ClientApplication.html#bulkEditGlobalCommands
55
+ // https://oceanic.owo-whats-this.dev/latest/classes/ClientApplication.ClientApplication.html#bulkEditGlobalCommands
56
56
  // Instead of deleting individual commands or creating commands one at a time, you can create them in bulk.
57
57
  await client.application.bulkEditGlobalCommands([
58
58
  {
@@ -65,7 +65,7 @@ client.on("ready", async() => {
65
65
  },
66
66
  {
67
67
  type: ApplicationCommandTypes.MESSAGE, // This will display in the `Apps` context menu, when clicking on a message.
68
- // same as above
68
+ // Same as above
69
69
  name: "Raw Json",
70
70
  nameLocalizations: {
71
71
  "es-ES": "json crudo"
@@ -73,18 +73,18 @@ client.on("ready", async() => {
73
73
  }
74
74
  ]);
75
75
 
76
- // https://oceanic.owo-whats-this.dev/classes/structures_ClientApplication.ClientApplication.html#getGlobalCommands
76
+ // https://oceanic.owo-whats-this.dev/latest/classes/ClientApplication.ClientApplication.html#getGlobalCommands
77
77
  // if you need to fetch your commands
78
78
  const commands = await client.application.getGlobalCommands();
79
- console.log(commands); // an array of ApplicationCommand classes
79
+ console.log(commands); // An array of ApplicationCommand classes
80
80
 
81
- for(const command of commands) {
82
- // https://oceanic.owo-whats-this.dev/classes/structures_ApplicationCommand.ApplicationCommand.html#delete
83
- await command.delete(); // DON'T DO THIS! This is just an example. Use `bulkedit` with an empty array if you want to delete all commands.
81
+ for (const command of commands) {
82
+ // https://oceanic.owo-whats-this.dev/latest/classes/ApplicationCommand.ApplicationCommand.html#delete
83
+ await command.delete(); // DON'T DO THIS! This is just an example. Use `bulkEdit` with an empty array if you want to delete all commands
84
84
  }
85
85
 
86
- // https://oceanic.owo-whats-this.dev/classes/structures_ClientApplication.ClientApplication.html#createGuildCommand
87
- // guilds commands are exactly the same thing, but with a guild id included.
86
+ // https://oceanic.owo-whats-this.dev/latest/classes/ClientApplication.ClientApplication.html#createGuildCommand
87
+ // Guilds commands are exactly the same thing, but with a guild ID included
88
88
  await client.application.createGuildCommand("1005489770278953112", {
89
89
  type: ApplicationCommandTypes.CHAT_INPUT,
90
90
  name: "guild-command",
@@ -98,10 +98,10 @@ client.on("ready", async() => {
98
98
  });
99
99
  });
100
100
 
101
- // an error handler
101
+ // An error handler
102
102
  client.on("error", (error) => {
103
103
  console.error("Something went wrong:", error);
104
104
  });
105
105
 
106
- // connect to Discord
106
+ // Connect to Discord
107
107
  client.connect();
Binary file
@@ -9,25 +9,25 @@ const client = new Client({
9
9
 
10
10
  client.on("ready", () => console.log("Ready as", client.user.tag));
11
11
 
12
- client.on("messageCreate", async(msg) => {
12
+ client.on("messageCreate", async (msg) => {
13
13
  if(msg.content.includes("!component")) {
14
14
  await client.rest.channels.createMessage(msg.channel.id, {
15
15
  content: `Here's some buttons for you, ${msg.author.mention}.`,
16
16
  components: [
17
17
  {
18
- // the top level component must always be an action row.
19
- // Full list of types: https://oceanic.owo-whats-this.dev/enums/Constants.ComponentTypes.html
20
- // https://oceanic.owo-whats-this.dev/interfaces/types_channels.MessageActionRow.html
18
+ // The top level component must always be an action row.
19
+ // Full list of types: https://oceanic.owo-whats-this.dev/latest/enums/Constants.ComponentTypes.html
20
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.MessageActionRow.html
21
21
  type: ComponentTypes.ACTION_ROW,
22
22
  components: [
23
23
  {
24
- // https://oceanic.owo-whats-this.dev/interfaces/types_channels.TextButton.html
24
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.TextButton.html
25
25
  type: ComponentTypes.BUTTON,
26
- style: ButtonStyles.PRIMARY, // the style of button - full list: https://oceanic.owo-whats-this.dev/enums/Constants.ButtonStyles.html
26
+ style: ButtonStyles.PRIMARY, // The style of button - full list: https://oceanic.owo-whats-this.dev/latest/enums/Constants.ButtonStyles.html
27
27
  customID: "some-string-you-will-see-later",
28
28
  label: "Click!",
29
29
  disabled: false, // If the button is disabled, false by default.
30
- emoji: { // an optional emoji
30
+ emoji: { // An optional emoji
31
31
  id: "1013346070606123009",
32
32
  name: "oceanic"
33
33
  }
@@ -40,25 +40,25 @@ client.on("messageCreate", async(msg) => {
40
40
  disabled: true
41
41
  },
42
42
  {
43
- // https://oceanic.owo-whats-this.dev/interfaces/types_channels.URLButton.html
43
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.URLButton.html
44
44
  type: ComponentTypes.BUTTON,
45
45
  style: ButtonStyles.LINK,
46
46
  label: "Open Link",
47
47
  url: "https://oceanic.owo-whats-this.dev"
48
48
  },
49
49
  {
50
- // https://oceanic.owo-whats-this.dev/interfaces/types_channels.SelectMenu.html
50
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.SelectMenu.html
51
51
  type: ComponentTypes.SELECT_MENU,
52
52
  customID: "select-menu",
53
53
  disabled: false,
54
- maxValues: 1, // the maximum number of values that can be selected (default 1)
55
- minValues: 1, // the minimum number of values that can be selected (default 1)
54
+ maxValues: 1, // The maximum number of values that can be selected (default 1)
55
+ minValues: 1, // The minimum number of values that can be selected (default 1)
56
56
  options: [
57
- // https://oceanic.owo-whats-this.dev/interfaces/types_channels.SelectOption.html
57
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.SelectOption.html
58
58
  {
59
- default: true, // if this option is selected by default
60
- description: "The description of the option", // optional description
61
- emoji: { // an optional emoji
59
+ default: true, // If this option is selected by default
60
+ description: "The description of the option", // Optional description
61
+ emoji: { // An optional emoji
62
62
  id: "1013346070606123009",
63
63
  name: "oceanic"
64
64
  },
@@ -79,10 +79,10 @@ client.on("messageCreate", async(msg) => {
79
79
  }
80
80
  });
81
81
 
82
- // an error handler
82
+ // An error handler
83
83
  client.on("error", (error) => {
84
84
  console.error("Something went wrong:", error);
85
85
  });
86
86
 
87
- // connect to Discord
87
+ // Connect to Discord
88
88
  client.connect();
@@ -1,5 +1,5 @@
1
1
  const { Client } = require("oceanic.js");
2
- const fs = require("fs");
2
+ const { readFileSync } = require("fs");
3
3
 
4
4
  const client = new Client({
5
5
  auth: "Bot [TOKEN]",
@@ -10,26 +10,27 @@ const client = new Client({
10
10
 
11
11
  client.on("ready", () => console.log("Ready as", client.user.tag));
12
12
 
13
- client.on("messageCreate", async(msg) => {
13
+ client.on("messageCreate", async (msg) => {
14
14
  if(msg.content.includes("!embed")) {
15
15
  await client.rest.channels.createMessage(msg.channel.id, {
16
- // https://oceanic.owo-whats-this.dev/interfaces/types_channels.EmbedOptions.html
17
- // up to 10 in one message
16
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.EmbedOptions.html
17
+ // Up to 10 in one message
18
18
  embeds: [
19
19
  {
20
- // https://oceanic.owo-whats-this.dev/interfaces/types_channels.EmbedAuthorOptions.html
20
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.EmbedAuthorOptions.html
21
21
  author: {
22
22
  name: "Author Name",
23
- // an image url, or attachment://filename.ext
24
- icon_url: "https://i.furry.cool/DonPride.png", // optional
25
- url: "https://oceanic.owo-whats-this.dev" // optional
23
+ // An image url, or attachment://filename.ext
24
+ iconURL: "https://i.furry.cool/DonPride.png", // Optional
25
+ url: "https://oceanic.owo-whats-this.dev" // Optional
26
26
  },
27
- // array of https://oceanic.owo-whats-this.dev/interfaces/types_channels.EmbedField.html
27
+ // Array of https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.EmbedField.html
28
+ // Up to 25 in one message
28
29
  fields: [
29
30
  {
30
31
  name: "Field One",
31
32
  value: "Field One Value",
32
- inline: true // if this field should be displayed inline (default: true)
33
+ inline: true // If this field should be displayed inline (default: false)
33
34
  },
34
35
  {
35
36
  name: "Field Two",
@@ -37,26 +38,26 @@ client.on("messageCreate", async(msg) => {
37
38
  inline: false
38
39
  }
39
40
  ],
40
- // https://oceanic.owo-whats-this.dev/interfaces/types_channels.EmbedFooterOptions.html
41
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.EmbedFooterOptions.html
41
42
  footer: {
42
43
  text: "Footer Text",
43
- // an image url, or attachment://filename.ext
44
- icon_url: "https://i.furry.cool/DonPride.png" // optional
44
+ // An image url, or attachment://filename.ext
45
+ iconURL: "https://i.furry.cool/DonPride.png" // Optional
45
46
  },
46
- // https://oceanic.owo-whats-this.dev/interfaces/types_channels.EmbedImageOptions.html
47
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.EmbedImageOptions.html
47
48
  image: {
48
- // an image url, or attachment://filename.ext
49
+ // An image url, or attachment://filename.ext
49
50
  url: "https://i.furry.cool/DonPride.png"
50
51
  },
51
- // https://oceanic.owo-whats-this.dev/interfaces/types_channels.EmbedThumbnailOptions.html
52
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.EmbedThumbnailOptions.html
52
53
  thumbnail: {
53
- // an image url, or attachment://filename.ext
54
+ // An image url, or attachment://filename.ext
54
55
  url: "https://i.furry.cool/DonPride.png"
55
56
  },
56
- // https://oceanic.owo-whats-this.dev/interfaces/types_channels.EmbedOptions.html
57
- color: 0xFFA500, // base-10 color (0x prefix can be used for hex codes)
57
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_channels.EmbedOptions.html
58
+ color: 0xFFA500, // Base-10 color (0x prefix can be used for hex codes)
58
59
  description: "My Cool Embed",
59
- timestamp: new Date().toISOString(), // the current time - ISO 8601 format
60
+ timestamp: new Date().toISOString(), // The current time - ISO 8601 format
60
61
  title: "My Amazing Embed",
61
62
  url: "https://oceanic.owo-whats-this.dev"
62
63
  }
@@ -67,7 +68,7 @@ client.on("messageCreate", async(msg) => {
67
68
  embeds: [
68
69
  {
69
70
  image: {
70
- // this can also be used for author & footer images
71
+ // This can also be used for author & footer images
71
72
  url: "attachment://image.png"
72
73
  }
73
74
  }
@@ -75,17 +76,17 @@ client.on("messageCreate", async(msg) => {
75
76
  files: [
76
77
  {
77
78
  name: "image.png",
78
- contents: fs.readFileSync(`${__dirname}/image.png`)
79
+ contents: readFileSync(`${__dirname}/image.png`)
79
80
  }
80
81
  ]
81
82
  });
82
83
  }
83
84
  });
84
85
 
85
- // an error handler
86
+ // An error handler
86
87
  client.on("error", (error) => {
87
88
  console.error("Something went wrong:", error);
88
89
  });
89
90
 
90
- // connect to Discord
91
+ // Connect to Discord
91
92
  client.connect();
@@ -1,41 +1,40 @@
1
1
  const { Client } = require("oceanic.js");
2
- const fs = require("fs");
3
2
 
4
3
  const client = new Client({
5
4
  auth: "Bot [TOKEN]",
6
5
  gateway: {
7
- // list of intents: https://discord.com/developers/docs/topics/gateway#list-of-intents
8
- // they roughly map on to events we use
9
- // most events also list if they require an intent: https://oceanic.owo-whats-this.dev/dev/interfaces/types_events.ClientEvents.html
6
+ // List of intents: https://discord.com/developers/docs/topics/gateway#list-of-intents
7
+ // They change what events our client receives to lower the amount of computer power needed to run it
8
+ // Most events also list if they require an intent: https://oceanic.owo-whats-this.dev/latest/interfaces/types_events.ClientEvents.html
10
9
  intents: ["GUILDS", "GUILD_MESSAGES", "MESSAGE_CONTENT"]
11
- // if you do not have the MESSAGE_CONTENT intent, various fields like `content`, `components`, `embeds` and more will be empty unless your client is specifically addressed.
10
+ // If you do not have the MESSAGE_CONTENT intent, various fields like `content`, `components`, `embeds` and more will be empty unless the message belongs to or mentions your client
12
11
  }
13
12
  });
14
13
 
15
14
  client.on("ready", () => console.log("Ready as", client.user.tag));
16
15
 
17
- // an error handler
16
+ // An error handler
18
17
  client.on("error", (error) => {
19
18
  console.error("Something went wrong:", error);
20
19
  });
21
20
 
22
21
  // New Guild Joined
23
- // https://oceanic.owo-whats-this.dev/dev/interfaces/types_events.ClientEvents.html#guildCreate
22
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_events.ClientEvents.html#guildCreate
24
23
  bot.on("guildCreate", (guild) => {
25
24
  console.log("Guild Joined:", guild.name);
26
25
  });
27
26
 
28
27
  // Message Sent
29
- // https://oceanic.owo-whats-this.dev/dev/interfaces/types_events.ClientEvents.html#messageCreate
28
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_events.ClientEvents.html#messageCreate
30
29
  bot.on("messageCreate", (msg) => {
31
30
  console.log(`New message: ${msg.content}`);
32
31
  });
33
32
 
34
33
  // This event will never be seen as neither `GUILD_MESSAGE_TYPING` or `DIRECT_MESSAGE_TYPING` were included in the intents
35
- // https://oceanic.owo-whats-this.dev/dev/interfaces/types_events.ClientEvents.html#typingStart
34
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/types_events.ClientEvents.html#typingStart
36
35
  bot.on("typingStart", (channel, user) => { // When a user starts typing
37
- console.log(`${user.username} is typing in ${channel.name}`);
36
+ console.log(`${user.id} is typing in ${channel.id}`); // User or channel are not necessarily complete (Uncached) to retrieve names
38
37
  });
39
38
 
40
- // connect to Discord
39
+ // Connect to Discord
41
40
  client.connect();
@@ -0,0 +1,171 @@
1
+ const { Client, InteractionTypes, MessageFlags, ComponentTypes, ApplicationCommandTypes } = require("oceanic.js");
2
+
3
+ const client = new Client({
4
+ auth: "Bot [TOKEN]",
5
+ gateway: {
6
+ intents: 0 // No intents are needed if you are only using interactions
7
+ }
8
+ });
9
+
10
+
11
+ client.on("ready", async() => {
12
+ console.log("Ready as", client.user.tag);
13
+ });
14
+
15
+ client.on("interactionCreate", async(interaction) => {
16
+ switch(interaction.type) {
17
+ // https://oceanic.owo-whats-this.dev/latest/classes/CommandInteraction.CommandInteraction.html
18
+ case InteractionTypes.APPLICATION_COMMAND: {
19
+ // defer interactions as soon as possible, you have three seconds to send any initial response
20
+ // if you wait too long, the interaction may be invalidated
21
+ await interaction.defer();
22
+ // If you want the response to be ephemeral, you can provide the flag to the defer function, like so:
23
+ // await interaction.defer(MessageFlags.EPHEMERAL);
24
+
25
+ // data = https://oceanic.owo-whats-this.dev/latest/interfaces/Types_Interactions.ApplicationCommandInteractionData.html
26
+ switch(interaction.data.type) {
27
+ // Chat Input commands are what you use in the chat, i.e. slash commands
28
+ case ApplicationCommandTypes.CHAT_INPUT: {
29
+ if(interaction.data.name === "greet") {
30
+ // assume we have two options, user (called user) then string (called greeting) - first is required, second is not
31
+
32
+ // Get an option named `user` with the type USER - https://oceanic.owo-whats-this.dev/dev/classes/InteractionOptionsWrapper.InteractionOptionsWrapper.html#getUser
33
+ // Setting the second parameter to true will throw an error if the option is not present
34
+ const user = interaction.data.options.getUser("user", true);
35
+ const greeting = interaction.data.options.getString("greeting", false) || "Hello, ";
36
+
37
+ // since we've already deferred the interaction, we cannot use createMessage (this is an initial response)
38
+ // we can only have one initial response, so we use createFollowup
39
+ await interaction.createFollowup({
40
+ content: `${greeting} ${user.mention}!`,
41
+ allowedMentions: {
42
+ users: [user.id]
43
+ }
44
+ });
45
+ }
46
+
47
+ // Chat Input application command interactions also have a set of resolved data, which is structured as so:
48
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/Types_Interactions.ApplicationCommandInteractionResolvedData.html
49
+ // the options wrapper pulls values out of resolved automatically, if you use the right method
50
+ break;
51
+ }
52
+
53
+ // User application commands are shown in the context menu when right clicking on users
54
+ // `data` will have a target (and targetID) property with the user that the command was executed on
55
+ // These don't have options
56
+ case ApplicationCommandTypes.USER: {
57
+ if(interaction.data.name === "ping") {
58
+ await interaction.createFollowup({
59
+ content: `Pong! ${interaction.data.target.mention}`,
60
+ allowedMentions: {
61
+ users: [interaction.data.target.id]
62
+ }
63
+ });
64
+ }
65
+ break;
66
+ }
67
+
68
+ // Message application commands are shown in the context menu when right clicking on essages
69
+ // `data` will have a target (and targetID) property with the message that the command was executed on
70
+ // Same as user commands, these don't have options
71
+ case ApplicationCommandTypes.MESSAGE: {
72
+ if(interaction.data.name === "author") {
73
+ await interaction.createFollowup({
74
+ content: `${interaction.data.target.author.mention} is the author of that message!`,
75
+ allowedMentions: {
76
+ users: [interaction.data.target.author.id]
77
+ }
78
+ });
79
+ }
80
+ break;
81
+ }
82
+ }
83
+ break;
84
+ }
85
+
86
+ // https://oceanic.owo-whats-this.dev/latest/classes/ComponentInteraction.ComponentInteraction.html
87
+ case InteractionTypes.MESSAGE_COMPONENT: {
88
+ // same spiel as above
89
+ await interaction.defer();
90
+ // when you create a message with components, this will correspond with what you provided as the customID there
91
+ if(interaction.data.componentType === ComponentTypes.BUTTON) {
92
+ if(interaction.data.customID === "edit-message") {
93
+ // Edits the original message. This has an initial response variant: editParent
94
+ await interaction.editOriginal({
95
+ content: `This message was edited by ${interaction.user.mention}!`,
96
+ allowedMentions: {
97
+ users: [interaction.user.id]
98
+ }
99
+ });
100
+ } else if(interaction.data.customID === "my-amazing-button") {
101
+ await interaction.createFollowup({
102
+ content: "You clicked an amazing button!"
103
+ });
104
+ }
105
+ } else if(interaction.data.componentType === ComponentTypes.SELECT_MENU) {
106
+ // The `values` property under data contains all of the selected values
107
+ await interaction.createFollowup({
108
+ content: `You selected: **${interaction.data.values.join("**, **")}**`
109
+ });
110
+ }
111
+ break;
112
+ }
113
+
114
+ // https://oceanic.owo-whats-this.dev/latest/classes/AutocompleteInteraction.AutocompleteInteraction.html
115
+ case InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE: {
116
+ // Autocomplete Interactions cannot be deferred
117
+ switch(interaction.data.name) {
118
+ case "test-autocomplete": {
119
+ // Autocomplete interactions data has a partial `options` property, which is the tree of options that are currently being filled in
120
+ // along with one at the end, which will have focused
121
+ // Setting the first parameter to true will throw an error if no focused option is present
122
+ const option = interaction.data.options.getFocused(true);
123
+ switch(option.name) {
124
+ case "test-option": {
125
+ return interaction.result([
126
+ {
127
+ name: "Choice 1",
128
+ nameLocalizations: {
129
+ "es-ES": "Opción 1"
130
+ },
131
+ value: "choice-1"
132
+ },
133
+ {
134
+ name: "Choice 2",
135
+ nameLocalizations: {
136
+ "es-ES": "Opción 2"
137
+ },
138
+ value: "choice-2"
139
+ }
140
+ ]);
141
+ break;
142
+ }
143
+ }
144
+ }
145
+ }
146
+ break;
147
+ }
148
+
149
+ // https://oceanic.owo-whats-this.dev/latest/classes/ModalSubmitInteraction.ModalSubmitInteraction.html
150
+ case InteractionTypes.MODAL_SUBMIT: {
151
+ // this will correspond with the customID you provided when creating the modal
152
+ switch(interaction.data.customID) {
153
+ case "test-modal": {
154
+ // the `components` property under data contains all of the components that were submitted
155
+ // https://oceanic.owo-whats-this.dev/latest/interfaces/Types_Channels.ModalActionRow.html
156
+ console.log(interaction.data.components);
157
+ break;
158
+ }
159
+ }
160
+ break;
161
+ }
162
+ }
163
+ });
164
+
165
+ // An error handler
166
+ client.on("error", (error) => {
167
+ console.error("Something went wrong:", error);
168
+ });
169
+
170
+ // Connect to Discord
171
+ client.connect();
@@ -0,0 +1,47 @@
1
+ const { Client } = require("oceanic.js");
2
+ const { VoiceConnectionStatus, AudioPlayerStatus, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
3
+
4
+ const client = new Client({
5
+ auth: "Bot [TOKEN]",
6
+ gateway: {
7
+ intents: ["GUILDS", "GUILD_VOICE_STATES"] // Voice connections require the GUILDS intent; We specify the GUILD_VOICE_STATES intent to reconnect to the voice channel in case we get disconnected
8
+ }
9
+ });
10
+
11
+ client.on("ready", () => {
12
+ console.log("Ready as", client.user.tag);
13
+
14
+ const guild = client.guilds.get("1005489770278953112"); // We need the guild to get the voiceAdapterCreator
15
+
16
+ const voiceConnection = client.joinVoiceChannel({
17
+ channelID: "1005489770849382443", // The ID of the channel to connect to
18
+ guildID: "1005489770278953112", // The ID of the guild the channel belongs to
19
+ selfDeaf: true, // Whether our client joins defeaned
20
+ selfMute: false, // Whether our client joins muted
21
+ voiceAdapterCreator: guild.voiceAdapterCreator // The voiceAdapterCreator the guild provides
22
+ })
23
+ voiceConnection.on(VoiceConnectionStatus.Disconnected, () => {
24
+ voiceConnection.rejoin(); // In case we get disconnected, rejoin
25
+ });
26
+
27
+ const player = createAudioPlayer(); // Create the player we will use to play audio
28
+ voiceConnection.subscribe(player); // Subscribe the player to the voice connection to the channel we have
29
+
30
+ player.on(AudioPlayerStatus.Playing, () => {
31
+ console.log("Audio started playing");
32
+ });
33
+ player.on(AudioPlayerStatus.Idle, () => {
34
+ console.log("The player is not playing any audio");
35
+ })
36
+
37
+ const audio = createAudioResource(`${__dirname}/audio.mp3`); // Create the audio resource from the mp3 we have to play through the player
38
+ player.play(audio); // Play the audio
39
+ });
40
+
41
+ // An error handler
42
+ client.on("error", (error) => {
43
+ console.error("Something went wrong:", error);
44
+ });
45
+
46
+ // Connect to Discord
47
+ client.connect();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oceanic.js",
3
- "version": "1.0.0-dev.3cfdac7",
3
+ "version": "1.0.0-dev.3d69a0f",
4
4
  "description": "A NodeJS library for interfacing with Discord.",
5
5
  "main": "./dist/lib/index.js",
6
6
  "types": "./dist/lib/index.d.ts",
@@ -15,7 +15,8 @@
15
15
  "scripts": {
16
16
  "lint": "eslint lib --ext .ts",
17
17
  "lint:fix": "eslint lib --ext .ts --fix",
18
- "prepublishOnly": "node build"
18
+ "prepublishOnly": "node scripts/build",
19
+ "test:docs": "npm i --no-save --ignore-scripts typedoc typedoc-plugin-extras typedoc-plugin-rename-defaults && node scripts/doc-test.js && npx --yes typedoc"
19
20
  },
20
21
  "repository": {
21
22
  "type": "git",
@@ -58,5 +59,8 @@
58
59
  },
59
60
  "engines": {
60
61
  "node": ">=16.16.0"
62
+ },
63
+ "optionalDependencies": {
64
+ "@discordjs/voice": "^0.11.0"
61
65
  }
62
66
  }
package/build.js DELETED
@@ -1,6 +0,0 @@
1
- const { execSync } = require("child_process");
2
- const { rmSync, readFileSync, writeFileSync, existsSync, cpSync } = require("fs");
3
- if(existsSync(`${__dirname}/dist`)) rmSync(`${__dirname}/dist`, { recursive: true });
4
- execSync("tsc", { stdio: "inherit" });
5
- writeFileSync(`${__dirname}/dist/lib/index.js`, readFileSync(`${__dirname}/dist/lib/index.js`).toString().replace(/__exportStar\(require\("\.\/types\/index"\), exports\);\r?\n/, ""))
6
- cpSync(`${__dirname}/lib/types`, `${__dirname}/dist/lib/types`, { recursive: true });
@@ -1,12 +0,0 @@
1
- import type { StageInstancePrivacyLevels } from "../Constants";
2
-
3
- export interface RawStageInstance {
4
- channel_id: string;
5
- /** @deprecated */
6
- discoverable_disabled: boolean;
7
- guild_id: string;
8
- guild_scheduled_event_id?: string;
9
- id: string;
10
- privacy_level: StageInstancePrivacyLevels;
11
- topic: string;
12
- }
@@ -1,9 +0,0 @@
1
- export default class Properties<C = unknown> {
2
- #private;
3
- constructor(obj: unknown);
4
- static define<T, K extends keyof T>(obj: T, property: K, value: T[K], writable?: boolean, configurable?: boolean, enumerable?: boolean): Properties<T>;
5
- static looseDefine<T>(obj: T, property: string, value: unknown, writable?: boolean, configurable?: boolean, enumerable?: boolean): Properties<T>;
6
- static new<T>(obj: T): Properties<T>;
7
- define<K extends keyof C>(property: K, value: C[K], writable?: boolean, configurable?: boolean, enumerable?: boolean): this;
8
- looseDefine(property: string, value: unknown, writable?: boolean, configurable?: boolean, enumerable?: boolean): this;
9
- }