diff --git a/README.md b/README.md
index 7db4118..3466d46 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,6 @@
[](https://www.npmjs.com/package/@oasisjs/biscuit)
[](https://deno.land/x/biscuit)
-
### Install (for [node18](https://nodejs.org/en/download/))
diff --git a/examples/components/mod.ts b/examples/components/mod.ts
index 14431c0..739bb27 100644
--- a/examples/components/mod.ts
+++ b/examples/components/mod.ts
@@ -1,56 +1,56 @@
-import 'https://deno.land/std@0.146.0/dotenv/load.ts';
-import {
- ActionRowBuilder,
- ButtonBuilder,
- ButtonStyles,
- GatewayIntents,
- InteractionResponseTypes,
- Session,
-} from 'https://x.nest.land/biscuit/mod.ts';
-
-const token = Deno.env.get("TOKEN") ?? Deno.args[0];
-
-if (!token) {
- throw new Error('Please provide a token');
-}
-
-const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
-const session = new Session({ token, intents });
-
-const PREFIX = ">";
-const components = new ButtonBuilder().setCustomId('ping').setLabel('Hello!').setStyle(ButtonStyles.Success);
-const row = new ActionRowBuilder().addComponents(components).toJSON();
-
-session.on('ready', (payload) => {
- console.log('Logged in as:', payload.user.username);
-});
-
-session.on("messageCreate", (message) => {
- if (message.author?.bot || !message.content.startsWith(PREFIX)) {
- return;
- }
-
- const args = message.content.substring(PREFIX.length).trim().split(/\s+/gm);
- const name = args.shift()?.toLowerCase();
- console.log(args, name);
-
- if (name === 'ping') {
- message.reply({ components: [row] });
- }
-});
-
-// Follow interaction event
-session.on('interactionCreate', (interaction) => {
- if (!interaction.isComponent()) {
- return;
- }
-
- if (interaction.customId === "ping") {
- interaction.respond({
- type: InteractionResponseTypes.ChannelMessageWithSource,
- data: { content: "pong!" },
- });
- }
-});
-
-session.start();
+import "https://deno.land/std@0.146.0/dotenv/load.ts";
+import {
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyles,
+ GatewayIntents,
+ InteractionResponseTypes,
+ Session,
+} from "https://x.nest.land/biscuit/mod.ts";
+
+const token = Deno.env.get("TOKEN") ?? Deno.args[0];
+
+if (!token) {
+ throw new Error("Please provide a token");
+}
+
+const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
+const session = new Session({ token, intents });
+
+const PREFIX = ">";
+const components = new ButtonBuilder().setCustomId("ping").setLabel("Hello!").setStyle(ButtonStyles.Success);
+const row = new ActionRowBuilder().addComponents(components).toJSON();
+
+session.on("ready", (payload) => {
+ console.log("Logged in as:", payload.user.username);
+});
+
+session.on("messageCreate", (message) => {
+ if (message.author?.bot || !message.content.startsWith(PREFIX)) {
+ return;
+ }
+
+ const args = message.content.substring(PREFIX.length).trim().split(/\s+/gm);
+ const name = args.shift()?.toLowerCase();
+ console.log(args, name);
+
+ if (name === "ping") {
+ message.reply({ components: [row] });
+ }
+});
+
+// Follow interaction event
+session.on("interactionCreate", (interaction) => {
+ if (!interaction.isComponent()) {
+ return;
+ }
+
+ if (interaction.customId === "ping") {
+ interaction.respond({
+ type: InteractionResponseTypes.ChannelMessageWithSource,
+ data: { content: "pong!" },
+ });
+ }
+});
+
+session.start();
diff --git a/examples/hello-bun/index.js b/examples/hello-bun/index.js
index bdfd117..eba3d84 100644
--- a/examples/hello-bun/index.js
+++ b/examples/hello-bun/index.js
@@ -1,33 +1,32 @@
-/**
- * Bun example
- * this example should work on most systems, but if it doesn't just clone the library and import everything from mod.ts
-*/
-
-const { GatewayIntents, Session } = require("@oasisjs/biscuit");
-
-// if it didn't worked use:
-// const { GatewayIntents, Session } = require("@oasisjs/biscuit");
-
-const token = process.env.TOKEN;
-const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
-const session = new Session({ token, intents });
-
-session.on("ready", (payload) => {
- console.log("Logged in as:", payload.user.username);
-});
-
-session.on("messageCreate", async (message) => {
- // GET
- if (message.content.startsWith("whatever")) {
- const whatever = await message.fetch();
- console.log(whatever);
- }
-
- // POST
- if (message.content.startsWith("ping")) {
- message.reply({ content: "pong!" }).catch((err) => console.error(err));
- }
-});
-
-await session.start();
-
+/**
+ * Bun example
+ * this example should work on most systems, but if it doesn't just clone the library and import everything from mod.ts
+ */
+
+const { GatewayIntents, Session } = require("@oasisjs/biscuit");
+
+// if it didn't worked use:
+// const { GatewayIntents, Session } = require("@oasisjs/biscuit");
+
+const token = process.env.TOKEN;
+const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
+const session = new Session({ token, intents });
+
+session.on("ready", (payload) => {
+ console.log("Logged in as:", payload.user.username);
+});
+
+session.on("messageCreate", async (message) => {
+ // GET
+ if (message.content.startsWith("whatever")) {
+ const whatever = await message.fetch();
+ console.log(whatever);
+ }
+
+ // POST
+ if (message.content.startsWith("ping")) {
+ message.reply({ content: "pong!" }).catch((err) => console.error(err));
+ }
+});
+
+await session.start();
diff --git a/examples/hello-deno/mod.ts b/examples/hello-deno/mod.ts
index e05f293..38b628e 100644
--- a/examples/hello-deno/mod.ts
+++ b/examples/hello-deno/mod.ts
@@ -1,39 +1,38 @@
-/**
- * Deno example
- */
-
-import "https://deno.land/std@0.146.0/dotenv/load.ts";
-
-// Session to create a new bot (and intents)
-import { GatewayIntents, Session } from "https://x.nest.land/biscuit/mod.ts";
-
-const token = Deno.env.get("TOKEN") ?? Deno.args[0];
-
-if (!token) {
- throw new Error("Please provide a token");
-}
-
-const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
-const session = new Session({ token, intents });
-
-session.on("ready", (payload) => {
- console.log("Logged in as:", payload.user.username);
-});
-
-const PREFIX = ">";
-
-session.on("messageCreate", (message) => {
- if (message.author?.bot || !message.content.startsWith(PREFIX)) {
- return;
- }
-
- const args = message.content.substring(PREFIX.length).trim().split(/\s+/gm);
- const name = args.shift()?.toLowerCase();
-
- if (name === "ping") {
- message.reply({ content: "pong!" });
- }
-});
-
-session.start();
-
+/**
+ * Deno example
+ */
+
+import "https://deno.land/std@0.146.0/dotenv/load.ts";
+
+// Session to create a new bot (and intents)
+import { GatewayIntents, Session } from "https://x.nest.land/biscuit/mod.ts";
+
+const token = Deno.env.get("TOKEN") ?? Deno.args[0];
+
+if (!token) {
+ throw new Error("Please provide a token");
+}
+
+const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
+const session = new Session({ token, intents });
+
+session.on("ready", (payload) => {
+ console.log("Logged in as:", payload.user.username);
+});
+
+const PREFIX = ">";
+
+session.on("messageCreate", (message) => {
+ if (message.author?.bot || !message.content.startsWith(PREFIX)) {
+ return;
+ }
+
+ const args = message.content.substring(PREFIX.length).trim().split(/\s+/gm);
+ const name = args.shift()?.toLowerCase();
+
+ if (name === "ping") {
+ message.reply({ content: "pong!" });
+ }
+});
+
+session.start();
diff --git a/examples/hello-node-mjs/index.mjs b/examples/hello-node-mjs/index.mjs
index f6a04c7..6cce5af 100644
--- a/examples/hello-node-mjs/index.mjs
+++ b/examples/hello-node-mjs/index.mjs
@@ -1,44 +1,44 @@
-/**
- * Biscuit node example
-*/
-
-// process for get the token
-/** @type {NodeJS.Process} process */
-import process from 'node:process';
-
-// Session for create a new bot and intents
-import { Session, GatewayIntents } from '@oasisjs/biscuit';
-
-// Discord bot token
-/** @type {string} token */
-const token = process.env.TOKEN || "YOUR_TOKEN_HERE";
-
-if (token === "") {
- console.log(new Error("Please set the TOKEN environment variable"));
-}
-
-const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
-const session = new Session({ token, intents });
-
-// Command prefix
-const PREFIX = ">";
-
-session.on("ready", (data) => {
- console.log("Ready! Let's start chatting!");
- console.log("Connected as: " + data.user.username);
-})
-
-session.on("messageCreate", (message) => {
- if (message.author?.bot || !message.content.startsWith(PREFIX)) {
- return;
- }
-
- const args = message.content.substring(PREFIX.length).trim().split(/\s+/gm);
- const name = args.shift()?.toLowerCase();
-
- if (name === "ping") {
- message.reply({ content: "pong!" });
- }
-});
-
-session.start();
\ No newline at end of file
+/**
+ * Biscuit node example
+ */
+
+// process for get the token
+/** @type {NodeJS.Process} process */
+import process from "node:process";
+
+// Session for create a new bot and intents
+import { GatewayIntents, Session } from "@oasisjs/biscuit";
+
+// Discord bot token
+/** @type {string} token */
+const token = process.env.TOKEN || "YOUR_TOKEN_HERE";
+
+if (token === "") {
+ console.log(new Error("Please set the TOKEN environment variable"));
+}
+
+const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
+const session = new Session({ token, intents });
+
+// Command prefix
+const PREFIX = ">";
+
+session.on("ready", (data) => {
+ console.log("Ready! Let's start chatting!");
+ console.log("Connected as: " + data.user.username);
+});
+
+session.on("messageCreate", (message) => {
+ if (message.author?.bot || !message.content.startsWith(PREFIX)) {
+ return;
+ }
+
+ const args = message.content.substring(PREFIX.length).trim().split(/\s+/gm);
+ const name = args.shift()?.toLowerCase();
+
+ if (name === "ping") {
+ message.reply({ content: "pong!" });
+ }
+});
+
+session.start();
diff --git a/examples/hello-node/index.js b/examples/hello-node/index.js
index b71827a..d5ac79f 100644
--- a/examples/hello-node/index.js
+++ b/examples/hello-node/index.js
@@ -1,44 +1,44 @@
-/**
- * Biscuit node example
-*/
-
-// process for get the token
-/** @type {NodeJS.Process} process */
-const process = require("node:process");
-
-// Session for create a new bot and intents
-const { Session, GatewayIntents } = require("@oasisjs/biscuit");
-
-// Discord bot token
-/** @type {string} token */
-const token = process.env.TOKEN || "YOUR_TOKEN_HERE";
-
-if (token === "") {
- return new Error("Please set the TOKEN environment variable");
-}
-
-const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
-const session = new Session({ token, intents });
-
-// Command prefix
-const PREFIX = ">";
-
-session.on("ready", (data) => {
- console.log("Ready! Let's start chatting!");
- console.log("Connected as: " + data.user.username);
-})
-
-session.on("messageCreate", (message) => {
- if (message.author?.bot || !message.content.startsWith(PREFIX)) {
- return;
- }
-
- const args = message.content.substring(PREFIX.length).trim().split(/\s+/gm);
- const name = args.shift()?.toLowerCase();
-
- if (name === "ping") {
- message.reply({ content: "pong!" });
- }
-});
-
-session.start();
\ No newline at end of file
+/**
+ * Biscuit node example
+ */
+
+// process for get the token
+/** @type {NodeJS.Process} process */
+const process = require("node:process");
+
+// Session for create a new bot and intents
+const { Session, GatewayIntents } = require("@oasisjs/biscuit");
+
+// Discord bot token
+/** @type {string} token */
+const token = process.env.TOKEN || "YOUR_TOKEN_HERE";
+
+if (token === "") {
+ return new Error("Please set the TOKEN environment variable");
+}
+
+const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
+const session = new Session({ token, intents });
+
+// Command prefix
+const PREFIX = ">";
+
+session.on("ready", (data) => {
+ console.log("Ready! Let's start chatting!");
+ console.log("Connected as: " + data.user.username);
+});
+
+session.on("messageCreate", (message) => {
+ if (message.author?.bot || !message.content.startsWith(PREFIX)) {
+ return;
+ }
+
+ const args = message.content.substring(PREFIX.length).trim().split(/\s+/gm);
+ const name = args.shift()?.toLowerCase();
+
+ if (name === "ping") {
+ message.reply({ content: "pong!" });
+ }
+});
+
+session.start();
diff --git a/examples/slash-commands/mod.ts b/examples/slash-commands/mod.ts
index 294d7db..c5b08c5 100644
--- a/examples/slash-commands/mod.ts
+++ b/examples/slash-commands/mod.ts
@@ -1,43 +1,48 @@
-import "https://deno.land/std@0.146.0/dotenv/load.ts";
-import { CreateApplicationCommand, GatewayIntents, InteractionResponseTypes, Session } from "https://x.nest.land/biscuit/mod.ts";
-
-const token = Deno.env.get("TOKEN") ?? Deno.args[0];
-
-if (!token) {
- throw new Error("Please provide a token");
-}
-
-const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
-const session = new Session({ token, intents });
-
-const command: CreateApplicationCommand = {
- name: "ping",
- description: "Replies with pong!",
-};
-
-const guildId = "";
-
-session.on("ready", async (payload) => {
- console.log("Logged in as:", payload.user.username);
- console.log("Creating the application commands...");
- // create command
- try {
- await session.createApplicationCommand(command, guildId);
- console.log("Done!");
- } catch (err) {
- console.error(err);
- }
-});
-
-// Follow interaction event
-session.on("interactionCreate", (interaction) => {
- if (!interaction.isCommand()) return;
- if (interaction.commandName === "ping") {
- interaction.respond({
- type: InteractionResponseTypes.ChannelMessageWithSource,
- data: { content: "pong!" },
- });
- }
-});
-
-await session.start();
+import "https://deno.land/std@0.146.0/dotenv/load.ts";
+import {
+ CreateApplicationCommand,
+ GatewayIntents,
+ InteractionResponseTypes,
+ Session,
+} from "https://x.nest.land/biscuit/mod.ts";
+
+const token = Deno.env.get("TOKEN") ?? Deno.args[0];
+
+if (!token) {
+ throw new Error("Please provide a token");
+}
+
+const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
+const session = new Session({ token, intents });
+
+const command: CreateApplicationCommand = {
+ name: "ping",
+ description: "Replies with pong!",
+};
+
+const guildId = "";
+
+session.on("ready", async (payload) => {
+ console.log("Logged in as:", payload.user.username);
+ console.log("Creating the application commands...");
+ // create command
+ try {
+ await session.createApplicationCommand(command, guildId);
+ console.log("Done!");
+ } catch (err) {
+ console.error(err);
+ }
+});
+
+// Follow interaction event
+session.on("interactionCreate", (interaction) => {
+ if (!interaction.isCommand()) return;
+ if (interaction.commandName === "ping") {
+ interaction.respond({
+ type: InteractionResponseTypes.ChannelMessageWithSource,
+ data: { content: "pong!" },
+ });
+ }
+});
+
+await session.start();
diff --git a/packages/biscuit/structures/builders/slash/ApplicationCommand.ts b/packages/biscuit/structures/builders/slash/ApplicationCommand.ts
index 031c092..12c430f 100644
--- a/packages/biscuit/structures/builders/slash/ApplicationCommand.ts
+++ b/packages/biscuit/structures/builders/slash/ApplicationCommand.ts
@@ -1,14 +1,14 @@
-import type { Localization, PermissionStrings } from '../../../../discordeno/mod.ts';
-import { ApplicationCommandTypes } from '../../../../discordeno/mod.ts';
-import { OptionBased } from './ApplicationCommandOption.ts';
-import { CreateApplicationCommand } from "../../../Session.ts"
+import type { Localization, PermissionStrings } from "../../../../discordeno/mod.ts";
+import { ApplicationCommandTypes } from "../../../../discordeno/mod.ts";
+import { OptionBased } from "./ApplicationCommandOption.ts";
+import { CreateApplicationCommand } from "../../../Session.ts";
export abstract class ApplicationCommandBuilder implements CreateApplicationCommand {
protected constructor(
// required
public type: ApplicationCommandTypes = ApplicationCommandTypes.ChatInput,
- public name = '',
- public description = '',
+ public name = "",
+ public description = "",
// non-required
public defaultMemberPermissions?: PermissionStrings[],
// etc
@@ -69,7 +69,7 @@ export class MessageApplicationCommandBuilder {
}
public toJSON(): { name: string; type: ApplicationCommandTypes.Message } {
- if (!this.name) throw new TypeError('Propety \'name\' is required');
+ if (!this.name) throw new TypeError("Propety 'name' is required");
return {
type: ApplicationCommandTypes.Message,
@@ -82,10 +82,10 @@ export class ChatInputApplicationCommandBuilder extends ApplicationCommandBuilde
public type: ApplicationCommandTypes.ChatInput = ApplicationCommandTypes.ChatInput;
public toJSON(): CreateApplicationCommand {
- if (!this.type) throw new TypeError('Propety \'type\' is required');
- if (!this.name) throw new TypeError('Propety \'name\' is required');
+ if (!this.type) throw new TypeError("Propety 'type' is required");
+ if (!this.name) throw new TypeError("Propety 'name' is required");
if (!this.description) {
- throw new TypeError('Propety \'description\' is required');
+ throw new TypeError("Propety 'description' is required");
}
return {
diff --git a/packages/biscuit/structures/builders/slash/ApplicationCommandOption.ts b/packages/biscuit/structures/builders/slash/ApplicationCommandOption.ts
index d475cd8..4f7d9c9 100644
--- a/packages/biscuit/structures/builders/slash/ApplicationCommandOption.ts
+++ b/packages/biscuit/structures/builders/slash/ApplicationCommandOption.ts
@@ -1,5 +1,5 @@
import { ApplicationCommandOptionTypes, type ChannelTypes, type Localization } from "../../../../discordeno/mod.ts";
-import { ApplicationCommandOptionChoice } from "../../interactions/CommandInteraction.ts"
+import { ApplicationCommandOptionChoice } from "../../interactions/CommandInteraction.ts";
export class ChoiceBuilder {
public name?: string;
diff --git a/packages/biscuit/structures/interactions/CommandInteraction.ts b/packages/biscuit/structures/interactions/CommandInteraction.ts
index f112b0b..74c4d5f 100644
--- a/packages/biscuit/structures/interactions/CommandInteraction.ts
+++ b/packages/biscuit/structures/interactions/CommandInteraction.ts
@@ -38,7 +38,7 @@ export interface InteractionApplicationCommandCallbackData
// components?: MessageComponents;
flags?: MessageFlags;
choices?: ApplicationCommandOptionChoice[];
-}
+}
/**
* @link https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice