https://github.com/warsam-e/echo
A discord.js wrapper, with a focus on slash commands.
https://github.com/warsam-e/echo
bot commando discord discord-js
Last synced: 5 months ago
JSON representation
A discord.js wrapper, with a focus on slash commands.
- Host: GitHub
- URL: https://github.com/warsam-e/echo
- Owner: itss0n1c
- Created: 2021-08-26T20:37:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-30T20:16:12.000Z (about 1 year ago)
- Last Synced: 2024-12-30T20:54:04.777Z (about 1 year ago)
- Topics: bot, commando, discord, discord-js
- Language: TypeScript
- Homepage:
- Size: 4.52 MB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @warsam-e/echo
### Simplifies the creation and handling of slash commands in Discord bots.
## Installation
```zsh
% bun i @warsam-e/echo
```
## Basic Usage
```ts
import Echo, { Command } from '@warsam-e/echo';
let commands = [
new Command({
name: 'ping',
description: 'Pong!',
owners_only: true, // default: false
nsfw: true, // default: false
}).addHandler('chat_input', async (bot, int) => {
const sent = await int.deferReply({ withResponse: true });
if (!sent.resource?.message?.createdTimestamp)
return int.editReply('An error occured while executing the command.');
const diff = sent.resource?.message?.createdTimestamp - int.createdTimestamp;
const content = [
'### 🏓 Pong!',
`## ${diff}ms`,
...(bot.isSharding ? [`-# via shard #${bot.shardId}`] : []),
].join('\n');
return int.editReply(content);
})
];
new Echo({
name: 'MyBot',
color: 'LuminousVividPink',
})
.register_commands(commands)
.init(); // starts the bot, .init(TOKEN) if `TOKEN` env is not set
```
## Scrollable
Echo includes a class called `Scrollable` which can be used to create scrollable content.
To initate this class, you can use the `create_scrollable` function.
```ts
import { Command, create_scrollable } from '@warsam-e/echo';
new Command({})
.addHandler("chat_input", (bot, int) => create_scrollable({
int,
data: () => [{ title: "foo" }, { title: "bar" }],
match: (v) => ({
content: `## ${v.title}`
})
}));
```