Skip to content

Commit 100a393

Browse files
authored
Merge pull request #4 from softnetics/yu/fix/deps
Fix dependencies error on bundle and add docs for what-is-dis
2 parents d4ab4cc + 86bfb56 commit 100a393

5 files changed

Lines changed: 163 additions & 11 deletions

File tree

.changeset/cuddly-pans-lie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@softnetics/what-is-dis': patch
3+
---
4+
5+
Add docs for what-is-dis

.changeset/lovely-eels-relate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@softnetics/what-is-dis": patch
3+
---
4+
5+
Fix dependencies error on bundle

packages/what-is-dis/README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# What Is Dis <!-- omit in toc -->
2+
3+
Typescript Discord bot framework aims to be a simple and easy to use framework for creating discord bots. It is built on top of [discord.js](https://discord.js.org/#/)
4+
5+
# Table of Contents <!-- omit in toc -->
6+
7+
# Installation
8+
9+
```bash
10+
npm install discord.js @softnetics/what-is-dis
11+
# Or
12+
yarn add discord.js @softnetics/what-is-dis
13+
# Or
14+
pnpm add discord.js @softnetics/what-is-dis
15+
# Or
16+
bun add discord.js @softnetics/what-is-dis
17+
```
18+
19+
# Usage
20+
21+
```ts
22+
import { GatewayIntentBits } from '@discordjs/core'
23+
import { DiscordBot, defineSlashCommandBasic } from '@softnetics/what-is-dis'
24+
25+
const pingCommand = defineSlashCommandBasic({
26+
name: 'ping',
27+
description: 'Ping!',
28+
options: {
29+
message: {
30+
type: 'string',
31+
description: 'Message to echo back',
32+
choices: [
33+
{ name: 'Hello', value: 'hello' },
34+
{ name: 'World', value: 'world' },
35+
],
36+
},
37+
to: {
38+
type: 'user',
39+
description: 'User to ping',
40+
required: true,
41+
},
42+
},
43+
execute: async ({ interaction, body, logger }) => {
44+
const message = body.message // Type: "hello" | "world" | undefined
45+
const user = body.to // Type: string (user id)
46+
logger.info(`Received /ping command with message: ${message} and user: ${user}`)
47+
await interaction.reply({
48+
content: `Pong! ${message} <@${user}>`,
49+
})
50+
},
51+
})
52+
53+
// Create a discord bot instance
54+
const bot = new DiscordBot({
55+
clientId: environment.DISCORD_CLIENT_ID,
56+
token: environment.DISCORD_TOKEN,
57+
intents: [
58+
GatewayIntentBits.Guilds,
59+
GatewayIntentBits.GuildMessages,
60+
GatewayIntentBits.MessageContent,
61+
],
62+
// If this value is set, the bot will only register commands in this guild. It's useful for development.
63+
developmentGuildId: environment.DISCORD_DEVELOPMENT_GUILD_ID,
64+
// If this value is set to true, the bot will delete the commands before registering them for `developmentGuildId`.
65+
refreshCommands: true,
66+
// Add more slash commands here
67+
slashCommands: [pingCommand],
68+
// Customized logger
69+
loggerOptions: {
70+
level: 'debug',
71+
},
72+
// This function will be called when the bot is ready
73+
onReady: ({ logger }) => {
74+
logger.info('Try to excecute /ping command!')
75+
},
76+
// This function will be called before the bot shuts down
77+
onShutDown: async ({ logger }) => {
78+
logger.info('Bot is shutting down!')
79+
},
80+
})
81+
82+
// Register the given slash commands and listen for the event
83+
bot.listen()
84+
```
85+
86+
# Examples
87+
88+
You can find examples in the [examples](./examples) folder.
89+
90+
- [Ping-pong discord bot](./examples/bun-simple-bot/)
91+
92+
# Features
93+
94+
- [x] Slash commands
95+
- Input types
96+
- [x] Subcommands
97+
- [ ] 🚧 Subcommand groups
98+
- [x] String
99+
- [x] Integer
100+
- [x] Boolean
101+
- [x] User
102+
- [x] Channel
103+
- [x] Role
104+
- [x] Mentionable
105+
- [x] Number
106+
- [x] Attachment
107+
- [ ] 🚧 Message command with prefix
108+
- [ ] 🚧 Message components
109+
- [ ] 🚧 [Action Rows](https://discordjs.guide/message-components/action-rows.html)
110+
- [ ] 🚧 [Buttons](https://discordjs.guide/message-components/buttons.html)
111+
- [ ] 🚧 [Select menus](https://discordjs.guide/message-components/select-menus.html)
112+
- [ ] 🚧 Other components
113+
- [ ] 🚧 [Modal](https://discordjs.guide/interactions/modals.html#building-and-responding-with-modals)
114+
- [ ] 🚧 [Context Menu](https://discordjs.guide/interactions/context-menus.html)
115+
- [ ] 🚧 Emoji reactions
116+
117+
# Contributing
118+
119+
WIP
120+
121+
# License
122+
123+
[MIT](./LICENSE)

packages/what-is-dis/package.json

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,29 @@
55
"main": "dist/index.cjs",
66
"types": "dist/index.d.ts",
77
"module": "dist/index.js",
8+
"license": "MIT",
89
"homepage": "https://github.com/softnetics/what-is-dis",
10+
"bugs": {
11+
"url": "https://github.com/softnetics/what-is-dis"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/softnetics/what-is-dis.git"
16+
},
917
"files": [
1018
"dist"
1119
],
20+
"keywords": [
21+
"typescript",
22+
"discord",
23+
"discord.js",
24+
"type-safe"
25+
],
26+
"author": {
27+
"name": "Saenyakorn Siangsanoh",
28+
"email": "me@saenyakorn.dev",
29+
"url": "https://saenyakorn.dev"
30+
},
1231
"scripts": {
1332
"build": "tsup",
1433
"build:watch": "tsup --watch",
@@ -17,12 +36,12 @@
1736
"dependencies": {
1837
"discord.js": "^14.14.1",
1938
"winston": "^3.11.0",
20-
"zod": "^3.22.4"
39+
"zod": "^3.22.4",
40+
"utility-types": "^3.10.0",
41+
"typescript": "^5.2.2"
2142
},
2243
"devDependencies": {
2344
"@internal/project-config": "workspace:^",
24-
"tsup": "^7.2.0",
25-
"typescript": "^5.2.2",
26-
"utility-types": "^3.10.0"
45+
"tsup": "^7.2.0"
2746
}
2847
}

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)