mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-07-07 07:01:00 +02:00
Merge pull request #11 from smyalygames/main
feat(arabot): start logging of sus notes
This commit is contained in:
commit
6c8f3b4219
@ -38,23 +38,23 @@ model User {
|
||||
vegCurious Boolean @default(false)
|
||||
convinced Boolean @default(false)
|
||||
muted Boolean @default(false)
|
||||
VerifyUser Verify[] @relation("user")
|
||||
VerifyVerifier Verify[] @relation("verifier")
|
||||
SusUser Sus[] @relation("user")
|
||||
SusMod Sus[] @relation("mod")
|
||||
RestrictUser Restrict[] @relation("user")
|
||||
RestrictMod Restrict[] @relation("mod")
|
||||
BanUser Ban[] @relation("user")
|
||||
BanMod Ban[] @relation("mod")
|
||||
TempBanUser TempBan[] @relation("user")
|
||||
TempBanMod TempBan[] @relation("mod")
|
||||
VerifyUser Verify[] @relation("verUser")
|
||||
VerifyVerifier Verify[] @relation("verVerifier")
|
||||
SusUser Sus[] @relation("susUser")
|
||||
SusMod Sus[] @relation("susMod")
|
||||
RestrictUser Restrict[] @relation("restUser")
|
||||
RestrictMod Restrict[] @relation("restMod")
|
||||
BanUser Ban[] @relation("banUser")
|
||||
BanMod Ban[] @relation("banMod")
|
||||
TempBanUser TempBan[] @relation("tbanUser")
|
||||
TempBanMod TempBan[] @relation("tbanMod")
|
||||
}
|
||||
|
||||
model Verify {
|
||||
id Int @id @default(autoincrement())
|
||||
user User @relation("user", fields: [userId], references: [id])
|
||||
user User @relation("verUser", fields: [userId], references: [id])
|
||||
userId String
|
||||
verifier User? @relation("verifier", fields: [verifierId], references: [id])
|
||||
verifier User? @relation("verVerifier", fields: [verifierId], references: [id])
|
||||
verifierId String?
|
||||
time DateTime @default(now())
|
||||
timedOut Boolean @default(false) // If they got kicked out of verification because they timed out
|
||||
@ -66,17 +66,18 @@ model Verify {
|
||||
|
||||
model Sus {
|
||||
id Int @id @default(autoincrement())
|
||||
user User @relation("user", fields: [userId], references: [id])
|
||||
user User @relation("susUser", fields: [userId], references: [id])
|
||||
userId String
|
||||
mod User @relation("mod", fields: [modId], references: [id])
|
||||
mod User @relation("susMod", fields: [modId], references: [id])
|
||||
modId String
|
||||
note String
|
||||
}
|
||||
|
||||
model Restrict {
|
||||
id Int @id @default(autoincrement())
|
||||
user User @relation("user", fields: [userId], references: [id])
|
||||
user User @relation("restUser", fields: [userId], references: [id])
|
||||
userId String
|
||||
mod User @relation("mod", fields: [modId], references: [id])
|
||||
mod User @relation("restMod", fields: [modId], references: [id])
|
||||
modId String
|
||||
startTime DateTime @default(now())
|
||||
endedTime DateTime?
|
||||
@ -85,9 +86,9 @@ model Restrict {
|
||||
|
||||
model Ban {
|
||||
id Int @id @default(autoincrement())
|
||||
user User @relation("user", fields: [userId], references: [id])
|
||||
user User @relation("banUser", fields: [userId], references: [id])
|
||||
userId String
|
||||
mod User @relation("mod", fields: [modId], references: [id])
|
||||
mod User @relation("banMod", fields: [modId], references: [id])
|
||||
modId String
|
||||
time DateTime @default(now())
|
||||
active Boolean @default(true)
|
||||
@ -96,9 +97,9 @@ model Ban {
|
||||
|
||||
model TempBan {
|
||||
id Int @id @default(autoincrement())
|
||||
user User @relation("user", fields: [userId], references: [id])
|
||||
user User @relation("tbanUser", fields: [userId], references: [id])
|
||||
userId String
|
||||
mod User @relation("mod", fields: [modId], references: [id])
|
||||
mod User @relation("tbanMod", fields: [modId], references: [id])
|
||||
modId String
|
||||
startTime DateTime @default(now())
|
||||
endedTime DateTime
|
||||
|
83
src/commands/mod/sus.ts
Normal file
83
src/commands/mod/sus.ts
Normal file
@ -0,0 +1,83 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
/*
|
||||
Animal Rights Advocates Discord Bot
|
||||
Copyright (C) 2022 Anthony Berg
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Command } from '@sapphire/framework';
|
||||
import type { Message, GuildMember } from 'discord.js';
|
||||
import { addExistingUser, userExists } from '../../utils/dbExistingUser';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
export class SusCommand extends Command {
|
||||
public constructor(context: Command.Context) {
|
||||
super(context, {
|
||||
name: 'sus',
|
||||
description: 'Adds a sus note about a user.',
|
||||
});
|
||||
}
|
||||
|
||||
public async messageRun(message: Message) {
|
||||
const msg = await message.channel.send('Ping?');
|
||||
|
||||
const content = `Pong from JavaScript! Bot Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${msg.createdTimestamp - message.createdTimestamp}ms.`;
|
||||
|
||||
// Checks if the user exists
|
||||
if (message.member === null) {
|
||||
await message.channel.send('Member not found');
|
||||
return;
|
||||
}
|
||||
|
||||
// Checks if the user is on the database
|
||||
if (!await userExists(message.member)) {
|
||||
// If they are not on the database, add them to the database
|
||||
await addExistingUser(message.member);
|
||||
}
|
||||
|
||||
await addToDatabase(message.member, message.member, 'This is a note :D');
|
||||
|
||||
return msg.edit(content);
|
||||
}
|
||||
}
|
||||
|
||||
async function addToDatabase(user: GuildMember, mod: GuildMember, message: string) {
|
||||
// Initialise the database connection
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
// Create variables for data input
|
||||
const userId = user.id.toString();
|
||||
const modId = mod.id.toString();
|
||||
|
||||
// Add the user to the database
|
||||
await prisma.sus.create({
|
||||
data: {
|
||||
user: {
|
||||
connect: {
|
||||
id: userId,
|
||||
},
|
||||
},
|
||||
mod: {
|
||||
connect: {
|
||||
id: modId,
|
||||
},
|
||||
},
|
||||
note: message,
|
||||
},
|
||||
});
|
||||
|
||||
// Close the database connection
|
||||
await prisma.$disconnect();
|
||||
}
|
@ -61,13 +61,13 @@ export async function addExistingUser(user: GuildMember) {
|
||||
}
|
||||
|
||||
// Checks what roles the user has
|
||||
const hasVegan = user.roles.cache.has(IDs.roles.vegan);
|
||||
const hasActivist = user.roles.cache.has(IDs.roles.activist);
|
||||
const hasPlus = user.roles.cache.has(IDs.roles.plus);
|
||||
const hasVegCurious = user.roles.cache.has(IDs.roles.vegCurious);
|
||||
const hasConvinced = user.roles.cache.has(IDs.roles.convinced);
|
||||
const hasVegan = user.roles.cache.has(IDs.roles.vegan.vegan);
|
||||
const hasActivist = user.roles.cache.has(IDs.roles.vegan.activist);
|
||||
const hasPlus = user.roles.cache.has(IDs.roles.vegan.plus);
|
||||
const hasVegCurious = user.roles.cache.has(IDs.roles.nonvegan.vegCurious);
|
||||
const hasConvinced = user.roles.cache.has(IDs.roles.nonvegan.convinced);
|
||||
const hasTrusted = user.roles.cache.has(IDs.roles.trusted);
|
||||
const hasMuted = user.roles.cache.has(IDs.roles.trusted);
|
||||
const hasMuted = user.roles.cache.has(IDs.roles.restrictions.muted);
|
||||
|
||||
// Create the user in the database
|
||||
await prisma.user.create({
|
||||
@ -82,4 +82,7 @@ export async function addExistingUser(user: GuildMember) {
|
||||
muted: hasMuted,
|
||||
},
|
||||
});
|
||||
|
||||
// Close the database connection
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
@ -18,14 +18,25 @@
|
||||
|
||||
const IDs = {
|
||||
roles: {
|
||||
nonvegan: '774763753308815400',
|
||||
vegan: '788114978020392982',
|
||||
activist: '730915638746546257',
|
||||
plus: '798682625619132428',
|
||||
vegCurious: '832656046572961803',
|
||||
convinced: '797132019166871612',
|
||||
trusted: '731563158011117590',
|
||||
muted: '730924813681688596',
|
||||
nonvegan: {
|
||||
nonvegan: '774763753308815400',
|
||||
vegCurious: '832656046572961803',
|
||||
convinced: '797132019166871612',
|
||||
},
|
||||
vegan: {
|
||||
vegan: '788114978020392982',
|
||||
activist: '730915638746546257',
|
||||
plus: '798682625619132428',
|
||||
},
|
||||
restrictions: {
|
||||
sus: '859145930640457729',
|
||||
muted: '730924813681688596',
|
||||
restricted1: '809769217477050369',
|
||||
restricted2: '872482843304001566',
|
||||
restricted3: '856582673258774538',
|
||||
restricted4: '872472182888992858',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user