no testing, straight to prod
This commit is contained in:
parent
f723f61af3
commit
8a2f5d6fbe
43
src/index.ts
43
src/index.ts
|
@ -8,6 +8,7 @@ config();
|
||||||
|
|
||||||
type Db = {
|
type Db = {
|
||||||
probation: string[];
|
probation: string[];
|
||||||
|
blocked: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const DB_FILE = process.env.DB_FILE || './db.json';
|
const DB_FILE = process.env.DB_FILE || './db.json';
|
||||||
|
@ -18,6 +19,8 @@ const COMMANDS = {
|
||||||
'unapprove': 'Send users to probation',
|
'unapprove': 'Send users to probation',
|
||||||
'status': 'Edit the bot\'s status',
|
'status': 'Edit the bot\'s status',
|
||||||
'suicide': 'This will make you commit suicide',
|
'suicide': 'This will make you commit suicide',
|
||||||
|
'block': 'Troll a user',
|
||||||
|
'unblock': 'Untroll a user',
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!process.env.TOKEN) throw "$TOKEN not set";
|
if (!process.env.TOKEN) throw "$TOKEN not set";
|
||||||
|
@ -30,7 +33,9 @@ const client = new Client({ });
|
||||||
client.loginBot(process.env.TOKEN);
|
client.loginBot(process.env.TOKEN);
|
||||||
|
|
||||||
db.read().then(() => {
|
db.read().then(() => {
|
||||||
db.data ||= { probation: [] };
|
db.data ||= { probation: [], blocked: [] };
|
||||||
|
db.data.probation ||= [];
|
||||||
|
db.data.blocked ||= [];
|
||||||
db.write();
|
db.write();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -210,6 +215,14 @@ client.on('message', async (message) => {
|
||||||
const logs = client.channels.get(process.env.LOGS!);
|
const logs = client.channels.get(process.env.LOGS!);
|
||||||
const privileged = message.member?.hasPermission(message.channel?.server!, 'ManageMessages');
|
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)) {
|
if (!privileged && db.data?.probation.includes(message.author_id)) {
|
||||||
console.log('Ignoring user on probation');
|
console.log('Ignoring user on probation');
|
||||||
return;
|
return;
|
||||||
|
@ -312,6 +325,34 @@ client.on('message', async (message) => {
|
||||||
break;
|
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': {
|
case 'help': {
|
||||||
const commands = Object.entries(COMMANDS).filter(c => privileged || PUBLIC_COMMANDS.includes(c[0]));
|
const commands = Object.entries(COMMANDS).filter(c => privileged || PUBLIC_COMMANDS.includes(c[0]));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue