mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
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();
|