aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/message
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-23 18:13:05 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-23 18:13:05 -0500
commita3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a (patch)
tree9b0f8ed8a93c22c90512751e3f2f5937e1925760 /src/listeners/message
parent5557677f1570eb564a30cfcebb6030235dc84d47 (diff)
downloadtanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.tar.gz
tanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.tar.bz2
tanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.zip
fix discord.js breaking changes, some other stuff
Diffstat (limited to 'src/listeners/message')
-rw-r--r--src/listeners/message/autoPublisher.ts2
-rw-r--r--src/listeners/message/autoThread.ts7
-rw-r--r--src/listeners/message/blacklistedFile.ts5
-rw-r--r--src/listeners/message/boosterMessage.ts3
-rw-r--r--src/listeners/message/directMessage.ts8
-rw-r--r--src/listeners/message/level.ts6
-rw-r--r--src/listeners/message/verbose.ts3
7 files changed, 19 insertions, 15 deletions
diff --git a/src/listeners/message/autoPublisher.ts b/src/listeners/message/autoPublisher.ts
index af75ea3..b074fda 100644
--- a/src/listeners/message/autoPublisher.ts
+++ b/src/listeners/message/autoPublisher.ts
@@ -13,7 +13,7 @@ export default class autoPublisherListener extends BushListener {
if (!message.guild || !(await message.guild.hasFeature('autoPublish'))) return;
const autoPublishChannels = await message.guild.getSetting('autoPublishChannels');
if (autoPublishChannels) {
- if (message.channel.type === 'GUILD_NEWS' && autoPublishChannels.some((x) => message.channel.id.includes(x))) {
+ if (message.channel.isNews() && autoPublishChannels.some((x) => message.channel.id.includes(x))) {
await message
.crosspost()
.then(
diff --git a/src/listeners/message/autoThread.ts b/src/listeners/message/autoThread.ts
index 6ee19ed..77ff33c 100644
--- a/src/listeners/message/autoThread.ts
+++ b/src/listeners/message/autoThread.ts
@@ -1,5 +1,5 @@
import { BushListener, type BushClientEvents, type BushTextChannel } from '#lib';
-import { GuildTextBasedChannel, MessageEmbed } from 'discord.js';
+import { GuildTextBasedChannel, MessageEmbed, MessageType, Permissions } from 'discord.js';
export default class autoThreadListener extends BushListener {
public constructor() {
@@ -13,7 +13,7 @@ export default class autoThreadListener extends BushListener {
public override async exec(...[message]: BushClientEvents['messageCreate']): Promise<Promise<void> | undefined> {
if (!client.config.isProduction) return;
if (!message.guild || !message.channel) return;
- if (!['DEFAULT', 'REPLY'].includes(message.type)) return;
+ if (![MessageType.Default, MessageType.Reply].includes(message.type)) return;
if (
message.author.bot &&
message.author.id === '444871677176709141' && //fire
@@ -35,7 +35,8 @@ export default class autoThreadListener extends BushListener {
// todo: make these configurable etc...
if (message.guild.id !== '516977525906341928') return; // mb
if (message.channel.id !== '714332750156660756') return; // neu-support-1
- if (!(message.channel as BushTextChannel).permissionsFor(message.guild.me!).has('CREATE_PUBLIC_THREADS')) return;
+ if (!(message.channel as BushTextChannel).permissionsFor(message.guild.me!).has(Permissions.FLAGS.CREATE_PUBLIC_THREADS))
+ return;
const thread = await message
.startThread({
name: `Support - ${message.author.username}#${message.author.discriminator}`,
diff --git a/src/listeners/message/blacklistedFile.ts b/src/listeners/message/blacklistedFile.ts
index 5b01218..9d52ab0 100644
--- a/src/listeners/message/blacklistedFile.ts
+++ b/src/listeners/message/blacklistedFile.ts
@@ -1,5 +1,6 @@
import { BushListener, type BushClientEvents } from '#lib';
import * as crypto from 'crypto';
+import { ChannelType } from 'discord.js';
import got from 'got';
export default class BlacklistedFileListener extends BushListener {
@@ -131,7 +132,7 @@ export default class BlacklistedFileListener extends BushListener {
await message.util.send(
`<@!${message.author.id}>, please do not send ${foundFiles.map((f) => f.description).join(' or ')}.`
);
- if (message.channel.type === 'DM') return;
+ if (message.channel.type === ChannelType.DM) return;
void client.console.info(
'blacklistedFile',
`Deleted <<${foundFiles.map((f) => f.description).join(' and ')}>> sent by <<${message.author.tag}>> in ${
@@ -145,7 +146,7 @@ export default class BlacklistedFileListener extends BushListener {
void client.console.warn(
'blacklistedFile',
`Failed to delete <<${foundFiles.map((f) => f.description).join(' and ')}>> sent by <<${message.author.tag}>> in <<${
- message.channel.type === 'DM' ? `${message.channel.recipient.tag}'s DMs` : message.channel.name
+ message.channel.type === ChannelType.DM ? `${message.channel.recipient.tag}'s DMs` : message.channel.name
}>>.`
);
}
diff --git a/src/listeners/message/boosterMessage.ts b/src/listeners/message/boosterMessage.ts
index 0ebe393..989f671 100644
--- a/src/listeners/message/boosterMessage.ts
+++ b/src/listeners/message/boosterMessage.ts
@@ -1,4 +1,5 @@
import { BushListener, type BushClientEvents } from '#lib';
+import { MessageType } from 'discord.js';
export default class BoosterMessageListener extends BushListener {
public constructor() {
@@ -11,7 +12,7 @@ export default class BoosterMessageListener extends BushListener {
public override async exec(...[message]: BushClientEvents['messageCreate']) {
if (!message.guild || !(await message.guild?.hasFeature('boosterMessageReact'))) return;
- if (message.type === 'USER_PREMIUM_GUILD_SUBSCRIPTION') {
+ if (message.type === MessageType.UserPremiumGuildSubscription) {
return await message.react('<:nitroboost:785160348885975062>').catch(() => {
void client.console.warn('boosterMessage', `Failed to react to <<${message.id}>>.`);
});
diff --git a/src/listeners/message/directMessage.ts b/src/listeners/message/directMessage.ts
index 39d203c..dfc9222 100644
--- a/src/listeners/message/directMessage.ts
+++ b/src/listeners/message/directMessage.ts
@@ -1,5 +1,5 @@
import { BushListener, type BushClientEvents } from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { ChannelType, MessageEmbed } from 'discord.js';
export default class DirectMessageListener extends BushListener {
public constructor() {
@@ -11,7 +11,7 @@ export default class DirectMessageListener extends BushListener {
}
public override async exec(...[message]: BushClientEvents['messageCreate']) {
- if (message.channel.type === 'DM') {
+ if (message.channel.type === ChannelType.DM) {
if (!(message.author.id == client.user!.id) && message.author.bot) return;
if (client.cache.global.blacklistedUsers.includes(message.author.id)) return;
const dmLogEmbed = new MessageEmbed().setTimestamp().setFooter({ text: `User ID • ${message.channel.recipient.id}` });
@@ -20,7 +20,7 @@ export default class DirectMessageListener extends BushListener {
dmLogEmbed
.setAuthor({
name: `From: ${message.author.username}`,
- iconURL: `${message.author.displayAvatarURL({ dynamic: true })}`
+ iconURL: `${message.author.displayAvatarURL()}`
})
.setDescription(`**DM:**\n${message}`)
.setColor(util.colors.blue);
@@ -28,7 +28,7 @@ export default class DirectMessageListener extends BushListener {
dmLogEmbed
.setAuthor({
name: `To: ${message.channel.recipient.username}`,
- iconURL: `${message.channel.recipient.displayAvatarURL({ dynamic: true })}`
+ iconURL: `${message.channel.recipient.displayAvatarURL()}`
})
.setDescription(`**DM:**\n${message}`)
.setColor(util.colors.red)
diff --git a/src/listeners/message/level.ts b/src/listeners/message/level.ts
index bce4614..c16e811 100644
--- a/src/listeners/message/level.ts
+++ b/src/listeners/message/level.ts
@@ -1,5 +1,5 @@
import { BushListener, Level, type BushCommandHandlerEvents, type BushGuild, type BushMessage } from '#lib';
-import { type MessageType } from 'discord.js';
+import { MessageType } from 'discord.js';
export default class LevelListener extends BushListener {
#levelCooldowns: Set<string> = new Set();
@@ -10,13 +10,13 @@ export default class LevelListener extends BushListener {
category: 'message'
});
}
+
public override async exec(...[message]: BushCommandHandlerEvents['messageInvalid']) {
if (message.author.bot || !message.author || !message.guild || !message.guildId) return;
if (this.#levelCooldowns.has(`${message.guildId}-${message.author.id}`)) return;
if ((await message.guild.getSetting('noXpChannels')).includes(message.channel.id)) return;
- const allowedMessageTypes: MessageType[] = ['DEFAULT', 'REPLY']; // this is so ts will yell at me when discord.js makes some unnecessary breaking change
- if (!allowedMessageTypes.includes(message.type)) return; //checks for join messages, slash commands, booster messages etc
+ if (message.type !== MessageType.Default && message.type !== MessageType.Reply) return; //checks for join messages, slash commands, booster messages etc
const [user] = await Level.findOrBuild({
where: {
user: message.author.id,
diff --git a/src/listeners/message/verbose.ts b/src/listeners/message/verbose.ts
index cf5a698..1225412 100644
--- a/src/listeners/message/verbose.ts
+++ b/src/listeners/message/verbose.ts
@@ -1,4 +1,5 @@
import { BushListener, type BushClientEvents } from '#lib';
+import { ChannelType } from 'discord.js';
export default class MessageVerboseListener extends BushListener {
public constructor() {
@@ -11,7 +12,7 @@ export default class MessageVerboseListener extends BushListener {
public override exec(...[message]: BushClientEvents['messageCreate']): void {
if (client.customReady) {
- if (message.channel?.type === 'DM') return;
+ if (message.channel?.type === ChannelType.DM) return;
void client.console.verbose(
'messageVerbose',
`A message was sent by <<${message.author.tag}>> in <<${message.channel.name}>> in <<${message.guild!.name}>>.`