Skip to content

A lightweight framework for building discord bots built on-top of discord.js

License

Notifications You must be signed in to change notification settings

l3dotdev/discordthing

Repository files navigation

discordthing

Description

A lightweight framework and collection of plugins for building a discord bot with discord.js

Installation

npm install discordthing
pnpm add discordthing

Create a bot

import { Bot } from "discordthing";

import { myCommand } from "./say.command";
import { myListener } from "./welcome.event";

const bot = new Bot(
	{
		name: "My bot",
		commands: [myCommand],
		listeners: [myListener]
	},
	{
		intents: ["Guilds", "GuildMembers"]
	}
);

await bot.start(process.env.DISCORD_BOT_TOKEN);

Define a command

// say.command.ts

import { command } from "discordthing/commands";
import { o } from "discordthing/options";
import { NONE } from "@l3dev/result";

export const myCommand = command({
	meta: {
		name: "say"
	},
	options: {
		message: o.string().describe("The message to say")
	},
	async handler(ctx, args) {
		await ctx.interaction.reply(args.message);

		return NONE;
	}
});

Define an event listener

// welcome.event.ts

import { listen } from "discordthing/events";
import { Events } from "discord.js";

export const myListener = listen({
	event: Events.GuildMemberAdd,
	async handler(member) {
		const joinChannel = await getJoinChannel(member.guild);

		await joinChannel.send(`Welcome <@${member.user.id}>!`);
	}
});

About

A lightweight framework for building discord bots built on-top of discord.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors