oceanic.js 1.0.2 → 1.0.3-dev.0457ffd
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/README.md +3 -3
- package/dist/lib/Constants.d.ts +16 -5
- package/dist/lib/Constants.js +25 -10
- package/dist/lib/gateway/Shard.d.ts +1 -1
- package/dist/lib/gateway/Shard.js +10 -9
- package/dist/lib/routes/ApplicationCommands.js +2 -1
- package/dist/lib/routes/Channels.js +74 -58
- package/dist/lib/routes/Guilds.d.ts +3 -3
- package/dist/lib/routes/Guilds.js +36 -15
- package/dist/lib/routes/OAuth.js +2 -1
- package/dist/lib/routes/Webhooks.js +4 -4
- package/dist/lib/structures/ApplicationCommand.d.ts +1 -1
- package/dist/lib/structures/ApplicationCommand.js +2 -2
- package/dist/lib/structures/AuditLogEntry.js +3 -1
- package/dist/lib/structures/CommandInteraction.js +1 -1
- package/dist/lib/structures/ForumChannel.d.ts +3 -0
- package/dist/lib/structures/ForumChannel.js +6 -1
- package/dist/lib/structures/GroupChannel.d.ts +2 -2
- package/dist/lib/structures/GroupChannel.js +2 -2
- package/dist/lib/structures/Guild.d.ts +18 -4
- package/dist/lib/structures/Guild.js +29 -5
- package/dist/lib/structures/GuildPreview.d.ts +19 -1
- package/dist/lib/structures/GuildPreview.js +49 -1
- package/dist/lib/structures/Integration.d.ts +2 -0
- package/dist/lib/structures/Integration.js +7 -1
- package/dist/lib/structures/Member.d.ts +5 -3
- package/dist/lib/structures/Member.js +2 -2
- package/dist/lib/structures/Message.d.ts +2 -4
- package/dist/lib/structures/Message.js +1 -1
- package/dist/lib/structures/PrivateChannel.d.ts +2 -2
- package/dist/lib/structures/PrivateChannel.js +2 -2
- package/dist/lib/structures/TextableChannel.d.ts +2 -2
- package/dist/lib/structures/TextableChannel.js +2 -2
- package/dist/lib/structures/ThreadChannel.d.ts +2 -2
- package/dist/lib/structures/ThreadChannel.js +2 -2
- package/dist/lib/structures/VoiceChannel.d.ts +2 -2
- package/dist/lib/structures/VoiceChannel.js +2 -2
- package/dist/lib/types/application-commands.d.ts +2 -0
- package/dist/lib/types/audit-log.d.ts +10 -0
- package/dist/lib/types/channels.d.ts +19 -12
- package/dist/lib/types/gateway-raw.d.ts +1 -1
- package/dist/lib/types/guilds.d.ts +34 -22
- package/dist/lib/types/interactions.d.ts +2 -0
- package/dist/lib/types/json.d.ts +2 -0
- package/dist/lib/types/oauth.d.ts +2 -0
- package/dist/lib/util/InteractionOptionsWrapper.d.ts +3 -3
- package/dist/lib/util/InteractionOptionsWrapper.js +1 -1
- package/dist/lib/util/Util.d.ts +2 -2
- package/dist/lib/util/Util.js +1 -1
- package/dist/package.json +1 -1
- package/examples/applicationCommand.js +9 -9
- package/examples/components.js +8 -8
- package/examples/embeds.js +9 -9
- package/examples/intents.js +4 -4
- package/examples/interactions.js +8 -8
- package/package.json +1 -1
package/examples/embeds.js
CHANGED
|
@@ -13,18 +13,18 @@ client.on("ready", () => console.log("Ready as", client.user.tag));
|
|
|
13
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.
|
|
16
|
+
// https://docs.oceanic.ws/latest/interfaces/Types_Channels.EmbedOptions.html
|
|
17
17
|
// Up to 10 in one message
|
|
18
18
|
embeds: [
|
|
19
19
|
{
|
|
20
|
-
// https://oceanic.
|
|
20
|
+
// https://docs.oceanic.ws/latest/interfaces/Types_Channels.EmbedAuthorOptions.html
|
|
21
21
|
author: {
|
|
22
22
|
name: "Author Name",
|
|
23
23
|
// An image url, or attachment://filename.ext
|
|
24
24
|
iconURL: "https://i.furry.cool/DonPride.png", // Optional
|
|
25
|
-
url: "https://oceanic.
|
|
25
|
+
url: "https://docs.oceanic.ws" // Optional
|
|
26
26
|
},
|
|
27
|
-
// Array of https://oceanic.
|
|
27
|
+
// Array of https://docs.oceanic.ws/latest/interfaces/Types_Channels.EmbedField.html
|
|
28
28
|
// Up to 25 in one message
|
|
29
29
|
fields: [
|
|
30
30
|
{
|
|
@@ -38,28 +38,28 @@ client.on("messageCreate", async (msg) => {
|
|
|
38
38
|
inline: false
|
|
39
39
|
}
|
|
40
40
|
],
|
|
41
|
-
// https://oceanic.
|
|
41
|
+
// https://docs.oceanic.ws/latest/interfaces/Types_Channels.EmbedFooterOptions.html
|
|
42
42
|
footer: {
|
|
43
43
|
text: "Footer Text",
|
|
44
44
|
// An image url, or attachment://filename.ext
|
|
45
45
|
iconURL: "https://i.furry.cool/DonPride.png" // Optional
|
|
46
46
|
},
|
|
47
|
-
// https://oceanic.
|
|
47
|
+
// https://docs.oceanic.ws/latest/interfaces/Types_Channels.EmbedImageOptions.html
|
|
48
48
|
image: {
|
|
49
49
|
// An image url, or attachment://filename.ext
|
|
50
50
|
url: "https://i.furry.cool/DonPride.png"
|
|
51
51
|
},
|
|
52
|
-
// https://oceanic.
|
|
52
|
+
// https://docs.oceanic.ws/latest/interfaces/Types_Channels.EmbedThumbnailOptions.html
|
|
53
53
|
thumbnail: {
|
|
54
54
|
// An image url, or attachment://filename.ext
|
|
55
55
|
url: "https://i.furry.cool/DonPride.png"
|
|
56
56
|
},
|
|
57
|
-
// https://oceanic.
|
|
57
|
+
// https://docs.oceanic.ws/latest/interfaces/Types_Channels.EmbedOptions.html
|
|
58
58
|
color: 0xFFA500, // Base-10 color (0x prefix can be used for hex codes)
|
|
59
59
|
description: "My Cool Embed",
|
|
60
60
|
timestamp: new Date().toISOString(), // The current time - ISO 8601 format
|
|
61
61
|
title: "My Amazing Embed",
|
|
62
|
-
url: "https://oceanic.
|
|
62
|
+
url: "https://docs.oceanic.ws"
|
|
63
63
|
}
|
|
64
64
|
]
|
|
65
65
|
});
|
package/examples/intents.js
CHANGED
|
@@ -5,7 +5,7 @@ const client = new Client({
|
|
|
5
5
|
gateway: {
|
|
6
6
|
// List of intents: https://discord.com/developers/docs/topics/gateway#list-of-intents
|
|
7
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.
|
|
8
|
+
// Most events also list if they require an intent: https://docs.oceanic.ws/latest/interfaces/Events.ClientEvents.html
|
|
9
9
|
intents: ["GUILDS", "GUILD_MESSAGES", "MESSAGE_CONTENT"]
|
|
10
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
|
|
11
11
|
}
|
|
@@ -19,19 +19,19 @@ client.on("error", (error) => {
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
// New Guild Joined
|
|
22
|
-
// https://oceanic.
|
|
22
|
+
// https://docs.oceanic.ws/latest/interfaces/Events.ClientEvents.html#guildCreate
|
|
23
23
|
bot.on("guildCreate", (guild) => {
|
|
24
24
|
console.log("Guild Joined:", guild.name);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
// Message Sent
|
|
28
|
-
// https://oceanic.
|
|
28
|
+
// https://docs.oceanic.ws/latest/interfaces/Events.ClientEvents.html#messageCreate
|
|
29
29
|
bot.on("messageCreate", (msg) => {
|
|
30
30
|
console.log(`New message: ${msg.content}`);
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
// This event will never be seen as neither `GUILD_MESSAGE_TYPING` or `DIRECT_MESSAGE_TYPING` were included in the intents
|
|
34
|
-
// https://oceanic.
|
|
34
|
+
// https://docs.oceanic.ws/latest/interfaces/Events.ClientEvents.html#typingStart
|
|
35
35
|
bot.on("typingStart", (channel, user) => { // When a user starts typing
|
|
36
36
|
console.log(`${user.id} is typing in ${channel.id}`); // User or channel are not necessarily complete (Uncached) to retrieve names
|
|
37
37
|
});
|
package/examples/interactions.js
CHANGED
|
@@ -14,7 +14,7 @@ client.on("ready", async() => {
|
|
|
14
14
|
|
|
15
15
|
client.on("interactionCreate", async(interaction) => {
|
|
16
16
|
switch(interaction.type) {
|
|
17
|
-
// https://oceanic.
|
|
17
|
+
// https://docs.oceanic.ws/latest/classes/CommandInteraction.CommandInteraction.html
|
|
18
18
|
case InteractionTypes.APPLICATION_COMMAND: {
|
|
19
19
|
// defer interactions as soon as possible, you have three seconds to send any initial response
|
|
20
20
|
// if you wait too long, the interaction may be invalidated
|
|
@@ -22,14 +22,14 @@ client.on("interactionCreate", async(interaction) => {
|
|
|
22
22
|
// If you want the response to be ephemeral, you can provide the flag to the defer function, like so:
|
|
23
23
|
// await interaction.defer(MessageFlags.EPHEMERAL);
|
|
24
24
|
|
|
25
|
-
// data = https://oceanic.
|
|
25
|
+
// data = https://docs.oceanic.ws/latest/interfaces/Types_Interactions.ApplicationCommandInteractionData.html
|
|
26
26
|
switch(interaction.data.type) {
|
|
27
27
|
// Chat Input commands are what you use in the chat, i.e. slash commands
|
|
28
28
|
case ApplicationCommandTypes.CHAT_INPUT: {
|
|
29
29
|
if(interaction.data.name === "greet") {
|
|
30
30
|
// assume we have two options, user (called user) then string (called greeting) - first is required, second is not
|
|
31
31
|
|
|
32
|
-
// Get an option named `user` with the type USER - https://oceanic.
|
|
32
|
+
// Get an option named `user` with the type USER - https://docs.oceanic.ws/dev/classes/InteractionOptionsWrapper.InteractionOptionsWrapper.html#getUser
|
|
33
33
|
// Setting the second parameter to true will throw an error if the option is not present
|
|
34
34
|
const user = interaction.data.options.getUser("user", true);
|
|
35
35
|
const greeting = interaction.data.options.getString("greeting", false) || "Hello, ";
|
|
@@ -45,7 +45,7 @@ client.on("interactionCreate", async(interaction) => {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// Chat Input application command interactions also have a set of resolved data, which is structured as so:
|
|
48
|
-
// https://oceanic.
|
|
48
|
+
// https://docs.oceanic.ws/latest/interfaces/Types_Interactions.ApplicationCommandInteractionResolvedData.html
|
|
49
49
|
// the options wrapper pulls values out of resolved automatically, if you use the right method
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
@@ -83,7 +83,7 @@ client.on("interactionCreate", async(interaction) => {
|
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
// https://oceanic.
|
|
86
|
+
// https://docs.oceanic.ws/latest/classes/ComponentInteraction.ComponentInteraction.html
|
|
87
87
|
case InteractionTypes.MESSAGE_COMPONENT: {
|
|
88
88
|
// same spiel as above
|
|
89
89
|
await interaction.defer();
|
|
@@ -111,7 +111,7 @@ client.on("interactionCreate", async(interaction) => {
|
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
// https://oceanic.
|
|
114
|
+
// https://docs.oceanic.ws/latest/classes/AutocompleteInteraction.AutocompleteInteraction.html
|
|
115
115
|
case InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE: {
|
|
116
116
|
// Autocomplete Interactions cannot be deferred
|
|
117
117
|
switch(interaction.data.name) {
|
|
@@ -146,13 +146,13 @@ client.on("interactionCreate", async(interaction) => {
|
|
|
146
146
|
break;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
// https://oceanic.
|
|
149
|
+
// https://docs.oceanic.ws/latest/classes/ModalSubmitInteraction.ModalSubmitInteraction.html
|
|
150
150
|
case InteractionTypes.MODAL_SUBMIT: {
|
|
151
151
|
// this will correspond with the customID you provided when creating the modal
|
|
152
152
|
switch(interaction.data.customID) {
|
|
153
153
|
case "test-modal": {
|
|
154
154
|
// the `components` property under data contains all of the components that were submitted
|
|
155
|
-
// https://oceanic.
|
|
155
|
+
// https://docs.oceanic.ws/latest/interfaces/Types_Channels.ModalActionRow.html
|
|
156
156
|
console.log(interaction.data.components);
|
|
157
157
|
break;
|
|
158
158
|
}
|