1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
import { BotListener, colors, Emitter, mappings, type BotClientEvents } from '#lib';
import { stripIndent } from '#tags';
import assert from 'assert/strict';
import { EmbedBuilder, Events, MessageType, PermissionFlagsBits, TextChannel } from 'discord.js';
export default class SupportThreadListener extends BotListener {
public constructor() {
super('supportThread', {
emitter: Emitter.Client,
event: Events.MessageCreate
});
}
public async exec(...[message]: BotClientEvents[Events.MessageCreate]): Promise<void | undefined> {
if (!this.client.config.isProduction || !message.inGuild()) return;
if (![MessageType.Default, MessageType.Reply].includes(message.type)) return;
if (message.thread) return;
if (message.author.bot && (message.author.id !== '444871677176709141' || !message.content.includes('uploaded a log,')))
return;
if (message.guild.id !== mappings.guilds["Moulberry's Bush"]) return; // mb
if (message.channel.id !== mappings.channels['neu-support']) return;
if (
[await message.guild.getSetting('prefix'), `<@!${this.client.user!.id}>`, `<@${this.client.user!.id}>`].some((v) =>
message.content.trim().startsWith(v)
) &&
this.client.commandHandler.aliases.some((alias) => message.content.includes(alias))
)
return;
assert(message.channel instanceof TextChannel);
if (!message.channel.permissionsFor(message.guild.members.me!).has(PermissionFlagsBits.CreatePublicThreads)) return;
const thread = await message
.startThread({
name: `Support - ${message.author.username}#${message.author.discriminator}`,
autoArchiveDuration: 60,
reason: 'Support Thread'
})
.catch(() => null);
if (!thread) return;
const embed = new EmbedBuilder()
.setTitle('NotEnoughUpdates Support')
.setDescription(
stripIndent`
Welcome to Moulberry Bush Support:tm:
Please make sure you have the latest version found in <#693586404256645231>.
Additionally if you need help installing the mod be sure to read <#737444942724726915> for a guide on how to do so.`
)
.setColor(colors.Blurple);
void thread
.send({ embeds: [embed] })
.then(() =>
this.client.console.info(
'supportThread',
`opened a support thread for <<${message.author.tag}>> in <<${message.channel.name}>> in <<${message.guild!.name}>>.`
)
);
}
}
|