Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
feat: rename models + remove helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
wdhdev committed Jul 9, 2023
1 parent f0e57e6 commit 162f151
Show file tree
Hide file tree
Showing 65 changed files with 344 additions and 361 deletions.
10 changes: 5 additions & 5 deletions src/buttons/appeals/approve.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const emoji = require("../../config.json").emojis;

const appealSchema = require("../../models/appealSchema");
const bannedUserSchema = require("../../models/bannedUserSchema");
const Appeal = require("../../models/Appeal");
const BannedUser = require("../../models/BannedUser");

module.exports = {
name: "appeal-approve",
Expand All @@ -12,7 +12,7 @@ module.exports = {
const id = interaction.customId.replace("appeal-approve-", "");
const modLogsChannel = client.channels.cache.get(client.config_channels.modLogs);

const data = await appealSchema.findOne({ _id: id });
const data = await Appeal.findOne({ _id: id });

if(!data) {
const error = new Discord.EmbedBuilder()
Expand Down Expand Up @@ -66,8 +66,8 @@ module.exports = {
if(i.customId === `modal-${interaction.id}`) {
const reason = i.fields.getTextInputValue(`modal-reason-${interaction.id}`);

await bannedUserSchema.findOneAndDelete({ _id: data.id });
await appealSchema.findOneAndUpdate({ _id: id }, { status: "APPROVED", mod: interaction.user.id, reason: reason });
await BannedUser.findOneAndDelete({ _id: data.id });
await Appeal.findOneAndUpdate({ _id: id }, { status: "APPROVED", mod: interaction.user.id, reason: reason });

const userDM = new Discord.EmbedBuilder()
.setColor(client.config_embeds.green)
Expand Down
6 changes: 3 additions & 3 deletions src/buttons/appeals/check.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const emoji = require("../../config.json").emojis;

const appealSchema = require("../../models/appealSchema");
const Appeal = require("../../models/Appeal");

module.exports = {
name: "check-appeal",
Expand Down Expand Up @@ -33,7 +33,7 @@ module.exports = {
if(i.customId === `modal-${interaction.id}`) {
const id = i.fields.getTextInputValue(`modal-appealid-${interaction.id}`);

if(!await appealSchema.exists({ _id: id })) {
if(!await Appeal.exists({ _id: id })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} That appeal does not exist!`)
Expand All @@ -42,7 +42,7 @@ module.exports = {
return;
}

const data = await appealSchema.findOne({ _id: id });
const data = await Appeal.findOne({ _id: id });

if(data.id !== interaction.user.id) {
const error = new Discord.EmbedBuilder()
Expand Down
6 changes: 3 additions & 3 deletions src/buttons/appeals/deny.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const emoji = require("../../config.json").emojis;

const appealSchema = require("../../models/appealSchema");
const Appeal = require("../../models/Appeal");

module.exports = {
name: "appeal-deny",
Expand All @@ -11,7 +11,7 @@ module.exports = {
const id = interaction.customId.replace("appeal-deny-", "");
const modLogsChannel = client.channels.cache.get(client.config_channels.modLogs);

const data = await appealSchema.findOne({ _id: id });
const data = await Appeal.findOne({ _id: id });

if(!data) {
const error = new Discord.EmbedBuilder()
Expand Down Expand Up @@ -65,7 +65,7 @@ module.exports = {
if(i.customId === `modal-${interaction.id}`) {
const reason = i.fields.getTextInputValue(`modal-reason-${interaction.id}`);

await appealSchema.findOneAndUpdate({ _id: id }, { status: "DENIED", mod: interaction.user.id, reason: reason });
await Appeal.findOneAndUpdate({ _id: id }, { status: "DENIED", mod: interaction.user.id, reason: reason });

const userDM = new Discord.EmbedBuilder()
.setColor(client.config_embeds.red)
Expand Down
14 changes: 7 additions & 7 deletions src/buttons/appeals/submit.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const emoji = require("../../config.json").emojis;

const appealSchema = require("../../models/appealSchema");
const bannedUserSchema = require("../../models/bannedUserSchema");
const Appeal = require("../../models/Appeal");
const BannedUser = require("../../models/BannedUser");

module.exports = {
name: "submit-appeal",
startsWith: false,
requiredRoles: [],
async execute(interaction, client, Discord) {
try {
if(!await bannedUserSchema.exists({ _id: interaction.user.id })) {
if(!await BannedUser.exists({ _id: interaction.user.id })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} You are not banned!`)
Expand All @@ -18,7 +18,7 @@ module.exports = {
return;
}

if(await bannedUserSchema.exists({ _id: interaction.user.id, allowAppeal: false }) || await appealSchema.exists({ id: interaction.user.id, status: "DENIED" })) {
if(await BannedUser.exists({ _id: interaction.user.id, allowAppeal: false }) || await Appeal.exists({ id: interaction.user.id, status: "DENIED" })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} You are allowed to submit an appeal!`)
Expand All @@ -27,7 +27,7 @@ module.exports = {
return;
}

if(await appealSchema.exists({ id: interaction.user.id, status: "NOT_REVIEWED" })) {
if(await Appeal.exists({ id: interaction.user.id, status: "NOT_REVIEWED" })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} You already have created an appeal!`)
Expand Down Expand Up @@ -74,7 +74,7 @@ module.exports = {
const banReason = i.fields.getTextInputValue(`modal-banreason-${id}`);
const unbanReason = i.fields.getTextInputValue(`modal-unbanreason-${id}`);

const banData = await bannedUserSchema.findOne({ _id: interaction.user.id });
const banData = await BannedUser.findOne({ _id: interaction.user.id });

const embed = new Discord.EmbedBuilder()
.setColor(client.config_embeds.default)
Expand All @@ -86,7 +86,7 @@ module.exports = {
{ name: "🔓 Unban Reason (*user provided*)", value: `${unbanReason}` }
)

new appealSchema({
new Appeal({
_id: id,
id: interaction.user.id,
ban_reason: banReason,
Expand Down
10 changes: 5 additions & 5 deletions src/buttons/logs/blocked-message-ban.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const emoji = require("../../config.json").emojis;

const bannedUserSchema = require("../../models/bannedUserSchema");
const userSchema = require("../../models/userSchema");
const BannedUser = require("../../models/BannedUser");
const User = require("../../models/User");

module.exports = {
name: "blocked-message-ban",
Expand All @@ -20,7 +20,7 @@ module.exports = {
return;
}

if(await userSchema.exists({ _id: id, immune: true })) {
if(await User.exists({ _id: id, immune: true })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} You cannot ban that user!`)
Expand All @@ -33,7 +33,7 @@ module.exports = {
return;
}

if(await bannedUserSchema.exists({ _id: id })) {
if(await BannedUser.exists({ _id: id })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} That user is already banned!`)
Expand Down Expand Up @@ -99,7 +99,7 @@ module.exports = {

const user = await client.users.fetch(id);

new bannedUserSchema({
new BannedUser({
_id: id,
timestamp: Date.now(),
allowAppeal: appealable === "false" ? false : true,
Expand Down
6 changes: 3 additions & 3 deletions src/buttons/logs/blocked-message-info.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const emoji = require("../../config.json").emojis;

const blockedSchema = require("../../models/blockedSchema");
const BlockedMessage = require("../../models/BlockedMessage");

module.exports = {
name: "blocked-message-info",
Expand All @@ -10,7 +10,7 @@ module.exports = {
try {
const id = interaction.customId.replace("blocked-message-info-", "");

if(!await blockedSchema.exists({ _id: id })) {
if(!await BlockedMessage.exists({ _id: id })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} No message was found with that ID!`)
Expand All @@ -19,7 +19,7 @@ module.exports = {
return;
}

const data = await blockedSchema.findOne({ _id: id });
const data = await BlockedMessage.findOne({ _id: id });

const info = new Discord.EmbedBuilder()
.setColor(client.config_embeds.default)
Expand Down
6 changes: 3 additions & 3 deletions src/buttons/logs/delete-message.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const emoji = require("../../config.json").emojis;

const messageSchema = require("../../models/messageSchema");
const Message = require("../../models/Message");

module.exports = {
name: "delete-message",
Expand All @@ -11,7 +11,7 @@ module.exports = {
const id = interaction.customId.replace("delete-message-", "");
const modLogsChannel = client.channels.cache.get(client.config_channels.modLogs);

if(!await messageSchema.exists({ _id: id })) {
if(!await Message.exists({ _id: id })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} No message was found with that ID!`)
Expand All @@ -20,7 +20,7 @@ module.exports = {
return;
}

const data = await messageSchema.findOne({ _id: id });
const data = await Message.findOne({ _id: id });

const total = data.messages.length;
let deleted = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/buttons/logs/message-ban.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const emoji = require("../../config.json").emojis;

const bannedUserSchema = require("../../models/bannedUserSchema");
const userSchema = require("../../models/userSchema");
const BannedUser = require("../../models/BannedUser");
const User = require("../../models/User");

module.exports = {
name: "message-ban",
Expand All @@ -20,7 +20,7 @@ module.exports = {
return;
}

if(await userSchema.exists({ _id: id, immune: true })) {
if(await User.exists({ _id: id, immune: true })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} You cannot ban that user!`)
Expand All @@ -33,7 +33,7 @@ module.exports = {
return;
}

if(await bannedUserSchema.exists({ _id: id })) {
if(await BannedUser.exists({ _id: id })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} That user is already banned!`)
Expand Down Expand Up @@ -99,7 +99,7 @@ module.exports = {

const user = await client.users.fetch(id);

new bannedUserSchema({
new BannedUser({
_id: id,
timestamp: Date.now(),
allowAppeal: appealable === "false" ? false : true,
Expand Down
6 changes: 3 additions & 3 deletions src/buttons/logs/message-info.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const emoji = require("../../config.json").emojis;

const messageSchema = require("../../models/messageSchema");
const Message = require("../../models/Message");

module.exports = {
name: "message-info",
Expand All @@ -10,7 +10,7 @@ module.exports = {
try {
const id = interaction.customId.replace("message-info-", "");

if(!await messageSchema.exists({ _id: id })) {
if(!await Message.exists({ _id: id })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} No message was found with that ID!`)
Expand All @@ -19,7 +19,7 @@ module.exports = {
return;
}

const data = await messageSchema.findOne({ _id: id });
const data = await Message.findOne({ _id: id });

const info = new Discord.EmbedBuilder()
.setColor(client.config_embeds.default)
Expand Down
10 changes: 5 additions & 5 deletions src/buttons/logs/report-ban.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const emoji = require("../../config.json").emojis;

const bannedUserSchema = require("../../models/bannedUserSchema");
const userSchema = require("../../models/userSchema");
const BannedUser = require("../../models/BannedUser");
const User = require("../../models/User");

module.exports = {
name: "report-ban",
Expand All @@ -20,7 +20,7 @@ module.exports = {
return;
}

if(await userSchema.exists({ _id: id, immune: true })) {
if(await User.exists({ _id: id, immune: true })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} You cannot ban that user!`)
Expand All @@ -33,7 +33,7 @@ module.exports = {
return;
}

if(await bannedUserSchema.exists({ _id: id })) {
if(await BannedUser.exists({ _id: id })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} That user is already banned!`)
Expand Down Expand Up @@ -99,7 +99,7 @@ module.exports = {

const user = await client.users.fetch(id);

new bannedUserSchema({
new BannedUser({
_id: id,
timestamp: Date.now(),
allowAppeal: appealable === "false" ? false : true,
Expand Down
6 changes: 3 additions & 3 deletions src/buttons/sentry/capture-info.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const emoji = require("../../config.json").emojis;

const sentrySchema = require("../../models/sentrySchema");
const SentryCapture = require("../../models/SentryCapture");

module.exports = {
name: "sentry-capture-info",
Expand Down Expand Up @@ -32,7 +32,7 @@ module.exports = {
if(i.customId === `modal-${interaction.id}`) {
const token = i.fields.getTextInputValue(`modal-token-${interaction.id}`);

if(!await sentrySchema.exists({ _id: token })) {
if(!await SentryCapture.exists({ _id: token })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} That token does not exist!`)
Expand All @@ -41,7 +41,7 @@ module.exports = {
return;
}

const data = await sentrySchema.findOne({ _id: token });
const data = await SentryCapture.findOne({ _id: token });

const tokenInfo = new Discord.EmbedBuilder()
.setColor(client.config_embeds.default)
Expand Down
8 changes: 4 additions & 4 deletions src/buttons/to-do-list/add.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const emoji = require("../../config.json").emojis;

const todoSchema = require("../../models/todoSchema");
const Task = require("../../models/Task");

module.exports = {
name: "add-task",
startsWith: false,
requiredRoles: ["dev"],
async execute(interaction, client, Discord) {
const todoData = await todoSchema.find();
const todoData = await Task.find();

if(todoData.length >= 25) {
const error = new Discord.EmbedBuilder()
Expand Down Expand Up @@ -96,7 +96,7 @@ module.exports = {
const message = interaction.message;
const taskId = require("crypto").randomUUID();

data = new todoSchema({
data = new Task({
_id: taskId,
timestamp: Date.now(),
added_by: interaction.user.id,
Expand All @@ -111,7 +111,7 @@ module.exports = {

await i.editReply({ embeds: [added], components: [], ephemeral: true });

const newData = await todoSchema.find();
const newData = await Task.find();

const todoList = [];

Expand Down
Loading

0 comments on commit 162f151

Please sign in to comment.