Skip to content

Commit aca941a

Browse files
authored
Merge pull request #7 from OnekiDevs/fix-intents
fix intents
2 parents f93652a + c683f36 commit aca941a

File tree

7 files changed

+996
-63
lines changed

7 files changed

+996
-63
lines changed

.github/workflows/release_on_merge.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,21 @@ jobs:
1414
- name: Checkout main branch
1515
uses: actions/checkout@v4
1616

17+
- name: Setup Node
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 20
21+
registry-url: https://registry.npmjs.org
22+
env:
23+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
24+
1725
# 2. Instalar dependencias y compilar el proyecto
1826
- name: Install dependencies and run build
1927
run: |
2028
npm install
2129
npm run build
30+
env:
31+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
2232

2333
# 3. Obtener la versión del package.json
2434
- name: Get version from package.json

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
# 2.7.4
6+
7+
## Fix
8+
9+
- **OFFDJS_INTENTS** loaded correctly
10+
511
# 2.7.3
612

713
## Fix

README.md

Lines changed: 64 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ offdjs is a small framework that uses
1717
simplify the development of the Oneki bot made public so that anyone can create
1818
their own bot in a few lines of code
1919

20-
- little
21-
- fast
22-
- easy to use
23-
- 0 config
20+
- little
21+
- fast
22+
- easy to use
23+
- 0 config
2424

2525
# Installation
2626

@@ -36,7 +36,7 @@ Set your token in an .env file at the root of the project (according to
3636
[discord.js](https://https://discord.js.org/) specs)
3737

3838
```env
39-
DISCORD_TOKEN="your_discord_token"
39+
OFFDJS_TOKEN="your_discord_token"
4040
```
4141

4242
At this point you can run your script from the root of your project and the bot
@@ -51,9 +51,9 @@ npx offdjs
5151
5252
```json
5353
{
54-
"scripts": {
55-
"start": "offdjs"
56-
}
54+
"scripts": {
55+
"start": "offdjs"
56+
}
5757
}
5858
```
5959

@@ -71,7 +71,7 @@ or
7171
An example with .env
7272

7373
```env
74-
DISCORD_INTENTS="1 GUILD_MEMBERS GuildBans"
74+
OFFDJS_INTENTS="1 GUILD_MEMBERS GuildBans"
7575
```
7676

7777
An example with cli
@@ -113,7 +113,7 @@ of such an event
113113
```js
114114
// events/ready.js
115115
export function handler(client) {
116-
console.log("ready");
116+
console.log('ready')
117117
}
118118
```
119119

@@ -126,14 +126,14 @@ constant.
126126

127127
```js
128128
// events/other_ready.js
129-
import { Events } from "offdjs/djs";
129+
import { Events } from 'offdjs/djs'
130130

131-
export const name = Events.ClientReady;
131+
export const name = Events.ClientReady
132132

133-
export const once = true;
133+
export const once = true
134134

135135
export function handler(client) {
136-
console.log("ready again");
136+
console.log('ready again')
137137
}
138138
```
139139

@@ -164,19 +164,19 @@ For buttons, the folder name is `buttons`.
164164

165165
```js
166166
// confirm_ban.js
167-
export const name = /ban:\d{18,19}/;
167+
export const name = /ban:\d{18,19}/
168168

169169
/**
170170
* @param {ButtonInteraction} interaction - djs interaction object
171171
* @param {'ban'} _ - in this case always is 'ban'
172172
* @param {string} id - the id of the member to ban
173173
*/
174174
export function handler(interaction, _, id) {
175-
// example code
176-
const user = interaction.guild?.members.ban(id);
177-
interaction.reply({
178-
content: `User ${user} banned successfully`,
179-
});
175+
// example code
176+
const user = interaction.guild?.members.ban(id)
177+
interaction.reply({
178+
content: `User ${user} banned successfully`,
179+
})
180180
}
181181
```
182182
@@ -198,19 +198,19 @@ menu, whether string, channel, role, user and mentionable menus.
198198
199199
```js
200200
// welcome_channel.js
201-
export const name = "config:welcome_channel";
201+
export const name = 'config:welcome_channel'
202202

203203
/**
204204
* @param {AnySelectMenuInteraction} interaction - djs interaction object
205205
*/
206206
export function handler(interaction) {
207-
// example code
208-
if (!interaction.isChannelSelectMenu()) return;
209-
const channel = interaction.channels.first();
210-
interaction.client.configWelcomeChannel(channel);
211-
interaction.reply({
212-
content: `welcomes are now displayed in ${channel}`,
213-
});
207+
// example code
208+
if (!interaction.isChannelSelectMenu()) return
209+
const channel = interaction.channels.first()
210+
interaction.client.configWelcomeChannel(channel)
211+
interaction.reply({
212+
content: `welcomes are now displayed in ${channel}`,
213+
})
214214
}
215215
```
216216
@@ -231,19 +231,19 @@ is surprisingly `modals`.
231231
232232
```js
233233
// secret.js
234-
export const name = "secret";
234+
export const name = 'secret'
235235

236236
/**
237237
* @param {ModalSubmitInteraction} interaction - djs interaction object
238238
*/
239239
export function handler(interaction) {
240-
// example code
241-
const secret = interaction.fields.getTextInputValue("secret");
242-
interaction.client.publishSecret(secret);
243-
interaction.reply({
244-
content: "Your secret was published anonymously",
245-
ephemeral: true,
246-
});
240+
// example code
241+
const secret = interaction.fields.getTextInputValue('secret')
242+
interaction.client.publishSecret(secret)
243+
interaction.reply({
244+
content: 'Your secret was published anonymously',
245+
ephemeral: true,
246+
})
247247
}
248248
```
249249
@@ -301,9 +301,9 @@ as if they were buttons.
301301
Offdjs will register the command for execution in the following order of
302302
priority:
303303
304-
- The name constant exported
305-
- The name of the constant `command` exported.
306-
- The name of the file
304+
- The name constant exported
305+
- The name of the constant `command` exported.
306+
- The name of the file
307307
308308
This means that the `export const name` is optional, plus, if you need to, you
309309
can name the file `poll:create.js` to listen only to the `/poll create`
@@ -394,17 +394,17 @@ will also be received in the function parameters as a custom id.
394394
395395
```js
396396
// secret.js
397-
export const name = "poll:finish";
397+
export const name = 'poll:finish'
398398
399399
/**
400400
* @param {AutocompleteInteraction} interaction - djs interaction object
401401
*/
402402
export function handler(interaction) {
403-
// example code
404-
const polls = interaction.client.polls
405-
.search(interaction.options.getFocused())
406-
.map((p) => ({ value: p.id, name: p.name }));
407-
interaction.respond(polls);
403+
// example code
404+
const polls = interaction.client.polls
405+
.search(interaction.options.getFocused())
406+
.map(p => ({ value: p.id, name: p.name }))
407+
interaction.respond(polls)
408408
}
409409
```
410410
@@ -440,14 +440,14 @@ npx offdjs ./index.js
440440
441441
```js
442442
// index.js
443-
import server from "./server.js";
444-
import client from "offdjs";
445-
import mydb from "./db.js";
443+
import server from './server.js'
444+
import client from 'offdjs'
445+
import mydb from './db.js'
446446
447447
// your custom process
448-
await mydb.connect();
449-
await server.listen(process.env.PORT ?? 3000);
450-
server.send(client.user.username + " ready");
448+
await mydb.connect()
449+
await server.listen(process.env.PORT ?? 3000)
450+
server.send(client.user.username + ' ready')
451451
```
452452
453453
> remember not to initialize the client in that file, offdjs already initializes
@@ -491,3 +491,16 @@ client.options.root = 'build'
491491
492492
await client.login()
493493
```
494+
495+
# TypeScript Support
496+
497+
You can type your event handlers
498+
499+
```ts
500+
import { EventHandler } from 'offdjs'
501+
import { Events } from 'offdjs/djs'
502+
503+
export const handler: EventHandler<Events.ClientReady> = async client => {
504+
console.log('ready again')
505+
}
506+
```

0 commit comments

Comments
 (0)