1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 16: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"],\
["@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/node", "npm:20.11.3"],\
["@types/node", "npm:20.11.5"],\
["@types/node-cron", "npm:3.0.11"],\
["@types/pg", "npm:8.10.9"],\
["@types/sequelize", "npm:4.28.20"],\
@ -46,9 +46,9 @@ const RAW_RUNTIME_STATE =
["redis", "npm:4.6.12"],\
["sequelize", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.35.2"],\
["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"],\
["undici", "npm:6.3.0"]\
["undici", "npm:6.4.0"]\
],\
"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/",\
"packageDependencies": [\
["@types/continuation-local-storage", "npm:3.2.7"],\
["@types/node", "npm:20.11.3"]\
["@types/node", "npm:20.11.5"]\
],\
"linkType": "HARD"\
}]\
@ -637,10 +637,10 @@ const RAW_RUNTIME_STATE =
}]\
]],\
["@types/node", [\
["npm:20.11.3", {\
"packageLocation": "./.yarn/cache/@types-node-npm-20.11.3-78cf05078e-dff6433343.zip/node_modules/@types/node/",\
["npm:20.11.5", {\
"packageLocation": "./.yarn/cache/@types-node-npm-20.11.5-b807d46a1a-9f31c47104.zip/node_modules/@types/node/",\
"packageDependencies": [\
["@types/node", "npm:20.11.3"],\
["@types/node", "npm:20.11.5"],\
["undici-types", "npm:5.26.5"]\
],\
"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/",\
"packageDependencies": [\
["@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-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/",\
"packageDependencies": [\
["@types/ws", "npm:8.5.9"],\
["@types/node", "npm:20.11.3"]\
["@types/node", "npm:20.11.5"]\
],\
"linkType": "HARD"\
}]\
@ -995,7 +995,7 @@ const RAW_RUNTIME_STATE =
["@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"],\
["@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/pg", "npm:8.10.9"],\
["@types/sequelize", "npm:4.28.20"],\
@ -1011,9 +1011,9 @@ const RAW_RUNTIME_STATE =
["redis", "npm:4.6.12"],\
["sequelize", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.35.2"],\
["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"],\
["undici", "npm:6.3.0"]\
["undici", "npm:6.4.0"]\
],\
"linkType": "SOFT"\
}]\
@ -2520,10 +2520,10 @@ const RAW_RUNTIME_STATE =
}]\
]],\
["systeminformation", [\
["npm:5.21.22", {\
"packageLocation": "./.yarn/unplugged/systeminformation-npm-5.21.22-d3fd9f8974/node_modules/systeminformation/",\
["npm:5.21.23", {\
"packageLocation": "./.yarn/unplugged/systeminformation-npm-5.21.23-f0c4f32b3c/node_modules/systeminformation/",\
"packageDependencies": [\
["systeminformation", "npm:5.21.22"]\
["systeminformation", "npm:5.21.23"]\
],\
"linkType": "HARD"\
}]\
@ -2614,10 +2614,10 @@ const RAW_RUNTIME_STATE =
],\
"linkType": "HARD"\
}],\
["npm:6.3.0", {\
"packageLocation": "./.yarn/cache/undici-npm-6.3.0-3653a9b474-4534474384.zip/node_modules/undici/",\
["npm:6.4.0", {\
"packageLocation": "./.yarn/cache/undici-npm-6.4.0-3c1375c132-65552916aa.zip/node_modules/undici/",\
"packageDependencies": [\
["undici", "npm:6.3.0"],\
["undici", "npm:6.4.0"],\
["@fastify/busboy", "npm:2.0.0"]\
],\
"linkType": "HARD"\
@ -2733,7 +2733,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/wkx-npm-0.5.0-fca5152cd8-b8975e33f9.zip/node_modules/wkx/",\
"packageDependencies": [\
["wkx", "npm:0.5.0"],\
["@types/node", "npm:20.11.3"]\
["@types/node", "npm:20.11.5"]\
],\
"linkType": "HARD"\
}]\

View File

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

View File

@ -6,7 +6,7 @@ import Formatters from '../helpers/Formatters.js';
import GitHub from '../helpers/GitHub.js';
import TClient from '../client.js';
import util from 'node:util';
import fs from 'node:fs';
import fs, { writeFileSync } from 'node:fs';
export default class Developer {
static run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>) {
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 (url) currentActivities[0].url = url;
client.user.setPresence(client.config.botPresence);
writeFileSync(process.argv[2] ?? 'src/config.json', JSON.stringify(client.config, null, 2));
interaction.reply(MessageTool.concatMessage(
'Presence updated:',
`Status: **${client.config.botPresence.status}**`,
@ -157,7 +158,7 @@ export default class Developer {
.setRequired(false)))
.addSubcommand(x=>x
.setName('restart')
.setDescription('Restart the bot for technical reasons'))
.setDescription('Restart the bot for manual changes/technical difficulties'))
.addSubcommand(x=>x
.setName('update')
.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()]();
}
@ -80,11 +73,4 @@ export default class ProhibitedWords {
.setName('word')
.setDescription('Remove the specific word from automod\'s prohibitedWords database')
.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)) {
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);

View File

@ -1,6 +1,5 @@
import DatabaseServer from '../components/DatabaseServer.js';
import {Model, DataTypes} from 'sequelize';
import {get} from 'node:https';
class prohibitedWords extends Model {
declare public word: string;
@ -27,25 +26,6 @@ export class ProhibitedWordsSvc {
this.model.sync();
}
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();
insertWord = async(word:string)=>await this.model.create({word: word});
removeWord = async(word:string)=>await this.model.destroy({where: {word: word}})

View File

@ -441,12 +441,12 @@ __metadata:
languageName: node
linkType: hard
"@types/node@npm:*, @types/node@npm:20.11.3":
version: 20.11.3
resolution: "@types/node@npm:20.11.3"
"@types/node@npm:*, @types/node@npm:20.11.5":
version: 20.11.5
resolution: "@types/node@npm:20.11.5"
dependencies:
undici-types: "npm:~5.26.4"
checksum: dff64333435bbda87e200e24e2103f40692d0a01849db685ecb31db7c589f2556843a03dd351ddaee9981020263939c026557b36df49154efd910c610deefe78
checksum: 9f31c471047d7b3e240ce7b77ff29b0d15e83be7e3feafb3d0b0d0931122b438b1eefa302a5a2e1e9849914ff3fd76aafbd8ccb372efb1331ba048da63bce6f8
languageName: node
linkType: hard
@ -748,7 +748,7 @@ __metadata:
"@octokit/rest": "npm:20.0.2"
"@toast/tokenservice-client": "npm:1.0.6"
"@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/pg": "npm:8.10.9"
"@types/sequelize": "npm:4.28.20"
@ -764,9 +764,9 @@ __metadata:
redis: "npm:4.6.12"
sequelize: "npm:6.35.2"
simple-git: "npm:3.22.0"
systeminformation: "npm:5.21.22"
systeminformation: "npm:5.21.23"
typescript: "npm:5.3.3"
undici: "npm:6.3.0"
undici: "npm:6.4.0"
languageName: unknown
linkType: soft
@ -2065,12 +2065,12 @@ __metadata:
languageName: node
linkType: hard
"systeminformation@npm:5.21.22":
version: 5.21.22
resolution: "systeminformation@npm:5.21.22"
"systeminformation@npm:5.21.23":
version: 5.21.23
resolution: "systeminformation@npm:5.21.23"
bin:
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)
languageName: node
linkType: hard
@ -2169,12 +2169,12 @@ __metadata:
languageName: node
linkType: hard
"undici@npm:6.3.0":
version: 6.3.0
resolution: "undici@npm:6.3.0"
"undici@npm:6.4.0":
version: 6.4.0
resolution: "undici@npm:6.4.0"
dependencies:
"@fastify/busboy": "npm:^2.0.0"
checksum: 4534474384267ea2818b23a61daa6d851895e9caa9998be0bd71687322f7fbad653ffbaba084bc9d75f41ae2ac1c27adab65d631837890e26a2a52a8e0408ec4
checksum: 65552916aa84eb8ea262cf7205bf2dc1ca86b616843adceb6d994a172a5a6be7fbf384ab790e7ede82811942f0c71a53e639309e92e05be044866ca54993e0be
languageName: node
linkType: hard