Skip to content

Commit 1eee34f

Browse files
authored
Merge pull request #164 from tjjfvi/update
2 parents 797e7f7 + d5dc0a2 commit 1eee34f

19 files changed

+302
-209
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v1
16-
- name: install node v12
16+
- name: install node v16
1717
uses: actions/setup-node@v1
1818
with:
19-
node-version: 12
19+
node-version: 16
2020

2121
- name: yarn install
2222
run: yarn install

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: '3'
33

44
services:
55
bot:
6-
image: node:13
6+
image: node:16
77
command: yarn start
88
depends_on:
99
- postgres

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dependencies": {
77
"@typescript/twoslash": "^2.1.0",
88
"algoliasearch": "^4.8.6",
9-
"cookiecord": "^0.5.18",
9+
"cookiecord": "^0.8.18",
1010
"dotenv-safe": "^8.2.0",
1111
"html-entities": "^2.3.2",
1212
"lz-string": "^1.4.4",

src/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@ const client = new CookiecordClient(
2020
prefix: ['!', 't!'],
2121
},
2222
{
23-
ws: { intents: Intents.NON_PRIVILEGED },
2423
partials: ['REACTION', 'MESSAGE', 'USER', 'CHANNEL'],
25-
disableMentions: 'everyone',
24+
allowedMentions: {
25+
parse: ['users'],
26+
},
27+
intents: new Intents([
28+
'GUILDS',
29+
'GUILD_MESSAGES',
30+
'GUILD_MEMBERS',
31+
'GUILD_MESSAGE_REACTIONS',
32+
]),
2633
},
27-
);
34+
).setMaxListeners(Infinity);
2835

2936
for (const mod of [
3037
AutoroleModule,

src/modules/etc.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import {
1111
GuildMember,
1212
User,
1313
ReactionEmoji,
14+
TextChannel,
1415
} from 'discord.js';
16+
import { MessageChannel } from 'worker_threads';
1517
import {
1618
clearMessageOwnership,
1719
DELETE_EMOJI,
@@ -30,7 +32,7 @@ export class EtcModule extends Module {
3032
await msg.channel.send('pong. :ping_pong:');
3133
}
3234

33-
@listener({ event: 'message' })
35+
@listener({ event: 'messageCreate' })
3436
async onMessage(msg: Message) {
3537
if (msg.author.bot || !msg.content.toLowerCase().startsWith('poll:'))
3638
return;
@@ -47,7 +49,8 @@ export class EtcModule extends Module {
4749
async onReact(reaction: MessageReaction, member: GuildMember) {
4850
if (reaction.partial) return;
4951

50-
if (reaction.message.author.id !== this.client.user?.id) return;
52+
if ((await reaction.message.fetch()).author.id !== this.client.user?.id)
53+
return;
5154
if (reaction.emoji.name !== DELETE_EMOJI) return;
5255
if (member.id === this.client.user?.id) return;
5356

@@ -69,7 +72,8 @@ export class EtcModule extends Module {
6972
const reactionFilter = (reaction: MessageReaction, user: User) =>
7073
reaction.emoji.name === confirm && user.id === msg.author.id;
7174
const proceed = await confirmationMessage
72-
.awaitReactions(reactionFilter, {
75+
.awaitReactions({
76+
filter: reactionFilter,
7377
max: 1,
7478
time: 10 * 1000,
7579
errors: ['time'],

src/modules/handbook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class HandbookModule extends Module {
3535
async handbook(msg: Message, text: string) {
3636
if (!text)
3737
return await sendWithMessageOwnership(msg, {
38-
embed: this.HANDBOOK_EMBED,
38+
embeds: [this.HANDBOOK_EMBED],
3939
});
4040
const data = await algolia.search<AlgoliaResult>([
4141
{
@@ -61,6 +61,6 @@ export class HandbookModule extends Module {
6161
.setTitle(decode(hierarchyParts[hierarchyParts.length - 1]))
6262
.setAuthor(decode(hierarchyParts.slice(0, -1).join(' / ')))
6363
.setURL(hit.url);
64-
await sendWithMessageOwnership(msg, { embed });
64+
await sendWithMessageOwnership(msg, { embeds: [embed] });
6565
}
6666
}

src/modules/help.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ export class HelpModule extends Module {
7676

7777
embed
7878
.setFooter(
79-
this.client.user?.username,
80-
this.client.user?.displayAvatarURL(),
79+
this.client.user!.username,
80+
this.client.user!.displayAvatarURL(),
8181
)
8282
.setTimestamp();
8383

84-
return await sendWithMessageOwnership(msg, { embed });
84+
return await sendWithMessageOwnership(msg, { embeds: [embed] });
8585
}
8686

8787
let cmd: { description?: string; triggers?: string[] } =
@@ -116,6 +116,6 @@ export class HelpModule extends Module {
116116
`*${splitCategoryDescription(cmd.description ?? '')[1]}*`,
117117
);
118118

119-
await sendWithMessageOwnership(msg, { embed });
119+
await sendWithMessageOwnership(msg, { embeds: [embed] });
120120
}
121121
}

0 commit comments

Comments
 (0)