⚰️ remvoed unused code
This commit is contained in:
parent
8ab6fe1559
commit
510c759e6b
23 changed files with 486 additions and 537 deletions
|
@ -56,8 +56,10 @@ export default async (interaction: CommandInteraction) => {
|
|||
const userDB = await fetchUser(user, guild);
|
||||
|
||||
if (userDB === null) return;
|
||||
if (guildDB === null) return;
|
||||
if (guildDB.shop === null) return;
|
||||
|
||||
const { pricePerHour } = guildDB?.shop?.roles;
|
||||
const { pricePerHour } = guildDB.shop.roles;
|
||||
|
||||
userDB.credits -= pricePerHour;
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
import users from "../../helpers/database/models/userSchema";
|
||||
import logger from "../../handlers/logger";
|
||||
|
||||
import { GuildMember } from "discord.js";
|
||||
import updatePresence from "../../helpers/updatePresence";
|
||||
import fetchUser from "../../helpers/fetchUser";
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
import users from "../../helpers/database/models/userSchema";
|
||||
import logger from "../../handlers/logger";
|
||||
|
||||
import { GuildMember } from "discord.js";
|
||||
import updatePresence from "../../helpers/updatePresence";
|
||||
import dropUser from "../../helpers/dropUser";
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
// Dependencies
|
||||
import { Message } from "discord.js";
|
||||
|
||||
// Models
|
||||
import userSchema from "../../helpers/database/models/userSchema";
|
||||
import guildSchema from "../../helpers/database/models/guildSchema";
|
||||
|
||||
// Modules
|
||||
import points from "./modules/points";
|
||||
import credits from "./modules/credits";
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import logger from "../../../handlers/logger";
|
||||
import counters from "../../../helpers/database/models/counterSchema";
|
||||
|
||||
import { Message } from "discord.js";
|
||||
|
|
|
@ -1,70 +1,70 @@
|
|||
import logger from '../../../handlers/logger';
|
||||
import timeouts from '../../../helpers/database/models/timeoutSchema';
|
||||
import { Message } from 'discord.js';
|
||||
export default async (guildDB: any, userDB: any, message: Message) => {
|
||||
const { guild, author, channel, content } = message;
|
||||
|
||||
// If message length is below guild minimum length
|
||||
if (content.length < guildDB.credits.minimumLength) return;
|
||||
|
||||
// Check if user has a timeout
|
||||
const isTimeout = await timeouts.findOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-42',
|
||||
});
|
||||
|
||||
// If user is not on timeout
|
||||
if (!isTimeout) {
|
||||
// Add credits to user
|
||||
|
||||
userDB.credits += guildDB.credits.rate;
|
||||
|
||||
await userDB
|
||||
.save()
|
||||
.then(async () => {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${channel.id} credits add ${guildDB.credits.rate} balance: ${userDB.credits}`
|
||||
);
|
||||
})
|
||||
.catch(async (e: any) => {
|
||||
// Send error message
|
||||
await logger.error(e);
|
||||
});
|
||||
|
||||
// Create a timeout for the user
|
||||
await timeouts.create({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-42',
|
||||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${
|
||||
channel.id
|
||||
} has not talked within last ${
|
||||
guildDB.credits.timeout / 1000
|
||||
} seconds, credits can be given`
|
||||
);
|
||||
|
||||
// When timeout is out, remove it from the database
|
||||
await timeouts.deleteOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-42',
|
||||
});
|
||||
}, guildDB.credits.timeout);
|
||||
} else {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${
|
||||
channel.id
|
||||
} has talked within last ${
|
||||
guildDB.credits.timeout / 1000
|
||||
} seconds, no credits given`
|
||||
);
|
||||
}
|
||||
};
|
||||
import logger from "../../../handlers/logger";
|
||||
import timeouts from "../../../helpers/database/models/timeoutSchema";
|
||||
import { Message } from "discord.js";
|
||||
export default async (guildDB: any, userDB: any, message: Message) => {
|
||||
const { guild, author, channel, content } = message;
|
||||
|
||||
// If message length is below guild minimum length
|
||||
if (content.length < guildDB.credits.minimumLength) return;
|
||||
|
||||
// Check if user has a timeout
|
||||
const isTimeout = await timeouts.findOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: "2022-03-15-17-42",
|
||||
});
|
||||
|
||||
// If user is not on timeout
|
||||
if (!isTimeout) {
|
||||
// Add credits to user
|
||||
|
||||
userDB.credits += guildDB.credits.rate;
|
||||
|
||||
await userDB
|
||||
.save()
|
||||
.then(async () => {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${channel.id} credits add ${guildDB.credits.rate} balance: ${userDB.credits}`
|
||||
);
|
||||
})
|
||||
.catch(async (e: any) => {
|
||||
// Send error message
|
||||
await logger.error(e);
|
||||
});
|
||||
|
||||
// Create a timeout for the user
|
||||
await timeouts.create({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: "2022-03-15-17-42",
|
||||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${
|
||||
channel.id
|
||||
} has not talked within last ${
|
||||
guildDB.credits.timeout / 1000
|
||||
} seconds, credits can be given`
|
||||
);
|
||||
|
||||
// When timeout is out, remove it from the database
|
||||
await timeouts.deleteOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: "2022-03-15-17-42",
|
||||
});
|
||||
}, guildDB.credits.timeout);
|
||||
} else {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${
|
||||
channel.id
|
||||
} has talked within last ${
|
||||
guildDB.credits.timeout / 1000
|
||||
} seconds, no credits given`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,70 +1,70 @@
|
|||
import logger from '../../../handlers/logger';
|
||||
import timeouts from '../../../helpers/database/models/timeoutSchema';
|
||||
|
||||
import { Message } from 'discord.js';
|
||||
export default async (guildDB: any, userDB: any, message: Message) => {
|
||||
const { author, guild, channel, content } = message;
|
||||
|
||||
// If message length is below guild minimum length
|
||||
if (content.length < guildDB.points.minimumLength) return;
|
||||
|
||||
// Check if user has a timeout
|
||||
const isTimeout = await timeouts.findOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-41',
|
||||
});
|
||||
|
||||
// If user is not on timeout
|
||||
if (!isTimeout) {
|
||||
// Add points to user
|
||||
userDB.points += guildDB.points.rate;
|
||||
|
||||
await userDB
|
||||
.save()
|
||||
.then(async () => {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${channel.id} points add: ${guildDB.points.rate} balance: ${userDB.points}`
|
||||
);
|
||||
})
|
||||
.catch(async (e: any) => {
|
||||
// Send error message
|
||||
await logger.error(e);
|
||||
});
|
||||
|
||||
// Create a timeout for the user
|
||||
await timeouts.create({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-41',
|
||||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${
|
||||
channel.id
|
||||
} has not talked within last ${
|
||||
guildDB.points.timeout / 1000
|
||||
} seconds, points can be given`
|
||||
);
|
||||
|
||||
// When timeout is out, remove it from the database
|
||||
await timeouts.deleteOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-41',
|
||||
});
|
||||
}, guildDB.points.timeout);
|
||||
} else {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${
|
||||
channel.id
|
||||
} has talked within last ${
|
||||
guildDB.points.timeout / 1000
|
||||
} seconds, no points given`
|
||||
);
|
||||
}
|
||||
};
|
||||
import logger from "../../../handlers/logger";
|
||||
import timeouts from "../../../helpers/database/models/timeoutSchema";
|
||||
|
||||
import { Message } from "discord.js";
|
||||
export default async (guildDB: any, userDB: any, message: Message) => {
|
||||
const { author, guild, channel, content } = message;
|
||||
|
||||
// If message length is below guild minimum length
|
||||
if (content.length < guildDB.points.minimumLength) return;
|
||||
|
||||
// Check if user has a timeout
|
||||
const isTimeout = await timeouts.findOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: "2022-03-15-17-41",
|
||||
});
|
||||
|
||||
// If user is not on timeout
|
||||
if (!isTimeout) {
|
||||
// Add points to user
|
||||
userDB.points += guildDB.points.rate;
|
||||
|
||||
await userDB
|
||||
.save()
|
||||
.then(async () => {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${channel.id} points add: ${guildDB.points.rate} balance: ${userDB.points}`
|
||||
);
|
||||
})
|
||||
.catch(async (e: any) => {
|
||||
// Send error message
|
||||
await logger.error(e);
|
||||
});
|
||||
|
||||
// Create a timeout for the user
|
||||
await timeouts.create({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: "2022-03-15-17-41",
|
||||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${
|
||||
channel.id
|
||||
} has not talked within last ${
|
||||
guildDB.points.timeout / 1000
|
||||
} seconds, points can be given`
|
||||
);
|
||||
|
||||
// When timeout is out, remove it from the database
|
||||
await timeouts.deleteOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: "2022-03-15-17-41",
|
||||
});
|
||||
}, guildDB.points.timeout);
|
||||
} else {
|
||||
// Send debug message
|
||||
await logger.debug(
|
||||
`Guild: ${guild?.id} User: ${author.id} Channel: ${
|
||||
channel.id
|
||||
} has talked within last ${
|
||||
guildDB.points.timeout / 1000
|
||||
} seconds, no points given`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import fs from 'fs'; // fs
|
||||
import { Collection } from 'discord.js'; // discord.js
|
||||
import { Client } from '../types/common/discord';
|
||||
import fs from "fs"; // fs
|
||||
import { Collection } from "discord.js"; // discord.js
|
||||
import { Client } from "../types/common/discord";
|
||||
export default async (client: Client) => {
|
||||
client.commands = new Collection();
|
||||
const commandFiles = fs.readdirSync('./src/commands');
|
||||
const commandFiles = fs.readdirSync("./src/commands");
|
||||
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`../commands/${file}`);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import fs from 'fs'; // fs
|
||||
import { Client } from 'discord.js'; // discord.js
|
||||
import fs from "fs"; // fs
|
||||
import { Client } from "discord.js"; // discord.js
|
||||
|
||||
export default async (client: Client) => {
|
||||
const eventFiles = fs.readdirSync('./src/events');
|
||||
const eventFiles = fs.readdirSync("./src/events");
|
||||
|
||||
for (const file of eventFiles) {
|
||||
const event = require(`../events/${file}`);
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
import events from './events';
|
||||
import commands from './commands';
|
||||
import locale from './locale';
|
||||
import schedules from './schedules';
|
||||
|
||||
export default { events, commands, locale, schedules };
|
|
@ -1,135 +1,135 @@
|
|||
import i18next from 'i18next';
|
||||
|
||||
export default async () => {
|
||||
await i18next.init({
|
||||
lng: 'en', // if you're using a language detector, do not define the lng option
|
||||
// debug: true,
|
||||
fallbackLng: 'en',
|
||||
resources: {
|
||||
en: {
|
||||
general: { not_available: 'Not Available' },
|
||||
commands: {
|
||||
credits: {
|
||||
general: {
|
||||
credits_one: '{{count}} credit',
|
||||
credits_other: '{{count}} credits',
|
||||
},
|
||||
addons: {
|
||||
balance: { embed: { title: 'Credits' } },
|
||||
gift: { embed: { title: 'Gift' } },
|
||||
},
|
||||
},
|
||||
reputation: {
|
||||
addons: {
|
||||
give: {
|
||||
version01: {
|
||||
embed: {
|
||||
title: ':medal: Reputation',
|
||||
description:
|
||||
'You have given reputation within the last day, you can not repute now!',
|
||||
},
|
||||
},
|
||||
version02: {
|
||||
embed: {
|
||||
title: ':medal: Reputation',
|
||||
description:
|
||||
'You have given {{user}} a {{type}} reputation!',
|
||||
},
|
||||
},
|
||||
version03: {
|
||||
embed: {
|
||||
title: ':medal: Reputation',
|
||||
description: 'You can not repute yourself.',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
profile: {
|
||||
addons: {
|
||||
view: {
|
||||
embed: {
|
||||
title: 'Profile',
|
||||
reputation: 'Reputation (Global)',
|
||||
level: 'Level (Guild)',
|
||||
points: 'Points (Guild)',
|
||||
credits: 'Credits (Guild)',
|
||||
language_code: 'Language Code (Global)',
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
embed: {
|
||||
title: 'Profile',
|
||||
description: 'Following settings is set',
|
||||
fields: { language: 'Language' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
sv: {
|
||||
general: { not_available: 'Otillgänglig' },
|
||||
commands: {
|
||||
credits: {
|
||||
general: {
|
||||
credits_one: '{{count}} krona',
|
||||
credits_other: '{{count}} kronor',
|
||||
},
|
||||
addons: {
|
||||
balance: { embed: { title: 'Krediter' } },
|
||||
gift: { embed: { title: 'Gåva' } },
|
||||
},
|
||||
},
|
||||
reputation: {
|
||||
addons: {
|
||||
give: {
|
||||
version01: {
|
||||
embed: {
|
||||
title: ':medal: Omdöme',
|
||||
description:
|
||||
'Du har redan gett omdöme inom den senaste dagen, du kan inte ge ett omdöme just nu!',
|
||||
},
|
||||
},
|
||||
version02: {
|
||||
embed: {
|
||||
title: ':medal: Omdöme',
|
||||
description: 'Du har gett {{user}} ett {{type}} omdöme!',
|
||||
},
|
||||
},
|
||||
version03: {
|
||||
embed: {
|
||||
title: ':medal: Omdöme',
|
||||
description: 'Du kan inte ge dig själv ett omdöme.',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
profile: {
|
||||
addons: {
|
||||
view: {
|
||||
embed: {
|
||||
title: 'Profil',
|
||||
reputation: 'Omdöme (Globalt)',
|
||||
level: 'Nivå (Server)',
|
||||
points: 'Poäng (Server)',
|
||||
credits: 'Krediter (Server)',
|
||||
language_code: 'Språkkod (Globalt)',
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
embed: {
|
||||
title: 'Profil',
|
||||
description: 'Följande inställningar är satta',
|
||||
fields: { language: 'Språk' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
import i18next from "i18next";
|
||||
|
||||
export default async () => {
|
||||
await i18next.init({
|
||||
lng: "en", // if you're using a language detector, do not define the lng option
|
||||
// debug: true,
|
||||
fallbackLng: "en",
|
||||
resources: {
|
||||
en: {
|
||||
general: { not_available: "Not Available" },
|
||||
commands: {
|
||||
credits: {
|
||||
general: {
|
||||
credits_one: "{{count}} credit",
|
||||
credits_other: "{{count}} credits",
|
||||
},
|
||||
addons: {
|
||||
balance: { embed: { title: "Credits" } },
|
||||
gift: { embed: { title: "Gift" } },
|
||||
},
|
||||
},
|
||||
reputation: {
|
||||
addons: {
|
||||
give: {
|
||||
version01: {
|
||||
embed: {
|
||||
title: ":medal: Reputation",
|
||||
description:
|
||||
"You have given reputation within the last day, you can not repute now!",
|
||||
},
|
||||
},
|
||||
version02: {
|
||||
embed: {
|
||||
title: ":medal: Reputation",
|
||||
description:
|
||||
"You have given {{user}} a {{type}} reputation!",
|
||||
},
|
||||
},
|
||||
version03: {
|
||||
embed: {
|
||||
title: ":medal: Reputation",
|
||||
description: "You can not repute yourself.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
profile: {
|
||||
addons: {
|
||||
view: {
|
||||
embed: {
|
||||
title: "Profile",
|
||||
reputation: "Reputation (Global)",
|
||||
level: "Level (Guild)",
|
||||
points: "Points (Guild)",
|
||||
credits: "Credits (Guild)",
|
||||
language_code: "Language Code (Global)",
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
embed: {
|
||||
title: "Profile",
|
||||
description: "Following settings is set",
|
||||
fields: { language: "Language" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
sv: {
|
||||
general: { not_available: "Otillgänglig" },
|
||||
commands: {
|
||||
credits: {
|
||||
general: {
|
||||
credits_one: "{{count}} krona",
|
||||
credits_other: "{{count}} kronor",
|
||||
},
|
||||
addons: {
|
||||
balance: { embed: { title: "Krediter" } },
|
||||
gift: { embed: { title: "Gåva" } },
|
||||
},
|
||||
},
|
||||
reputation: {
|
||||
addons: {
|
||||
give: {
|
||||
version01: {
|
||||
embed: {
|
||||
title: ":medal: Omdöme",
|
||||
description:
|
||||
"Du har redan gett omdöme inom den senaste dagen, du kan inte ge ett omdöme just nu!",
|
||||
},
|
||||
},
|
||||
version02: {
|
||||
embed: {
|
||||
title: ":medal: Omdöme",
|
||||
description: "Du har gett {{user}} ett {{type}} omdöme!",
|
||||
},
|
||||
},
|
||||
version03: {
|
||||
embed: {
|
||||
title: ":medal: Omdöme",
|
||||
description: "Du kan inte ge dig själv ett omdöme.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
profile: {
|
||||
addons: {
|
||||
view: {
|
||||
embed: {
|
||||
title: "Profil",
|
||||
reputation: "Omdöme (Globalt)",
|
||||
level: "Nivå (Server)",
|
||||
points: "Poäng (Server)",
|
||||
credits: "Krediter (Server)",
|
||||
language_code: "Språkkod (Globalt)",
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
embed: {
|
||||
title: "Profil",
|
||||
description: "Följande inställningar är satta",
|
||||
fields: { language: "Språk" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import pino from 'pino';
|
||||
import * as config from '../../config.json';
|
||||
import pino from "pino";
|
||||
import * as config from "../../config.json";
|
||||
|
||||
export default pino({ level: config.debug ? 'debug' : 'info' });
|
||||
export default pino({ level: config.debug ? "debug" : "info" });
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import mongoose from 'mongoose';
|
||||
import mongoose from "mongoose";
|
||||
|
||||
import * as config from '../../../config.json';
|
||||
import logger from '../../handlers/logger';
|
||||
import * as config from "../../../config.json";
|
||||
import logger from "../../handlers/logger";
|
||||
|
||||
export default async () =>
|
||||
{
|
||||
await mongoose.connect(config.mongodb.url);
|
||||
logger.info('Connected to the database');
|
||||
export default async () => {
|
||||
await mongoose.connect(config.mongodb.url);
|
||||
logger.info("Connected to the database");
|
||||
};
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
import mongoose from 'mongoose';
|
||||
|
||||
const counterSchema = new mongoose.Schema(
|
||||
{
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
channelId: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
unique: true,
|
||||
index: true,
|
||||
},
|
||||
word: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
counter: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model('counter', counterSchema);
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const counterSchema = new mongoose.Schema(
|
||||
{
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
channelId: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
unique: true,
|
||||
index: true,
|
||||
},
|
||||
word: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
counter: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model("counter", counterSchema);
|
||||
|
|
|
@ -1,71 +1,71 @@
|
|||
import mongoose from 'mongoose';
|
||||
|
||||
const guildSchema = new mongoose.Schema(
|
||||
{
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: true,
|
||||
index: true,
|
||||
},
|
||||
credits: {
|
||||
status: {
|
||||
type: mongoose.SchemaTypes.Boolean,
|
||||
default: true,
|
||||
},
|
||||
rate: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 1,
|
||||
},
|
||||
minimumLength: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 5,
|
||||
},
|
||||
timeout: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 5000,
|
||||
},
|
||||
workRate: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 15,
|
||||
},
|
||||
workTimeout: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 900000,
|
||||
},
|
||||
},
|
||||
shop: {
|
||||
roles: {
|
||||
status: {
|
||||
type: mongoose.SchemaTypes.Boolean,
|
||||
default: true,
|
||||
},
|
||||
pricePerHour: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
points: {
|
||||
status: {
|
||||
type: mongoose.SchemaTypes.Boolean,
|
||||
default: false,
|
||||
},
|
||||
rate: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 1,
|
||||
},
|
||||
minimumLength: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 5,
|
||||
},
|
||||
timeout: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 5000,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model('guild', guildSchema);
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const guildSchema = new mongoose.Schema(
|
||||
{
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: true,
|
||||
index: true,
|
||||
},
|
||||
credits: {
|
||||
status: {
|
||||
type: mongoose.SchemaTypes.Boolean,
|
||||
default: true,
|
||||
},
|
||||
rate: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 1,
|
||||
},
|
||||
minimumLength: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 5,
|
||||
},
|
||||
timeout: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 5000,
|
||||
},
|
||||
workRate: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 15,
|
||||
},
|
||||
workTimeout: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 900000,
|
||||
},
|
||||
},
|
||||
shop: {
|
||||
roles: {
|
||||
status: {
|
||||
type: mongoose.SchemaTypes.Boolean,
|
||||
default: true,
|
||||
},
|
||||
pricePerHour: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
points: {
|
||||
status: {
|
||||
type: mongoose.SchemaTypes.Boolean,
|
||||
default: false,
|
||||
},
|
||||
rate: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 1,
|
||||
},
|
||||
minimumLength: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 5,
|
||||
},
|
||||
timeout: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
default: 5000,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model("guild", guildSchema);
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
import users from './userSchema';
|
||||
import guilds from './guildSchema';
|
||||
import apis from './apiSchema';
|
||||
import timeouts from './timeoutSchema';
|
||||
import counters from './counterSchema';
|
||||
import shopRoles from './shopRolesSchema';
|
||||
|
||||
export default {
|
||||
users,
|
||||
guilds,
|
||||
apis,
|
||||
timeouts,
|
||||
counters,
|
||||
shopRoles,
|
||||
};
|
|
@ -1,39 +1,39 @@
|
|||
import mongoose from 'mongoose';
|
||||
|
||||
const shopRoleSchema = new mongoose.Schema(
|
||||
{
|
||||
roleId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
userId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
pricePerHour: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
default: 5,
|
||||
},
|
||||
lastPayed: {
|
||||
type: mongoose.SchemaTypes.Date,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model('shopRole', shopRoleSchema);
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const shopRoleSchema = new mongoose.Schema(
|
||||
{
|
||||
roleId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
userId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
pricePerHour: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
default: 5,
|
||||
},
|
||||
lastPayed: {
|
||||
type: mongoose.SchemaTypes.Date,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model("shopRole", shopRoleSchema);
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
import mongoose from 'mongoose';
|
||||
|
||||
const timeoutSchema = new mongoose.Schema(
|
||||
{
|
||||
userId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
timeoutId: { type: mongoose.SchemaTypes.String },
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model('timeout', timeoutSchema);
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const timeoutSchema = new mongoose.Schema(
|
||||
{
|
||||
userId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
timeoutId: { type: mongoose.SchemaTypes.String },
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model("timeout", timeoutSchema);
|
||||
|
|
|
@ -1,31 +1,24 @@
|
|||
// TODO This file will make sure that all guilds always has at least one entry in all collections with "guildId"
|
||||
|
||||
import apis from "./database/models/apiSchema"
|
||||
import guilds from "./database/models/guildSchema"
|
||||
import apis from "./database/models/apiSchema";
|
||||
import guilds from "./database/models/guildSchema";
|
||||
|
||||
import logger from '../handlers/logger';
|
||||
import { Guild } from 'discord.js';
|
||||
import logger from "../handlers/logger";
|
||||
import { Guild } from "discord.js";
|
||||
|
||||
export default async (guild: Guild) =>
|
||||
{
|
||||
export default async (guild: Guild) => {
|
||||
const api = await apis.findOne({ guildId: guild.id });
|
||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
||||
if (!api)
|
||||
{
|
||||
if (!api) {
|
||||
apis.create({ guildId: guild.id });
|
||||
logger.debug(`Guild: ${guild.id} added api collection`);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
logger.debug(`Guild: ${guild.id} already in api collection`);
|
||||
}
|
||||
if (!guildData)
|
||||
{
|
||||
if (!guildData) {
|
||||
guilds.create({ guildId: guild.id });
|
||||
logger.debug(`Guild: ${guild.id} added guild collection`);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
logger.debug(`Guild: ${guild.id} already in guild collection`);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,27 +1,21 @@
|
|||
import users from './database/models/userSchema';
|
||||
import logger from '../handlers/logger';
|
||||
import { Guild, User } from 'discord.js';
|
||||
import users from "./database/models/userSchema";
|
||||
import logger from "../handlers/logger";
|
||||
import { Guild, User } from "discord.js";
|
||||
|
||||
export default async (user: User, guild: Guild) =>
|
||||
{
|
||||
export default async (user: User, guild: Guild) => {
|
||||
const userData = await users.findOne({ userId: user.id, guildId: guild.id });
|
||||
if (!userData)
|
||||
{
|
||||
if (!userData) {
|
||||
users
|
||||
.create({ userId: user.id, guildId: guild.id })
|
||||
.then(async () =>
|
||||
{
|
||||
.then(async () => {
|
||||
await logger.debug(`User: ${user.id} added user collection`);
|
||||
})
|
||||
.catch(async (e) =>
|
||||
{
|
||||
.catch(async (e) => {
|
||||
await logger.error(
|
||||
`User: ${user.id} failed to added user collection ${e}`
|
||||
);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
logger.debug(`User: ${user.id} already in user collection`);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
import config from '../../config.json';
|
||||
import logger from '../handlers/logger';
|
||||
import fs from 'fs';
|
||||
import { REST } from '@discordjs/rest';
|
||||
import { Routes } from 'discord-api-types/v9';
|
||||
import config from "../../config.json";
|
||||
import logger from "../handlers/logger";
|
||||
import fs from "fs";
|
||||
import { REST } from "@discordjs/rest";
|
||||
import { Routes } from "discord-api-types/v9";
|
||||
|
||||
export default async () => {
|
||||
const commands = [];
|
||||
const commandFiles = fs.readdirSync('./src/commands');
|
||||
const commandFiles = fs.readdirSync("./src/commands");
|
||||
|
||||
for (const file of commandFiles) {
|
||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||
// eslint-disable-next-line global-require
|
||||
const command = require(`../commands/${file}`);
|
||||
commands.push(command.default.data.toJSON());
|
||||
}
|
||||
|
||||
const rest = new REST({ version: '9' }).setToken(config.bot.token);
|
||||
const rest = new REST({ version: "9" }).setToken(config.bot.token);
|
||||
|
||||
await rest.put(Routes.applicationCommands(config.bot.clientId), {
|
||||
body: commands,
|
||||
|
@ -32,7 +32,7 @@ export default async () => {
|
|||
}
|
||||
)
|
||||
.then(async () =>
|
||||
logger.info('Successfully registered application commands.')
|
||||
logger.info("Successfully registered application commands.")
|
||||
)
|
||||
.catch(async (err) => {
|
||||
await logger.error(err);
|
||||
|
|
|
@ -8,7 +8,6 @@ import timeouts from "../helpers/database/models/timeoutSchema";
|
|||
import logger from "../handlers/logger";
|
||||
|
||||
import { Guild } from "discord.js";
|
||||
import updatePresence from "../helpers/updatePresence";
|
||||
|
||||
export default async (guild: Guild) => {
|
||||
guilds
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
import database from "./database";
|
||||
import deployCommands from "./deployCommands";
|
||||
import dbGuildFix from "./dbGuildFix";
|
||||
import dbMemberFix from "./dbMemberFix";
|
||||
|
||||
export default { database, deployCommands, dbGuildFix, dbMemberFix };
|
Loading…
Add table
Reference in a new issue