1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 20:30:58 -05:00

Compare commits

..

3 Commits

Author SHA1 Message Date
AnxietyisReal
282c833b8f Fix automod preventing autoresponses from responding to non-staff 2024-01-21 00:14:28 +11:00
AnxietyisReal
3c8e5355ac Update dependencies 2024-01-20 23:16:46 +11:00
AnxietyisReal
de5fec7079 Improvements 2024-01-20 23:13:18 +11:00
7 changed files with 44 additions and 74 deletions

38
.pnp.cjs generated
View File

@ -30,7 +30,7 @@ const RAW_RUNTIME_STATE =
["@octokit/rest", "npm:20.0.2"],\ ["@octokit/rest", "npm:20.0.2"],\
["@toast/tokenservice-client", "npm:1.0.6::__archiveUrl=https%3A%2F%2Fgit.toast-server.net%2Fapi%2Fpackages%2Ftoast%2Fnpm%2F%2540toast%252Ftokenservice-client%2F-%2F1.0.6%2Ftokenservice-client-1.0.6.tgz"],\ ["@toast/tokenservice-client", "npm:1.0.6::__archiveUrl=https%3A%2F%2Fgit.toast-server.net%2Fapi%2Fpackages%2Ftoast%2Fnpm%2F%2540toast%252Ftokenservice-client%2F-%2F1.0.6%2Ftokenservice-client-1.0.6.tgz"],\
["@types/ms", "npm:0.7.34"],\ ["@types/ms", "npm:0.7.34"],\
["@types/node", "npm:20.11.3"],\ ["@types/node", "npm:20.11.5"],\
["@types/node-cron", "npm:3.0.11"],\ ["@types/node-cron", "npm:3.0.11"],\
["@types/pg", "npm:8.10.9"],\ ["@types/pg", "npm:8.10.9"],\
["@types/sequelize", "npm:4.28.20"],\ ["@types/sequelize", "npm:4.28.20"],\
@ -46,9 +46,9 @@ const RAW_RUNTIME_STATE =
["redis", "npm:4.6.12"],\ ["redis", "npm:4.6.12"],\
["sequelize", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.35.2"],\ ["sequelize", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.35.2"],\
["simple-git", "npm:3.22.0"],\ ["simple-git", "npm:3.22.0"],\
["systeminformation", "npm:5.21.22"],\ ["systeminformation", "npm:5.21.23"],\
["typescript", "patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7"],\ ["typescript", "patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7"],\
["undici", "npm:6.3.0"]\ ["undici", "npm:6.4.0"]\
],\ ],\
"linkType": "SOFT"\ "linkType": "SOFT"\
}]\ }]\
@ -603,7 +603,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/@types-continuation-local-storage-npm-3.2.7-763e4dc12b-1f272b53bc.zip/node_modules/@types/continuation-local-storage/",\ "packageLocation": "./.yarn/cache/@types-continuation-local-storage-npm-3.2.7-763e4dc12b-1f272b53bc.zip/node_modules/@types/continuation-local-storage/",\
"packageDependencies": [\ "packageDependencies": [\
["@types/continuation-local-storage", "npm:3.2.7"],\ ["@types/continuation-local-storage", "npm:3.2.7"],\
["@types/node", "npm:20.11.3"]\ ["@types/node", "npm:20.11.5"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
@ -637,10 +637,10 @@ const RAW_RUNTIME_STATE =
}]\ }]\
]],\ ]],\
["@types/node", [\ ["@types/node", [\
["npm:20.11.3", {\ ["npm:20.11.5", {\
"packageLocation": "./.yarn/cache/@types-node-npm-20.11.3-78cf05078e-dff6433343.zip/node_modules/@types/node/",\ "packageLocation": "./.yarn/cache/@types-node-npm-20.11.5-b807d46a1a-9f31c47104.zip/node_modules/@types/node/",\
"packageDependencies": [\ "packageDependencies": [\
["@types/node", "npm:20.11.3"],\ ["@types/node", "npm:20.11.5"],\
["undici-types", "npm:5.26.5"]\ ["undici-types", "npm:5.26.5"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
@ -660,7 +660,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/@types-pg-npm-8.10.9-ee8620c8e7-787be5431a.zip/node_modules/@types/pg/",\ "packageLocation": "./.yarn/cache/@types-pg-npm-8.10.9-ee8620c8e7-787be5431a.zip/node_modules/@types/pg/",\
"packageDependencies": [\ "packageDependencies": [\
["@types/pg", "npm:8.10.9"],\ ["@types/pg", "npm:8.10.9"],\
["@types/node", "npm:20.11.3"],\ ["@types/node", "npm:20.11.5"],\
["pg-protocol", "npm:1.6.0"],\ ["pg-protocol", "npm:1.6.0"],\
["pg-types", "npm:4.0.1"]\ ["pg-types", "npm:4.0.1"]\
],\ ],\
@ -694,7 +694,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/@types-ws-npm-8.5.9-91d1b2ab07-7cf66383b8.zip/node_modules/@types/ws/",\ "packageLocation": "./.yarn/cache/@types-ws-npm-8.5.9-91d1b2ab07-7cf66383b8.zip/node_modules/@types/ws/",\
"packageDependencies": [\ "packageDependencies": [\
["@types/ws", "npm:8.5.9"],\ ["@types/ws", "npm:8.5.9"],\
["@types/node", "npm:20.11.3"]\ ["@types/node", "npm:20.11.5"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
@ -995,7 +995,7 @@ const RAW_RUNTIME_STATE =
["@octokit/rest", "npm:20.0.2"],\ ["@octokit/rest", "npm:20.0.2"],\
["@toast/tokenservice-client", "npm:1.0.6::__archiveUrl=https%3A%2F%2Fgit.toast-server.net%2Fapi%2Fpackages%2Ftoast%2Fnpm%2F%2540toast%252Ftokenservice-client%2F-%2F1.0.6%2Ftokenservice-client-1.0.6.tgz"],\ ["@toast/tokenservice-client", "npm:1.0.6::__archiveUrl=https%3A%2F%2Fgit.toast-server.net%2Fapi%2Fpackages%2Ftoast%2Fnpm%2F%2540toast%252Ftokenservice-client%2F-%2F1.0.6%2Ftokenservice-client-1.0.6.tgz"],\
["@types/ms", "npm:0.7.34"],\ ["@types/ms", "npm:0.7.34"],\
["@types/node", "npm:20.11.3"],\ ["@types/node", "npm:20.11.5"],\
["@types/node-cron", "npm:3.0.11"],\ ["@types/node-cron", "npm:3.0.11"],\
["@types/pg", "npm:8.10.9"],\ ["@types/pg", "npm:8.10.9"],\
["@types/sequelize", "npm:4.28.20"],\ ["@types/sequelize", "npm:4.28.20"],\
@ -1011,9 +1011,9 @@ const RAW_RUNTIME_STATE =
["redis", "npm:4.6.12"],\ ["redis", "npm:4.6.12"],\
["sequelize", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.35.2"],\ ["sequelize", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.35.2"],\
["simple-git", "npm:3.22.0"],\ ["simple-git", "npm:3.22.0"],\
["systeminformation", "npm:5.21.22"],\ ["systeminformation", "npm:5.21.23"],\
["typescript", "patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7"],\ ["typescript", "patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7"],\
["undici", "npm:6.3.0"]\ ["undici", "npm:6.4.0"]\
],\ ],\
"linkType": "SOFT"\ "linkType": "SOFT"\
}]\ }]\
@ -2520,10 +2520,10 @@ const RAW_RUNTIME_STATE =
}]\ }]\
]],\ ]],\
["systeminformation", [\ ["systeminformation", [\
["npm:5.21.22", {\ ["npm:5.21.23", {\
"packageLocation": "./.yarn/unplugged/systeminformation-npm-5.21.22-d3fd9f8974/node_modules/systeminformation/",\ "packageLocation": "./.yarn/unplugged/systeminformation-npm-5.21.23-f0c4f32b3c/node_modules/systeminformation/",\
"packageDependencies": [\ "packageDependencies": [\
["systeminformation", "npm:5.21.22"]\ ["systeminformation", "npm:5.21.23"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
@ -2614,10 +2614,10 @@ const RAW_RUNTIME_STATE =
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}],\ }],\
["npm:6.3.0", {\ ["npm:6.4.0", {\
"packageLocation": "./.yarn/cache/undici-npm-6.3.0-3653a9b474-4534474384.zip/node_modules/undici/",\ "packageLocation": "./.yarn/cache/undici-npm-6.4.0-3c1375c132-65552916aa.zip/node_modules/undici/",\
"packageDependencies": [\ "packageDependencies": [\
["undici", "npm:6.3.0"],\ ["undici", "npm:6.4.0"],\
["@fastify/busboy", "npm:2.0.0"]\ ["@fastify/busboy", "npm:2.0.0"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
@ -2733,7 +2733,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/wkx-npm-0.5.0-fca5152cd8-b8975e33f9.zip/node_modules/wkx/",\ "packageLocation": "./.yarn/cache/wkx-npm-0.5.0-fca5152cd8-b8975e33f9.zip/node_modules/wkx/",\
"packageDependencies": [\ "packageDependencies": [\
["wkx", "npm:0.5.0"],\ ["wkx", "npm:0.5.0"],\
["@types/node", "npm:20.11.3"]\ ["@types/node", "npm:20.11.5"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\

View File

@ -47,12 +47,12 @@
"redis": "4.6.12", "redis": "4.6.12",
"sequelize": "6.35.2", "sequelize": "6.35.2",
"simple-git": "3.22.0", "simple-git": "3.22.0",
"systeminformation": "5.21.22", "systeminformation": "5.21.23",
"undici": "6.3.0" "undici": "6.4.0"
}, },
"devDependencies": { "devDependencies": {
"@types/ms": "0.7.34", "@types/ms": "0.7.34",
"@types/node": "20.11.3", "@types/node": "20.11.5",
"@types/node-cron": "3.0.11", "@types/node-cron": "3.0.11",
"@types/pg": "8.10.9", "@types/pg": "8.10.9",
"@types/sequelize": "4.28.20", "@types/sequelize": "4.28.20",

View File

@ -6,7 +6,7 @@ import Formatters from '../helpers/Formatters.js';
import GitHub from '../helpers/GitHub.js'; import GitHub from '../helpers/GitHub.js';
import TClient from '../client.js'; import TClient from '../client.js';
import util from 'node:util'; import util from 'node:util';
import fs from 'node:fs'; import fs, { writeFileSync } from 'node:fs';
export default class Developer { export default class Developer {
static run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>) { static run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>) {
if (!client.config.whitelist.includes(interaction.user.id)) return MessageTool.youNeedRole(interaction, 'bottech'); if (!client.config.whitelist.includes(interaction.user.id)) return MessageTool.youNeedRole(interaction, 'bottech');
@ -102,6 +102,7 @@ export default class Developer {
if (name) currentActivities[0].name = name; if (name) currentActivities[0].name = name;
if (url) currentActivities[0].url = url; if (url) currentActivities[0].url = url;
client.user.setPresence(client.config.botPresence); client.user.setPresence(client.config.botPresence);
writeFileSync(process.argv[2] ?? 'src/config.json', JSON.stringify(client.config, null, 2));
interaction.reply(MessageTool.concatMessage( interaction.reply(MessageTool.concatMessage(
'Presence updated:', 'Presence updated:',
`Status: **${client.config.botPresence.status}**`, `Status: **${client.config.botPresence.status}**`,
@ -157,7 +158,7 @@ export default class Developer {
.setRequired(false))) .setRequired(false)))
.addSubcommand(x=>x .addSubcommand(x=>x
.setName('restart') .setName('restart')
.setDescription('Restart the bot for technical reasons')) .setDescription('Restart the bot for manual changes/technical difficulties'))
.addSubcommand(x=>x .addSubcommand(x=>x
.setName('update') .setName('update')
.setDescription('Pull from repository and restart') .setDescription('Pull from repository and restart')

View File

@ -47,13 +47,6 @@ export default class ProhibitedWords {
] ]
}); });
} }
},
import: async()=>{
const file = interaction.options.getAttachment('file', true);
if (!file.contentType.match(/application\/json/)) return interaction.reply({ephemeral: true, content: 'This file is not a JSON file!'});
const success = await client.prohibitedWords.importWords(file.url);
if (success) interaction.reply({ephemeral: true, content: `Successfully imported the list from \`${file.name}\` into the database`});
else interaction.reply({ephemeral: true, content: `Failed to import the list from \`${file.name}\` into the database`});
} }
} as any)[interaction.options.getSubcommand()](); } as any)[interaction.options.getSubcommand()]();
} }
@ -80,11 +73,4 @@ export default class ProhibitedWords {
.setName('word') .setName('word')
.setDescription('Remove the specific word from automod\'s prohibitedWords database') .setDescription('Remove the specific word from automod\'s prohibitedWords database')
.setRequired(true))) .setRequired(true)))
.addSubcommand(x=>x
.setName('import')
.setDescription('Import a JSON file of words into the database')
.addAttachmentOption(x=>x
.setName('file')
.setDescription('The JSON file to import')
.setRequired(true)))
} }

View File

@ -50,7 +50,10 @@ export default class MessageCreate {
}; };
for (const rule of Object.values(automodRules)) { for (const rule of Object.values(automodRules)) {
if (await rule.check()) await rule.action(); if (!automodded && await rule.check()) {
await rule.action();
break;
}
} }
}; };
if (message.guildId === client.config.dcServer.id && !automodded) client.userLevels.messageIncremental(message.author.id); if (message.guildId === client.config.dcServer.id && !automodded) client.userLevels.messageIncremental(message.author.id);

View File

@ -1,6 +1,5 @@
import DatabaseServer from '../components/DatabaseServer.js'; import DatabaseServer from '../components/DatabaseServer.js';
import {Model, DataTypes} from 'sequelize'; import {Model, DataTypes} from 'sequelize';
import {get} from 'node:https';
class prohibitedWords extends Model { class prohibitedWords extends Model {
declare public word: string; declare public word: string;
@ -27,25 +26,6 @@ export class ProhibitedWordsSvc {
this.model.sync(); this.model.sync();
} }
findWord = async(word:string)=>await this.model.findByPk(word); findWord = async(word:string)=>await this.model.findByPk(word);
async importWords(file:string) {
const jsonData = await new Promise<string>((resolve, reject)=>{
get(file, res=>{
let data = '';
res.on('data', chunk=>data += chunk);
res.on('end', ()=>resolve(data));
res.on('error', reject);
})
});
const data = JSON.parse(jsonData);
const dataMapping = data.map((x:string)=>({word: x}));
try {
await this.model.bulkCreate(dataMapping, {ignoreDuplicates: true});
return true;
} catch(err) {
throw new Error(`Failed to insert words into Postgres database: ${err.message}`)
}
}
getAllWords = async()=>await this.model.findAll(); getAllWords = async()=>await this.model.findAll();
insertWord = async(word:string)=>await this.model.create({word: word}); insertWord = async(word:string)=>await this.model.create({word: word});
removeWord = async(word:string)=>await this.model.destroy({where: {word: word}}) removeWord = async(word:string)=>await this.model.destroy({where: {word: word}})

View File

@ -441,12 +441,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:*, @types/node@npm:20.11.3": "@types/node@npm:*, @types/node@npm:20.11.5":
version: 20.11.3 version: 20.11.5
resolution: "@types/node@npm:20.11.3" resolution: "@types/node@npm:20.11.5"
dependencies: dependencies:
undici-types: "npm:~5.26.4" undici-types: "npm:~5.26.4"
checksum: dff64333435bbda87e200e24e2103f40692d0a01849db685ecb31db7c589f2556843a03dd351ddaee9981020263939c026557b36df49154efd910c610deefe78 checksum: 9f31c471047d7b3e240ce7b77ff29b0d15e83be7e3feafb3d0b0d0931122b438b1eefa302a5a2e1e9849914ff3fd76aafbd8ccb372efb1331ba048da63bce6f8
languageName: node languageName: node
linkType: hard linkType: hard
@ -748,7 +748,7 @@ __metadata:
"@octokit/rest": "npm:20.0.2" "@octokit/rest": "npm:20.0.2"
"@toast/tokenservice-client": "npm:1.0.6" "@toast/tokenservice-client": "npm:1.0.6"
"@types/ms": "npm:0.7.34" "@types/ms": "npm:0.7.34"
"@types/node": "npm:20.11.3" "@types/node": "npm:20.11.5"
"@types/node-cron": "npm:3.0.11" "@types/node-cron": "npm:3.0.11"
"@types/pg": "npm:8.10.9" "@types/pg": "npm:8.10.9"
"@types/sequelize": "npm:4.28.20" "@types/sequelize": "npm:4.28.20"
@ -764,9 +764,9 @@ __metadata:
redis: "npm:4.6.12" redis: "npm:4.6.12"
sequelize: "npm:6.35.2" sequelize: "npm:6.35.2"
simple-git: "npm:3.22.0" simple-git: "npm:3.22.0"
systeminformation: "npm:5.21.22" systeminformation: "npm:5.21.23"
typescript: "npm:5.3.3" typescript: "npm:5.3.3"
undici: "npm:6.3.0" undici: "npm:6.4.0"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@ -2065,12 +2065,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"systeminformation@npm:5.21.22": "systeminformation@npm:5.21.23":
version: 5.21.22 version: 5.21.23
resolution: "systeminformation@npm:5.21.22" resolution: "systeminformation@npm:5.21.23"
bin: bin:
systeminformation: lib/cli.js systeminformation: lib/cli.js
checksum: 333c733adb1ff89d27146e4e727dee62ba7f53e88150bcf5c533d86f9dbbf8d598dbddc295816794eb991b88a2ae3b0d04ffff22d2ebdd8ddecddfd66734a373 checksum: b2084429c552e9600795c01620ed94c0289e3214bb0501b2d265b84c3682e2ad969fb3eb3914726d05be62dbd073138cfdb65a49b3bf335cebd15f5740be89c5
conditions: (os=darwin | os=linux | os=win32 | os=freebsd | os=openbsd | os=netbsd | os=sunos | os=android) conditions: (os=darwin | os=linux | os=win32 | os=freebsd | os=openbsd | os=netbsd | os=sunos | os=android)
languageName: node languageName: node
linkType: hard linkType: hard
@ -2169,12 +2169,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"undici@npm:6.3.0": "undici@npm:6.4.0":
version: 6.3.0 version: 6.4.0
resolution: "undici@npm:6.3.0" resolution: "undici@npm:6.4.0"
dependencies: dependencies:
"@fastify/busboy": "npm:^2.0.0" "@fastify/busboy": "npm:^2.0.0"
checksum: 4534474384267ea2818b23a61daa6d851895e9caa9998be0bd71687322f7fbad653ffbaba084bc9d75f41ae2ac1c27adab65d631837890e26a2a52a8e0408ec4 checksum: 65552916aa84eb8ea262cf7205bf2dc1ca86b616843adceb6d994a172a5a6be7fbf384ab790e7ede82811942f0c71a53e639309e92e05be044866ca54993e0be
languageName: node languageName: node
linkType: hard linkType: hard