Skip to content

Commit 4b739a3

Browse files
committed
add tests
1 parent 274d7f3 commit 4b739a3

File tree

7 files changed

+111
-2
lines changed

7 files changed

+111
-2
lines changed

packages/commandkit/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
dist
33
.DS_Store
4-
.vscode
4+
.vscode
5+
.env

packages/commandkit/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/node_modules
22
/src
3+
/tests
34
/.github
45
/.vscode
56
/.git

packages/commandkit/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"lint": "tsc",
1717
"dev": "tsup --watch",
1818
"build": "tsup",
19-
"publish": "npm publish"
19+
"publish": "npm publish",
20+
"test": "tsx tests/index.ts"
2021
},
2122
"repository": {
2223
"type": "git",
@@ -35,8 +36,10 @@
3536
"devDependencies": {
3637
"@types/node": "^20.5.9",
3738
"discord.js": "^14.13.0",
39+
"dotenv": "^16.3.1",
3840
"tsconfig": "workspace:*",
3941
"tsup": "^7.2.0",
42+
"tsx": "^3.12.8",
4043
"typescript": "^5.1.6"
4144
},
4245
"peerDependencies": {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TOKEN = 'bot_token'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { ChatInputCommandInteraction, PermissionResolvable } from 'discord.js';
2+
3+
export const data = {
4+
name: 'ping',
5+
description: 'Pong!',
6+
};
7+
8+
export function run({ interaction }: { interaction: ChatInputCommandInteraction }) {
9+
interaction.reply('Pong!');
10+
}
11+
12+
export const options: {
13+
userPermissions: PermissionResolvable;
14+
} = {
15+
userPermissions: ['AddReactions', 'KickMembers'],
16+
};

packages/commandkit/tests/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { CommandKit } from '../src/index';
2+
import { Client } from 'discord.js';
3+
import { config } from 'dotenv';
4+
5+
config({ path: `${__dirname}/.env` });
6+
7+
const client = new Client({
8+
intents: ['Guilds', 'GuildMembers', 'GuildMessages', 'MessageContent'],
9+
});
10+
11+
client.on('ready', (c) => console.log(`${c.user.username} is online`));
12+
13+
new CommandKit({
14+
client,
15+
commandsPath: `${__dirname}/commands`,
16+
});
17+
18+
client.login(process.env.TOKEN);

pnpm-lock.yaml

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)