mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
Update examples
This commit is contained in:
parent
af73561279
commit
9193346f52
@ -1,4 +1,4 @@
|
|||||||
import "https://deno.land/std@0.146.0/dotenv/load.ts";
|
import 'https://deno.land/std@0.146.0/dotenv/load.ts';
|
||||||
import {
|
import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
@ -7,23 +7,23 @@ import {
|
|||||||
GatewayIntents,
|
GatewayIntents,
|
||||||
InteractionResponseTypes,
|
InteractionResponseTypes,
|
||||||
Session,
|
Session,
|
||||||
} from "./deps.ts";
|
} from 'https://x.nest.land/biscuit@0.1.0/mod.ts';
|
||||||
|
|
||||||
const token = Deno.env.get("TOKEN") ?? Deno.args[0];
|
const token = Deno.env.get("TOKEN") ?? Deno.args[0];
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw new Error("Please provide a token");
|
throw new Error('Please provide a token');
|
||||||
}
|
}
|
||||||
|
|
||||||
const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
|
const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
|
||||||
const session = new Session({ token, intents });
|
const session = new Session({ token, intents });
|
||||||
|
|
||||||
const PREFIX = ">";
|
const PREFIX = ">";
|
||||||
const components = new ButtonBuilder().setCustomId("ping").setLabel("Hello!").setStyle(ButtonStyles.Success);
|
const components = new ButtonBuilder().setCustomId('ping').setLabel('Hello!').setStyle(ButtonStyles.Success);
|
||||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(components).toJSON();
|
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(components).toJSON();
|
||||||
|
|
||||||
session.on("ready", (payload) => {
|
session.on('ready', (payload) => {
|
||||||
console.log("Logged in as:", payload.user.username);
|
console.log('Logged in as:', payload.user.username);
|
||||||
});
|
});
|
||||||
|
|
||||||
session.on("messageCreate", (message) => {
|
session.on("messageCreate", (message) => {
|
||||||
@ -35,7 +35,7 @@ session.on("messageCreate", (message) => {
|
|||||||
const name = args.shift()?.toLowerCase();
|
const name = args.shift()?.toLowerCase();
|
||||||
console.log(args, name);
|
console.log(args, name);
|
||||||
|
|
||||||
if (name === "ping") {
|
if (name === 'ping') {
|
||||||
message.reply({ components: [row] })
|
message.reply({ components: [row] })
|
||||||
.then(() => {})
|
.then(() => {})
|
||||||
.catch((e) => console.error(e));
|
.catch((e) => console.error(e));
|
||||||
@ -43,7 +43,7 @@ session.on("messageCreate", (message) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Follow interaction event
|
// Follow interaction event
|
||||||
session.on("interactionCreate", (interaction) => {
|
session.on('interactionCreate', (interaction) => {
|
||||||
if (!interaction.isComponent()) return;
|
if (!interaction.isComponent()) return;
|
||||||
const component = interaction as ComponentInteraction;
|
const component = interaction as ComponentInteraction;
|
||||||
if (component.customId == "ping") {
|
if (component.customId == "ping") {
|
@ -11,11 +11,6 @@ const token = process.env.TOKEN;
|
|||||||
const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
|
const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
|
||||||
const session = new Session({ token, intents });
|
const session = new Session({ token, intents });
|
||||||
|
|
||||||
// uncomment to debug stuff
|
|
||||||
// session.on("debug", (any) => {
|
|
||||||
// console.debug(any);
|
|
||||||
// })
|
|
||||||
|
|
||||||
session.on("ready", (payload) => {
|
session.on("ready", (payload) => {
|
||||||
console.log("Logged in as:", payload.user.username);
|
console.log("Logged in as:", payload.user.username);
|
||||||
});
|
});
|
||||||
@ -32,3 +27,4 @@ session.on("messageCreate", async (message) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await session.start();
|
await session.start();
|
||||||
|
|
@ -3,6 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import "https://deno.land/std@0.146.0/dotenv/load.ts";
|
import "https://deno.land/std@0.146.0/dotenv/load.ts";
|
||||||
|
|
||||||
|
// Session for create a new bot and intents
|
||||||
import { GatewayIntents, Session } from "https://x.nest.land/biscuit@0.1.0/mod.ts";
|
import { GatewayIntents, Session } from "https://x.nest.land/biscuit@0.1.0/mod.ts";
|
||||||
|
|
||||||
const token = Deno.env.get("TOKEN") ?? Deno.args[0];
|
const token = Deno.env.get("TOKEN") ?? Deno.args[0];
|
||||||
@ -34,3 +36,4 @@ session.on("messageCreate", (message) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await session.start();
|
await session.start();
|
||||||
|
|
@ -2,10 +2,14 @@
|
|||||||
* Biscuit node example
|
* Biscuit node example
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// process for get the token
|
||||||
/** @type {NodeJS.Process} process */
|
/** @type {NodeJS.Process} process */
|
||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
|
|
||||||
|
// Session for create a new bot and intents
|
||||||
import { Session, GatewayIntents } from '@oasisjs/biscuit';
|
import { Session, GatewayIntents } from '@oasisjs/biscuit';
|
||||||
|
|
||||||
|
// Discord bot token
|
||||||
/** @type {string} token */
|
/** @type {string} token */
|
||||||
const token = process.env.TOKEN || "YOUR_TOKEN_HERE";
|
const token = process.env.TOKEN || "YOUR_TOKEN_HERE";
|
||||||
|
|
||||||
@ -15,6 +19,8 @@ if (token === "") {
|
|||||||
|
|
||||||
const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
|
const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
|
||||||
const session = new Session({ token, intents });
|
const session = new Session({ token, intents });
|
||||||
|
|
||||||
|
// Command prefix
|
||||||
const PREFIX = ">";
|
const PREFIX = ">";
|
||||||
|
|
||||||
session.on("ready", (data) => {
|
session.on("ready", (data) => {
|
||||||
@ -35,8 +41,4 @@ session.on("messageCreate", (message) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
|
||||||
session.start();
|
session.start();
|
||||||
} catch(err){
|
|
||||||
throw err;
|
|
||||||
}
|
|
@ -2,10 +2,14 @@
|
|||||||
* Biscuit node example
|
* Biscuit node example
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// process for get the token
|
||||||
/** @type {NodeJS.Process} process */
|
/** @type {NodeJS.Process} process */
|
||||||
const process = require("node:process");
|
const process = require("node:process");
|
||||||
|
|
||||||
|
// Session for create a new bot and intents
|
||||||
const { Session, GatewayIntents } = require("@oasisjs/biscuit");
|
const { Session, GatewayIntents } = require("@oasisjs/biscuit");
|
||||||
|
|
||||||
|
// Discord bot token
|
||||||
/** @type {string} token */
|
/** @type {string} token */
|
||||||
const token = process.env.TOKEN || "YOUR_TOKEN_HERE";
|
const token = process.env.TOKEN || "YOUR_TOKEN_HERE";
|
||||||
|
|
||||||
@ -15,6 +19,8 @@ if (token === "") {
|
|||||||
|
|
||||||
const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
|
const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
|
||||||
const session = new Session({ token, intents });
|
const session = new Session({ token, intents });
|
||||||
|
|
||||||
|
// Command prefix
|
||||||
const PREFIX = ">";
|
const PREFIX = ">";
|
||||||
|
|
||||||
session.on("ready", (data) => {
|
session.on("ready", (data) => {
|
||||||
@ -35,8 +41,4 @@ session.on("messageCreate", (message) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
|
||||||
session.start();
|
session.start();
|
||||||
} catch(err){
|
|
||||||
throw err;
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user