Skip to content

Commit

Permalink
Add utility for moderators to quickly resolve posts
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Jan 14, 2024
1 parent ca62880 commit aac152f
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 182 deletions.
3 changes: 2 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"token": "<token>",
"clientId": "<clientId>"
"clientId": "<clientId>",
"resolvedTag": "<forumTagSnowflake>"
}
4 changes: 2 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Client, GatewayIntentBits, ActivityType } from 'discord.js'

import config from './config.json'
import config from 'config.json'

import fs from 'fs'

Expand All @@ -26,7 +26,7 @@ const client = new Client({
})

client.on('ready', () => {
console.log(`Logged in as ${client.user?.tag}!`)
console.log(`Logged in as ${client.user?.tag ?? 'unknown'}!`)
})

fs.readdirSync('modules')
Expand Down
2 changes: 1 addition & 1 deletion modules/autoupload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const website = 'https://pastes.dev'
const api = 'https://api.pastes.dev'

// noinspection JSUnusedGlobalSymbols
export default (client: Client) => {
export default (client: Client): void => {
client.on('messageCreate', async message => {
if (!message.channel.isTextBased() || message.channel.isDMBased()) return

Expand Down
6 changes: 3 additions & 3 deletions modules/checks/checks.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const checksConfig: ChecksConfig = {
title: 'SkinsRestorerAPI is not initialized yet',
content: 'This error occurs when a third-party plugin tries to access SkinsRestorerAPI before SkinsRestorer is fully loaded. This is a bug in the third-party plugin, and should be reported to the plugin developer.',
tips: [
"Make sure SkinsRestorer is installed and enabled. There may have been a startup error that prevented SkinsRestorer from loading.",
'Make sure SkinsRestorer is installed and enabled. There may have been a startup error that prevented SkinsRestorer from loading.',
'Your plugin may be loading before SkinsRestorer. To load your plugin after SkinsRestorer, add `softdepend: [ "SkinsRestorer" ]` to your plugin.yml file.'
],
link: 'https://skinsrestorer.net/docs/development/api#add-skinsrestorer-as-a-dependency'
Expand All @@ -45,9 +45,9 @@ const checksConfig: ChecksConfig = {
title: 'Missing mapping in SkinsRestorer',
content: 'This error occurs when the current build does not support the current Minecraft version. Every new version of Minecraft requires a new mapping to be added to SkinsRestorer because of Spigot\'s obfuscation.',
tips: [
"Check announcements for updates for new versions of SkinsRestorer. If there is no update, please be patient.",
'Check announcements for updates for new versions of SkinsRestorer. If there is no update, please be patient.',
'If PaperMC has released a new version, try switching from Spigot to Paper. We recommend PaperMC over Spigot because we don\'t use mappings for Paper.'
],
]
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions modules/checks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default (client: Client): void => {

let response = ''
try {
console.log(`Getting upload bin ${getLink}`);
console.log(`Getting upload bin ${getLink}`)
response = (await (await fetch(getLink)).text())
} catch (e: any) {
if (e.response) {
Expand Down Expand Up @@ -96,20 +96,20 @@ function checkMatch (text: string, checks: RegExp[]) {

async function respondToText (message: Message, text: string, footer: string) {
for (const test of config.tests) {
let cause = checkMatch(text, test.checks)
const cause = checkMatch(text, test.checks)
if (cause == null) {
continue
}

const embed = new EmbedBuilder()
embed.setTitle(test.title)
embed.setDescription(test.content)
if (test.tips) {
if (test.tips != null) {
embed.addFields(test.tips.map((tip, i) => ({ name: `Tip #${i + 1}`, value: tip })))
}

if (test.link) {
embed.addFields({ name: 'Read More', value: test.link },)
embed.addFields({ name: 'Read More', value: test.link })
}

embed.addFields({ name: 'Caused By', value: `\`\`\`${cause}\`\`\`` })
Expand Down
Loading

0 comments on commit aac152f

Please sign in to comment.