Skip to content

Commit

Permalink
support module
Browse files Browse the repository at this point in the history
  • Loading branch information
lleyton committed Oct 28, 2024
1 parent 4a057f9 commit 5808922
Show file tree
Hide file tree
Showing 7 changed files with 543 additions and 746 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ANNOUNCEMENTS_CHANNEL_ID=
UPDATES_CHANNEL_ID=
GENERAL_CHANNEL_ID=
MEMBER_ROLE_ID=
SUPPORT_FORUM_ID=
HEALTH_PORT=8080
REDIS_HOST=
REDIS_PORT=
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
},
"dependencies": {
"@prisma/client": "^5.21.1",
"bullmq": "^5.21.1",
"bullmq": "^5.21.2",
"cat-loggr": "^1.2.2",
"dayjs": "^1.11.13",
"discord-api-types": "^0.37.102",
"discord-api-types": "^0.37.103",
"discord.js": "^14.16.3",
"dotenv": "^16.4.5",
"fastify": "^4.28.1",
"fastify": "^5.0.0",
"parse-duration": "^1.1.0",
"slash-create": "^6.3.0"
},
"devDependencies": {
"@types/express": "^5.0.0",
"@types/node": "^22.7.7",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^6.21.0",
"eslint": "^8.57.0",
"@types/node": "^22.8.1",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"@typescript-eslint/parser": "^8.11.0",
"eslint": "^9.13.0",
"eslint-config-dmitmel": "github:dmitmel/eslint-config-dmitmel",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.2.1",
Expand Down
1,230 changes: 495 additions & 735 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/commands/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const generateFinalReport = async (): Promise<void> => {

const announcementsChannel = await getAnnoucementsChannel();

if (!announcementsChannel.isTextBased()) {
if (!announcementsChannel.isSendable()) {
throw new Error('Announcements channel is not a text channel.');
}

Expand Down Expand Up @@ -289,7 +289,7 @@ export default class Progress extends SlashCommand {

const updatesChannel = await getUpdatesChannel();

if (!updatesChannel.isTextBased()) {
if (!updatesChannel.isSendable()) {
throw new Error('Updates channel is not a text channel.');
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/guildMemberAdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getGeneralChannel } from '../util';
client.on(Events.GuildMemberAdd, async (member) => {
const generalChannel = await getGeneralChannel();

if (!generalChannel.isTextBased()) {
if (!generalChannel.isSendable()) {
throw new Error('General channel is not a text channel.');
}

Expand Down
36 changes: 36 additions & 0 deletions src/modules/support.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import client from '../client';
import { ChannelType, Events } from 'discord.js';

const cannedResponses = new Map([
[
'Ultramarine Linux',
`Hewwo! If you haven't already, please make sure to provide the following:
* Version and edition of Ultramrine (ex. Ultramarine 40 KDE)
* Any relavant hardware details, especially if using a port of Ultramarine (ex. Chromebooks)
* Age of the install (ex. 1 week old)
* Any recent changes made to the system (ex. updates, new software, etc.)
* Any error messages you're seeing
* Any steps you've already taken to try and resolve the issue
* Any other relevant information
This will help us help you faster! :3`,
],
]);

client.on(Events.ThreadCreate, async (thread) => {
if (
!(
thread.parent?.type === ChannelType.GuildForum &&
thread.parent.id === process.env.SUPPORT_FORUM_ID!
)
) {
return;
}

const entry = Array.from(cannedResponses.entries()).find(([tag]) =>
thread.appliedTags.includes(tag),
);
if (!entry) return;

await thread.send(entry[1]);
});
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ export const getRedisConnection = (): ConnectionOptions => ({
export const containsWord = (msg: Message, word: string): boolean => {
const matches = msg.content.match(new RegExp(`\\b${word}\\b`, 'i'));
return matches != null && matches.length > 0;
};
};

0 comments on commit 5808922

Please sign in to comment.