no testing, straight to prod

This commit is contained in:
Lea 2023-03-20 19:59:42 +01:00
parent f723f61af3
commit 8a2f5d6fbe
Signed by: Lea
GPG key ID: 1BAFFE8347019C42

View file

@ -8,6 +8,7 @@ config();
type Db = {
probation: string[];
blocked: string[];
}
const DB_FILE = process.env.DB_FILE || './db.json';
@ -18,6 +19,8 @@ const COMMANDS = {
'unapprove': 'Send users to probation',
'status': 'Edit the bot\'s status',
'suicide': 'This will make you commit suicide',
'block': 'Troll a user',
'unblock': 'Untroll a user',
}
if (!process.env.TOKEN) throw "$TOKEN not set";
@ -30,7 +33,9 @@ const client = new Client({ });
client.loginBot(process.env.TOKEN);
db.read().then(() => {
db.data ||= { probation: [] };
db.data ||= { probation: [], blocked: [] };
db.data.probation ||= [];
db.data.blocked ||= [];
db.write();
});
@ -210,6 +215,14 @@ client.on('message', async (message) => {
const logs = client.channels.get(process.env.LOGS!);
const privileged = message.member?.hasPermission(message.channel?.server!, 'ManageMessages');
if (!privileged && db.data?.blocked.includes(message.author_id)) {
console.log('Ignoring nerd');
try {
await message.react('01G7PX5GVMPQD35FQE15H2T08S');
} catch(e) { console.error(e) }
return;
}
if (!privileged && db.data?.probation.includes(message.author_id)) {
console.log('Ignoring user on probation');
return;
@ -312,6 +325,34 @@ client.on('message', async (message) => {
break;
}
case 'block': {
const users = await extractUsers(message, args);
if (!users?.length) return await message.reply('User(s) not found or no users provided');
for (const user of users) {
if (!db.data?.blocked.includes(user._id)) db.data?.blocked.push(user._id);
}
await message.reply({ embeds: [
embed("Users trolled successfully", undefined, "SUCCESS"),
] });
break;
}
case 'unblock': {
const users = await extractUsers(message, args);
if (!users?.length) return await message.reply('User(s) not found or no users provided');
for (const user of users) {
if (db.data?.blocked.includes(user._id)) db.data.blocked = db.data.blocked.filter(u => u != user._id);
}
await message.reply({ embeds: [
embed("Users untrolled successfully", undefined, "SUCCESS"),
] });
break;
}
case 'help': {
const commands = Object.entries(COMMANDS).filter(c => privileged || PUBLIC_COMMANDS.includes(c[0]));