import { DiscordBot, Command } from "sorionlib";
const bot = new DiscordBot({
token: process.env.DISCORD_TOKEN,
prefix: "!",
intents: ["Guilds", "GuildMessages", "MessageContent"]
});
// Middleware
bot.use(async (ctx, next) => {
console.log(`[${new Date().toISOString()}] ${ctx.command.name}`);
await next();
});
// Commands
bot.addCommand(
new Command()
.setName("ping")
.setDescription("Check latency")
.setHandler(async (ctx) => {
await ctx.reply(`Pong! ${ctx.client.ping}ms`);
})
);
bot.addCommand(
new Command()
.setName("avatar")
.setDescription("Get user avatar")
.addOption({
name: "user",
type: "user",
description: "Target user",
required: false
})
.setHandler(async (ctx) => {
const user = ctx.options.get("user") || ctx.author;
await ctx.reply(user.displayAvatarURL({ size: 512 }));
})
);
// Events
bot.on("ready", () => {
console.log(`Bot is ready! Logged in as ${bot.user.tag}`);
});
bot.start();