Skip to content

Commit 24e6f51

Browse files
committed
fix: make use of BaseChannel#isSendable()
Signed-off-by: Seren_Modz 21 <seren@kings-world.net>
1 parent 585099b commit 24e6f51

File tree

12 files changed

+34
-39
lines changed

12 files changed

+34
-39
lines changed

examples/with-esm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@sapphire/time-utilities": "^1.7.12",
2424
"@sapphire/type": "^2.5.1",
2525
"@sapphire/utilities": "^3.17.0",
26-
"discord.js": "^14.16.1"
26+
"discord.js": "^14.16.2"
2727
},
2828
"devDependencies": {
2929
"@sapphire/cli": "^1.9.3",

examples/with-javascript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@sapphire/time-utilities": "^1.7.12",
1818
"@sapphire/type": "^2.5.1",
1919
"@sapphire/utilities": "^3.17.0",
20-
"discord.js": "^14.16.1"
20+
"discord.js": "^14.16.2"
2121
},
2222
"devDependencies": {
2323
"@sapphire/cli": "^1.9.3",

examples/with-swc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@sapphire/type": "^2.5.1",
2020
"@sapphire/utilities": "^3.17.0",
2121
"@skyra/env-utilities": "^1.3.0",
22-
"discord.js": "^14.16.1"
22+
"discord.js": "^14.16.2"
2323
},
2424
"devDependencies": {
2525
"@sapphire/cli": "^1.9.3",

examples/with-swc/src/listeners/mentionPrefixOnly.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import type { Events } from '@sapphire/framework';
22
import { Listener } from '@sapphire/framework';
3-
import { ChannelType, type Message } from 'discord.js';
3+
import type { Message } from 'discord.js';
44

55
export class UserEvent extends Listener<typeof Events.MentionPrefixOnly> {
6-
public override async run(message: Message) {
7-
// TODO: replace with BaseChannel#isSendable once discord.js releases a new version
8-
// Bots cannot send messages in group DMs, so we have no choice but to return.
9-
if (message.channel.type === ChannelType.GroupDM) return;
6+
public override run(message: Message) {
7+
// Do nothing if we cannot send messages in the channel (eg. group DMs)
8+
if (!message.channel.isSendable()) return;
109

1110
const prefix = this.container.client.options.defaultPrefix;
1211
return message.channel.send(prefix ? `My prefix in this guild is: \`${prefix}\`` : 'Cannot find any Prefix for Message Commands.');

examples/with-tsup/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@sapphire/type": "^2.5.1",
2020
"@sapphire/utilities": "^3.17.0",
2121
"@skyra/env-utilities": "^1.3.0",
22-
"discord.js": "^14.16.1"
22+
"discord.js": "^14.16.2"
2323
},
2424
"devDependencies": {
2525
"@sapphire/cli": "^1.9.3",

examples/with-tsup/src/listeners/mentionPrefixOnly.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import type { Events } from '@sapphire/framework';
22
import { Listener } from '@sapphire/framework';
3-
import { ChannelType, type Message } from 'discord.js';
3+
import type { Message } from 'discord.js';
44

55
export class UserEvent extends Listener<typeof Events.MentionPrefixOnly> {
6-
public override async run(message: Message) {
7-
// TODO: replace with BaseChannel#isSendable once discord.js releases a new version
8-
// Bots cannot send messages in group DMs, so we have no choice but to return.
9-
if (message.channel.type === ChannelType.GroupDM) return;
6+
public override run(message: Message) {
7+
// Do nothing if we cannot send messages in the channel (eg. group DMs)
8+
if (!message.channel.isSendable()) return;
109

1110
const prefix = this.container.client.options.defaultPrefix;
1211
return message.channel.send(prefix ? `My prefix in this guild is: \`${prefix}\`` : 'Cannot find any Prefix for Message Commands.');

examples/with-typescript-complete/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@sapphire/utilities": "^3.17.0",
2121
"@skyra/env-utilities": "^1.3.0",
2222
"colorette": "^2.0.20",
23-
"discord.js": "^14.16.1"
23+
"discord.js": "^14.16.2"
2424
},
2525
"devDependencies": {
2626
"@sapphire/cli": "^1.9.3",

examples/with-typescript-complete/src/listeners/mentionPrefixOnly.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import type { Events } from '@sapphire/framework';
22
import { Listener } from '@sapphire/framework';
3-
import { ChannelType, type Message } from 'discord.js';
3+
import type { Message } from 'discord.js';
44

55
export class UserEvent extends Listener<typeof Events.MentionPrefixOnly> {
6-
public override async run(message: Message) {
7-
// TODO: replace with BaseChannel#isSendable once discord.js releases a new version
8-
// Bots cannot send messages in group DMs, so we have no choice but to return.
9-
if (message.channel.type === ChannelType.GroupDM) return;
6+
public override run(message: Message) {
7+
// Do nothing if we cannot send messages in the channel (eg. group DMs)
8+
if (!message.channel.isSendable()) return;
109

1110
const prefix = this.container.client.options.defaultPrefix;
1211
return message.channel.send(prefix ? `My prefix in this guild is: \`${prefix}\`` : 'Cannot find any Prefix for Message Commands.');

examples/with-typescript-starter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@sapphire/utilities": "^3.17.0",
1414
"@skyra/env-utilities": "^1.3.0",
1515
"colorette": "^2.0.20",
16-
"discord.js": "^14.16.1"
16+
"discord.js": "^14.16.2"
1717
},
1818
"devDependencies": {
1919
"@sapphire/cli": "^1.9.3",

examples/with-typescript-starter/src/commands/ping.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ export class UserCommand extends Command {
5858
}
5959

6060
private async sendPing(interactionOrMessage: Message | Command.ChatInputCommandInteraction | Command.ContextMenuCommandInteraction) {
61-
// TODO: replace with BaseChannel#isSendable once discord.js releases a new version
62-
// PR for reference: https://github.com/discordjs/discord.js/pull/10482
63-
if (interactionOrMessage.channel && !('send' in interactionOrMessage.channel)) return;
61+
// Do nothing if we cannot send messages in the channel (eg. group DMs)
62+
if (!interactionOrMessage.channel?.isSendable()) return;
6463

6564
const pingMessage =
6665
interactionOrMessage instanceof Message

examples/with-typescript-starter/src/listeners/mentionPrefixOnly.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import type { Events } from '@sapphire/framework';
22
import { Listener } from '@sapphire/framework';
3-
import { ChannelType, type Message } from 'discord.js';
3+
import type { Message } from 'discord.js';
44

55
export class UserEvent extends Listener<typeof Events.MentionPrefixOnly> {
6-
public override async run(message: Message) {
7-
// TODO: replace with BaseChannel#isSendable once discord.js releases a new version
8-
// Bots cannot send messages in group DMs, so we have no choice but to return.
9-
if (message.channel.type === ChannelType.GroupDM) return;
6+
public override run(message: Message) {
7+
// Do nothing if we cannot send messages in the channel (eg. group DMs)
8+
if (!message.channel.isSendable()) return;
109

1110
const prefix = this.container.client.options.defaultPrefix;
1211
return message.channel.send(prefix ? `My prefix in this guild is: \`${prefix}\`` : 'Cannot find any Prefix for Message Commands.');

yarn.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,9 +2421,9 @@ __metadata:
24212421
languageName: node
24222422
linkType: hard
24232423

2424-
"discord.js@npm:^14.16.1":
2425-
version: 14.16.1
2426-
resolution: "discord.js@npm:14.16.1"
2424+
"discord.js@npm:^14.16.2":
2425+
version: 14.16.2
2426+
resolution: "discord.js@npm:14.16.2"
24272427
dependencies:
24282428
"@discordjs/builders": "npm:^1.9.0"
24292429
"@discordjs/collection": "npm:1.5.3"
@@ -2437,7 +2437,7 @@ __metadata:
24372437
lodash.snakecase: "npm:4.1.1"
24382438
tslib: "npm:^2.6.3"
24392439
undici: "npm:6.19.8"
2440-
checksum: 10/e75d0f8dd1a8e9aae313e016ba88d0c4b75dfe502663b08edae94cc99936f634e5647022bae71f517b6233d44af2a8bd4cabbe53db398e954116178b196030c4
2440+
checksum: 10/9da5621e88734b3cc8236de492c4fb6b78ee8c0a9a751472aa221234f66cf741f0947e81eb1842dd5ba711b95228593855a9f16453b4786455f3cb7c7cd1c381
24412441
languageName: node
24422442
linkType: hard
24432443

@@ -6212,7 +6212,7 @@ __metadata:
62126212
"@sapphire/time-utilities": "npm:^1.7.12"
62136213
"@sapphire/type": "npm:^2.5.1"
62146214
"@sapphire/utilities": "npm:^3.17.0"
6215-
discord.js: "npm:^14.16.1"
6215+
discord.js: "npm:^14.16.2"
62166216
nodemon: "npm:^3.0.3"
62176217
npm-run-all2: "npm:^6.1.1"
62186218
prettier: "npm:^3.2.4"
@@ -6236,7 +6236,7 @@ __metadata:
62366236
"@sapphire/time-utilities": "npm:^1.7.12"
62376237
"@sapphire/type": "npm:^2.5.1"
62386238
"@sapphire/utilities": "npm:^3.17.0"
6239-
discord.js: "npm:^14.16.1"
6239+
discord.js: "npm:^14.16.2"
62406240
nodemon: "npm:^3.0.3"
62416241
npm-run-all2: "npm:^6.1.1"
62426242
prettier: "npm:^3.2.4"
@@ -6267,7 +6267,7 @@ __metadata:
62676267
"@swc/core": "npm:^1.3.106"
62686268
"@types/node": "npm:^20.11.5"
62696269
"@types/ws": "npm:^8.5.10"
6270-
discord.js: "npm:^14.16.1"
6270+
discord.js: "npm:^14.16.2"
62716271
npm-run-all2: "npm:^6.1.1"
62726272
prettier: "npm:^3.2.4"
62736273
tsc-watch: "npm:^6.0.4"
@@ -6297,7 +6297,7 @@ __metadata:
62976297
"@skyra/env-utilities": "npm:^1.3.0"
62986298
"@types/node": "npm:^20.11.5"
62996299
"@types/ws": "npm:^8.5.10"
6300-
discord.js: "npm:^14.16.1"
6300+
discord.js: "npm:^14.16.2"
63016301
npm-run-all2: "npm:^6.1.1"
63026302
prettier: "npm:^3.2.4"
63036303
tsup: "npm:^8.0.1"
@@ -6328,7 +6328,7 @@ __metadata:
63286328
"@types/node": "npm:^20.11.5"
63296329
"@types/ws": "npm:^8.5.10"
63306330
colorette: "npm:^2.0.20"
6331-
discord.js: "npm:^14.16.1"
6331+
discord.js: "npm:^14.16.2"
63326332
npm-run-all2: "npm:^6.1.1"
63336333
prettier: "npm:^3.2.4"
63346334
tsc-watch: "npm:^6.0.4"
@@ -6352,7 +6352,7 @@ __metadata:
63526352
"@types/node": "npm:^20.11.5"
63536353
"@types/ws": "npm:^8.5.10"
63546354
colorette: "npm:^2.0.20"
6355-
discord.js: "npm:^14.16.1"
6355+
discord.js: "npm:^14.16.2"
63566356
prettier: "npm:^3.2.4"
63576357
tsc-watch: "npm:^6.0.4"
63586358
typescript: "npm:~5.4.5"

0 commit comments

Comments
 (0)