[CodeFactor] Apply fixes
This commit is contained in:
parent
eacf9fd557
commit
82ac841993
30 changed files with 395 additions and 395 deletions
|
@ -1,17 +1,17 @@
|
|||
// Dependencies
|
||||
import { CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import { CommandInteraction, ColorResolvable } from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../../config.json';
|
||||
import config from "../../../../../config.json";
|
||||
|
||||
// Handlers
|
||||
import logger from '../../../../handlers/logger';
|
||||
import logger from "../../../../handlers/logger";
|
||||
|
||||
// Helpers
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
import creditNoun from "../../../../helpers/creditNoun";
|
||||
|
||||
// Models
|
||||
import fetchUser from '../../../../helpers/fetchUser';
|
||||
import fetchUser from "../../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
|
@ -19,17 +19,17 @@ export default async (interaction: CommandInteraction) => {
|
|||
const { guild, user, options } = interaction;
|
||||
|
||||
// User option
|
||||
const optionUser = options?.getUser('user');
|
||||
const optionUser = options?.getUser("user");
|
||||
|
||||
// Amount option
|
||||
const optionAmount = options?.getInteger('amount');
|
||||
const optionAmount = options?.getInteger("amount");
|
||||
|
||||
// If amount option is null
|
||||
if (optionAmount === null) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Give]' as string,
|
||||
description: 'We could not read your requested amount.' as string,
|
||||
title: ":toolbox: Admin - Credits [Give]" as string,
|
||||
description: "We could not read your requested amount." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -46,8 +46,8 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (optionAmount <= 0) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Give]' as string,
|
||||
description: 'You can not give zero credits or below.' as string,
|
||||
title: ":toolbox: Admin - Credits [Give]" as string,
|
||||
description: "You can not give zero credits or below." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -70,7 +70,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (!toUser) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Give]' as string,
|
||||
title: ":toolbox: Admin - Credits [Give]" as string,
|
||||
description: `We could not find ${optionUser} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
|
@ -88,7 +88,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (!toUser?.credits) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Give]' as string,
|
||||
title: ":toolbox: Admin - Credits [Give]" as string,
|
||||
description:
|
||||
`We could not find credits for ${optionUser} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
|
@ -110,7 +110,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
await toUser?.save()?.then(async () => {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Give]' as string,
|
||||
title: ":toolbox: Admin - Credits [Give]" as string,
|
||||
description: `We have given ${optionUser}, ${creditNoun(
|
||||
optionAmount
|
||||
)}.` as string,
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
// Dependencies
|
||||
import { Permissions, CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import { Permissions, CommandInteraction, ColorResolvable } from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../../config.json';
|
||||
import config from "../../../../../config.json";
|
||||
|
||||
// Handlers
|
||||
import logger from '../../../../handlers/logger';
|
||||
import logger from "../../../../handlers/logger";
|
||||
|
||||
// Helpers
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
import creditNoun from "../../../../helpers/creditNoun";
|
||||
|
||||
// Models
|
||||
import fetchUser from '../../../../helpers/fetchUser';
|
||||
import fetchUser from "../../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
|
@ -19,17 +19,17 @@ export default async (interaction: CommandInteraction) => {
|
|||
const { options, user, guild } = interaction;
|
||||
|
||||
// User Option
|
||||
const optionUser = options.getUser('user');
|
||||
const optionUser = options.getUser("user");
|
||||
|
||||
// Amount Option
|
||||
const optionAmount = options.getInteger('amount');
|
||||
const optionAmount = options.getInteger("amount");
|
||||
|
||||
// If amount is null
|
||||
if (optionAmount === null) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Set]' as string,
|
||||
description: 'We could not read your requested amount.' as string,
|
||||
title: ":toolbox: Admin - Credits [Set]" as string,
|
||||
description: "We could not read your requested amount." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -52,7 +52,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (!toUser) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Set]' as string,
|
||||
title: ":toolbox: Admin - Credits [Set]" as string,
|
||||
description: `We could not find ${optionUser} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
|
@ -70,7 +70,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (!toUser?.credits) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Set]' as string,
|
||||
title: ":toolbox: Admin - Credits [Set]" as string,
|
||||
description:
|
||||
`We could not find credits for ${optionUser} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
|
@ -92,7 +92,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
await toUser?.save()?.then(async () => {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Set]' as string,
|
||||
title: ":toolbox: Admin - Credits [Set]" as string,
|
||||
description: `We have set ${optionUser} to ${creditNoun(
|
||||
optionAmount
|
||||
)}` as string,
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
// Dependencies
|
||||
import { Permissions, CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import { Permissions, CommandInteraction, ColorResolvable } from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../../config.json';
|
||||
import config from "../../../../../config.json";
|
||||
|
||||
// Handlers
|
||||
import logger from '../../../../handlers/logger';
|
||||
import logger from "../../../../handlers/logger";
|
||||
|
||||
// Helpers
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
import creditNoun from "../../../../helpers/creditNoun";
|
||||
|
||||
// Models
|
||||
import fetchUser from '../../../../helpers/fetchUser';
|
||||
import fetchUser from "../../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
|
@ -19,17 +19,17 @@ export default async (interaction: CommandInteraction) => {
|
|||
const { guild, user, options } = interaction;
|
||||
|
||||
// User option
|
||||
const optionUser = options?.getUser('user');
|
||||
const optionUser = options?.getUser("user");
|
||||
|
||||
// Amount option
|
||||
const optionAmount = options?.getInteger('amount');
|
||||
const optionAmount = options?.getInteger("amount");
|
||||
|
||||
// If amount is null
|
||||
if (optionAmount === null) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Take]' as string,
|
||||
description: 'We could not read your requested amount.' as string,
|
||||
title: ":toolbox: Admin - Credits [Take]" as string,
|
||||
description: "We could not read your requested amount." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -46,8 +46,8 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (optionAmount <= 0) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Take]' as string,
|
||||
description: 'You can not take zero credits or below.' as string,
|
||||
title: ":toolbox: Admin - Credits [Take]" as string,
|
||||
description: "You can not take zero credits or below." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -70,7 +70,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (!toUser) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Take]' as string,
|
||||
title: ":toolbox: Admin - Credits [Take]" as string,
|
||||
description: `We could not find ${optionUser} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
|
@ -88,7 +88,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (!toUser?.credits) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Take]' as string,
|
||||
title: ":toolbox: Admin - Credits [Take]" as string,
|
||||
description:
|
||||
`We could not find credits for ${optionUser} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
|
@ -110,7 +110,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
await toUser?.save()?.then(async () => {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Set]' as string,
|
||||
title: ":toolbox: Admin - Credits [Set]" as string,
|
||||
description: `We have taken ${creditNoun(
|
||||
optionAmount
|
||||
)} from ${optionUser}` as string,
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Dependencies
|
||||
import { CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import { CommandInteraction, ColorResolvable } from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../../config.json';
|
||||
import config from "../../../../../config.json";
|
||||
|
||||
// Handlers
|
||||
import logger from '../../../../handlers/logger';
|
||||
import logger from "../../../../handlers/logger";
|
||||
|
||||
// Helpers
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
import saveUser from '../../../../helpers/saveUser';
|
||||
import creditNoun from "../../../../helpers/creditNoun";
|
||||
import saveUser from "../../../../helpers/saveUser";
|
||||
|
||||
// Models
|
||||
import fetchUser from '../../../../helpers/fetchUser';
|
||||
import fetchUser from "../../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
|
@ -20,16 +20,16 @@ export default async (interaction: CommandInteraction) => {
|
|||
const { guild, options, user } = interaction;
|
||||
|
||||
// Get options
|
||||
const optionFromUser = options?.getUser('from');
|
||||
const optionToUser = options?.getUser('to');
|
||||
const optionAmount = options?.getInteger('amount');
|
||||
const optionFromUser = options?.getUser("from");
|
||||
const optionToUser = options?.getUser("to");
|
||||
const optionAmount = options?.getInteger("amount");
|
||||
|
||||
// If amount is null
|
||||
if (optionAmount === null) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Transfer]' as string,
|
||||
description: 'We could not read your requested amount.' as string,
|
||||
title: ":toolbox: Admin - Credits [Transfer]" as string,
|
||||
description: "We could not read your requested amount." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -56,7 +56,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (!fromUser) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Transfer]' as string,
|
||||
title: ":toolbox: Admin - Credits [Transfer]" as string,
|
||||
description:
|
||||
`We could not find ${optionFromUser} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
|
@ -75,7 +75,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (!fromUser?.credits) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Transfer]' as string,
|
||||
title: ":toolbox: Admin - Credits [Transfer]" as string,
|
||||
description:
|
||||
`We could not find credits for ${optionFromUser} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
|
@ -94,7 +94,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (!toUser) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Transfer]' as string,
|
||||
title: ":toolbox: Admin - Credits [Transfer]" as string,
|
||||
description:
|
||||
`We could not find ${optionToUser} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
|
@ -113,7 +113,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (!toUser?.credits) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Transfer]' as string,
|
||||
title: ":toolbox: Admin - Credits [Transfer]" as string,
|
||||
description:
|
||||
`We could not find credits for ${optionToUser} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
|
@ -138,7 +138,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
await saveUser(fromUser, toUser)?.then(async () => {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':toolbox: Admin - Credits [Transfer]' as string,
|
||||
title: ":toolbox: Admin - Credits [Transfer]" as string,
|
||||
description: `You sent ${creditNoun(
|
||||
optionAmount
|
||||
)} from ${optionFromUser} to ${optionToUser}.` as string,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
// Dependencies
|
||||
import { CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import { CommandInteraction, ColorResolvable } from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../config.json';
|
||||
import config from "../../../../config.json";
|
||||
|
||||
// Helpers
|
||||
import creditNoun from '../../../helpers/creditNoun';
|
||||
import creditNoun from "../../../helpers/creditNoun";
|
||||
|
||||
// Models
|
||||
import fetchUser from '../../../helpers/fetchUser';
|
||||
import fetchUser from "../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
|
@ -16,7 +16,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
const { options, user, guild } = interaction;
|
||||
|
||||
// User option
|
||||
const optionUser = options?.getUser('user');
|
||||
const optionUser = options?.getUser("user");
|
||||
|
||||
if (guild === null) return;
|
||||
|
||||
|
@ -27,9 +27,9 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (userDB === null) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':dollar: Credits [Balance]' as string,
|
||||
title: ":dollar: Credits [Balance]" as string,
|
||||
description: `We can not find ${
|
||||
optionUser || 'you'
|
||||
optionUser || "you"
|
||||
} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
|
@ -47,9 +47,9 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (userDB.credits === null) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':dollar: Credits [Balance]' as string,
|
||||
title: ":dollar: Credits [Balance]" as string,
|
||||
description: `We can not find credits for ${
|
||||
optionUser || 'you'
|
||||
optionUser || "you"
|
||||
} in our database.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
|
@ -64,9 +64,9 @@ export default async (interaction: CommandInteraction) => {
|
|||
} else {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':dollar: Credits [Balance]' as string,
|
||||
title: ":dollar: Credits [Balance]" as string,
|
||||
description: `${
|
||||
optionUser ? `${optionUser} has` : 'You have'
|
||||
optionUser ? `${optionUser} has` : "You have"
|
||||
} ${creditNoun(userDB.credits)}.` as string,
|
||||
color: config?.colors?.success as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Dependencies
|
||||
import { CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import { CommandInteraction, ColorResolvable } from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../config.json';
|
||||
import config from "../../../../config.json";
|
||||
|
||||
// Handlers
|
||||
import logger from '../../../handlers/logger';
|
||||
import logger from "../../../handlers/logger";
|
||||
|
||||
// Helpers
|
||||
import saveUser from '../../../helpers/saveUser';
|
||||
import creditNoun from '../../../helpers/creditNoun';
|
||||
import saveUser from "../../../helpers/saveUser";
|
||||
import creditNoun from "../../../helpers/creditNoun";
|
||||
|
||||
// Models
|
||||
import fetchUser from '../../../helpers/fetchUser';
|
||||
import fetchUser from "../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
|
@ -20,13 +20,13 @@ export default async (interaction: CommandInteraction) => {
|
|||
const { options, user, guild, client } = interaction;
|
||||
|
||||
// User option
|
||||
const optionUser = options?.getUser('user');
|
||||
const optionUser = options?.getUser("user");
|
||||
|
||||
// Amount option
|
||||
const optionAmount = options?.getInteger('amount');
|
||||
const optionAmount = options?.getInteger("amount");
|
||||
|
||||
// Reason option
|
||||
const optionReason = options?.getString('reason');
|
||||
const optionReason = options?.getString("reason");
|
||||
|
||||
if (guild === null) return;
|
||||
if (optionUser === null) return;
|
||||
|
@ -44,7 +44,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (optionUser?.id === user?.id) {
|
||||
// Create embed object
|
||||
const embed = {
|
||||
title: ':dollar: Credits [Gift]' as string,
|
||||
title: ":dollar: Credits [Gift]" as string,
|
||||
description: "You can't pay yourself." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
|
@ -62,8 +62,8 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (optionAmount === null) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':dollar: Credits [Gift]' as string,
|
||||
description: 'We could not read your requested amount.' as string,
|
||||
title: ":dollar: Credits [Gift]" as string,
|
||||
description: "We could not read your requested amount." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -80,7 +80,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (optionAmount <= 0) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':dollar: Credits [Gift]' as string,
|
||||
title: ":dollar: Credits [Gift]" as string,
|
||||
description: "You can't pay zero or below." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
|
@ -98,7 +98,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (fromUserDB?.credits < optionAmount) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':dollar: Credits [Gift]' as string,
|
||||
title: ":dollar: Credits [Gift]" as string,
|
||||
description:
|
||||
`You have insufficient credits. Your credits is ${fromUserDB?.credits}` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
|
@ -117,7 +117,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (!toUserDB) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':dollar: Credits [Gift]' as string,
|
||||
title: ":dollar: Credits [Gift]" as string,
|
||||
description:
|
||||
`That user has no credits, I can not gift credits to ${optionUser}` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
|
@ -142,9 +142,9 @@ export default async (interaction: CommandInteraction) => {
|
|||
await saveUser(fromUserDB, toUserDB)?.then(async () => {
|
||||
// Interaction embed object
|
||||
const interactionEmbed = {
|
||||
title: ':dollar: Credits [Gift]',
|
||||
title: ":dollar: Credits [Gift]",
|
||||
description: `You sent ${creditNoun(optionAmount)} to ${optionUser}${
|
||||
optionReason ? ` with reason: ${optionReason}` : ''
|
||||
optionReason ? ` with reason: ${optionReason}` : ""
|
||||
}. Your new credits is ${creditNoun(fromUserDB?.credits)}.`,
|
||||
color: config?.colors?.success as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
|
@ -156,9 +156,9 @@ export default async (interaction: CommandInteraction) => {
|
|||
|
||||
// DM embed object
|
||||
const dmEmbed = {
|
||||
title: ':dollar: Credits [Gift]' as string,
|
||||
title: ":dollar: Credits [Gift]" as string,
|
||||
description: `You received ${creditNoun(optionAmount)} from ${user}${
|
||||
optionReason ? ` with reason: ${optionReason}` : ''
|
||||
optionReason ? ` with reason: ${optionReason}` : ""
|
||||
}. Your new credits is ${creditNoun(toUserDB?.credits)}.` as string,
|
||||
color: config?.colors?.success as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
// Dependencies
|
||||
import { CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import Chance from 'chance';
|
||||
import { CommandInteraction, ColorResolvable } from "discord.js";
|
||||
import Chance from "chance";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../config.json';
|
||||
import config from "../../../../config.json";
|
||||
|
||||
// Handlers
|
||||
import logger from '../../../handlers/logger';
|
||||
import logger from "../../../handlers/logger";
|
||||
|
||||
// Models
|
||||
import timeouts from '../../../helpers/database/models/timeoutSchema';
|
||||
import timeouts from "../../../helpers/database/models/timeoutSchema";
|
||||
|
||||
// Helpers
|
||||
import creditNoun from '../../../helpers/creditNoun';
|
||||
import fetchUser from '../../../helpers/fetchUser';
|
||||
import fetchGuild from '../../../helpers/fetchGuild';
|
||||
import creditNoun from "../../../helpers/creditNoun";
|
||||
import fetchUser from "../../../helpers/fetchUser";
|
||||
import fetchGuild from "../../../helpers/fetchGuild";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
|
@ -28,7 +28,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
const isTimeout = await timeouts?.findOne({
|
||||
guildId: guild?.id,
|
||||
userId: user?.id,
|
||||
timeoutId: '2022-03-15-19-16',
|
||||
timeoutId: "2022-03-15-19-16",
|
||||
});
|
||||
|
||||
if (guild === null) return;
|
||||
|
@ -54,7 +54,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
|
||||
// Create embed object
|
||||
const embed = {
|
||||
title: ':dollar: Credits [Work]' as string,
|
||||
title: ":dollar: Credits [Work]" as string,
|
||||
description: `You have earned ${creditNoun(creditsEarned)}` as string,
|
||||
color: config?.colors?.success as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
|
@ -72,7 +72,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
await timeouts?.create({
|
||||
guildId: guild?.id,
|
||||
userId: user?.id,
|
||||
timeoutId: '2022-03-15-19-16',
|
||||
timeoutId: "2022-03-15-19-16",
|
||||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
|
@ -87,13 +87,13 @@ export default async (interaction: CommandInteraction) => {
|
|||
await timeouts?.deleteOne({
|
||||
guildId: guild?.id,
|
||||
userId: user?.id,
|
||||
timeoutId: '2022-03-15-19-16',
|
||||
timeoutId: "2022-03-15-19-16",
|
||||
});
|
||||
}, guildDB?.credits?.workTimeout);
|
||||
} else {
|
||||
// Create embed object
|
||||
const embed = {
|
||||
title: ':dollar: Credits [Work]' as string,
|
||||
title: ":dollar: Credits [Work]" as string,
|
||||
description: `You have worked within the last ${
|
||||
guildDB?.credits?.workTimeout / 1000
|
||||
} seconds, you can not work now!` as string,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Dependencies
|
||||
import { CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import { CommandInteraction, ColorResolvable } from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../config.json';
|
||||
import config from "../../../../config.json";
|
||||
|
||||
// Models
|
||||
import fetchUser from '../../../helpers/fetchUser';
|
||||
import fetchUser from "../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
|
@ -13,7 +13,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
const { client, options, user, guild } = interaction;
|
||||
|
||||
// Target information
|
||||
const target = options?.getUser('target');
|
||||
const target = options?.getUser("target");
|
||||
|
||||
// Discord User Information
|
||||
const discordUser = await client?.users?.fetch(
|
||||
|
@ -35,27 +35,27 @@ export default async (interaction: CommandInteraction) => {
|
|||
fields: [
|
||||
{
|
||||
name: `:dollar: Credits` as string,
|
||||
value: `${userObj?.credits || 'Not found'}` as string,
|
||||
value: `${userObj?.credits || "Not found"}` as string,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `:squeeze_bottle: Level` as string,
|
||||
value: `${userObj?.level || 'Not found'}` as string,
|
||||
value: `${userObj?.level || "Not found"}` as string,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `:squeeze_bottle: Points` as string,
|
||||
value: `${userObj?.points || 'Not found'}` as string,
|
||||
value: `${userObj?.points || "Not found"}` as string,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `:loudspeaker: Reputation` as string,
|
||||
value: `${userObj?.reputation || 'Not found'}` as string,
|
||||
value: `${userObj?.reputation || "Not found"}` as string,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `:rainbow_flag: Language` as string,
|
||||
value: `${userObj?.language || 'Not found'}` as string,
|
||||
value: `${userObj?.language || "Not found"}` as string,
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
// Dependencies
|
||||
import { CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import { CommandInteraction, ColorResolvable } from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../config.json';
|
||||
import config from "../../../../config.json";
|
||||
|
||||
// Handlers
|
||||
import logger from '../../../handlers/logger';
|
||||
import logger from "../../../handlers/logger";
|
||||
|
||||
// Models
|
||||
import timeoutSchema from '../../../helpers/database/models/timeoutSchema';
|
||||
import fetchUser from '../../../helpers/fetchUser';
|
||||
import timeoutSchema from "../../../helpers/database/models/timeoutSchema";
|
||||
import fetchUser from "../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
|
@ -17,10 +17,10 @@ export default async (interaction: CommandInteraction) => {
|
|||
const { options, user, guild } = interaction;
|
||||
|
||||
// Target option
|
||||
const optionTarget = options?.getUser('target');
|
||||
const optionTarget = options?.getUser("target");
|
||||
|
||||
// Type information
|
||||
const optionType = options?.getString('type');
|
||||
const optionType = options?.getString("type");
|
||||
|
||||
if (guild === null) return;
|
||||
|
||||
|
@ -33,7 +33,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
const isTimeout = await timeoutSchema?.findOne({
|
||||
guildId: guild?.id,
|
||||
userId: user?.id,
|
||||
timeoutId: '2022-04-10-16-42',
|
||||
timeoutId: "2022-04-10-16-42",
|
||||
});
|
||||
|
||||
// If user is not on timeout
|
||||
|
@ -42,8 +42,8 @@ export default async (interaction: CommandInteraction) => {
|
|||
if (optionTarget?.id === user?.id) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':loudspeaker: Reputation [Give]' as string,
|
||||
description: 'You can not repute yourself.' as string,
|
||||
title: ":loudspeaker: Reputation [Give]" as string,
|
||||
description: "You can not repute yourself." as string,
|
||||
timestamp: new Date() as Date,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
footer: {
|
||||
|
@ -57,12 +57,12 @@ export default async (interaction: CommandInteraction) => {
|
|||
}
|
||||
|
||||
// If type is positive
|
||||
if (optionType === 'positive') {
|
||||
if (optionType === "positive") {
|
||||
userObj.reputation += 1;
|
||||
}
|
||||
|
||||
// If type is negative
|
||||
else if (optionType === 'negative') {
|
||||
else if (optionType === "negative") {
|
||||
userObj.reputation -= 1;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
await userObj?.save()?.then(async () => {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':loudspeaker: Reputation [Give]' as string,
|
||||
title: ":loudspeaker: Reputation [Give]" as string,
|
||||
description:
|
||||
`You have given ${optionTarget} a ${optionType} reputation!` as string,
|
||||
timestamp: new Date() as Date,
|
||||
|
@ -90,7 +90,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
await timeoutSchema?.create({
|
||||
guildId: guild?.id,
|
||||
userId: user?.id,
|
||||
timeoutId: '2022-04-10-16-42',
|
||||
timeoutId: "2022-04-10-16-42",
|
||||
});
|
||||
// Return interaction reply
|
||||
return await interaction?.editReply({ embeds: [embed] });
|
||||
|
@ -108,13 +108,13 @@ export default async (interaction: CommandInteraction) => {
|
|||
await timeoutSchema?.deleteOne({
|
||||
guildId: guild?.id,
|
||||
userId: user?.id,
|
||||
timeoutId: '2022-04-10-16-42',
|
||||
timeoutId: "2022-04-10-16-42",
|
||||
});
|
||||
}, config?.reputation?.timeout);
|
||||
} else {
|
||||
// Create embed object
|
||||
const embed = {
|
||||
title: ':loudspeaker: Reputation [Give]' as string,
|
||||
title: ":loudspeaker: Reputation [Give]" as string,
|
||||
description: `You have given reputation within the last ${
|
||||
config?.reputation?.timeout / 1000
|
||||
} seconds, you can not repute now!` as string,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
// Dependencies
|
||||
import { CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import { CommandInteraction, ColorResolvable } from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../../config.json';
|
||||
import config from "../../../../../config.json";
|
||||
|
||||
// Handlers
|
||||
import logger from '../../../../handlers/logger';
|
||||
import logger from "../../../../handlers/logger";
|
||||
|
||||
// Models
|
||||
import fetchUser from '../../../../helpers/fetchUser';
|
||||
import fetchUser from "../../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
|
@ -16,7 +16,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
const { options, user, guild } = interaction;
|
||||
|
||||
// Get options
|
||||
const language = options?.getString('language');
|
||||
const language = options?.getString("language");
|
||||
|
||||
if (guild === null) return;
|
||||
|
||||
|
@ -32,12 +32,12 @@ export default async (interaction: CommandInteraction) => {
|
|||
await userDB?.save()?.then(async () => {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':hammer: Settings - User [Appearance]' as string,
|
||||
description: 'Following settings is set!' as string,
|
||||
title: ":hammer: Settings - User [Appearance]" as string,
|
||||
description: "Following settings is set!" as string,
|
||||
color: config?.colors?.success as ColorResolvable,
|
||||
fields: [
|
||||
{
|
||||
name: '🏳️🌈 Language' as string,
|
||||
name: "🏳️🌈 Language" as string,
|
||||
value: `${userDB?.language}` as string,
|
||||
inline: true,
|
||||
},
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
// Dependencies
|
||||
import { CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import axios from 'axios';
|
||||
import { CommandInteraction, ColorResolvable } from "discord.js";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import axios from "axios";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../config.json';
|
||||
import config from "../../../../config.json";
|
||||
|
||||
// Handlers
|
||||
import logger from '../../../handlers/logger';
|
||||
import logger from "../../../handlers/logger";
|
||||
|
||||
// Helpers
|
||||
import creditNoun from '../../../helpers/creditNoun';
|
||||
import creditNoun from "../../../helpers/creditNoun";
|
||||
|
||||
// Models
|
||||
import apiSchema from '../../../helpers/database/models/apiSchema';
|
||||
import fetchUser from '../../../helpers/fetchUser';
|
||||
import apiSchema from "../../../helpers/database/models/apiSchema";
|
||||
import fetchUser from "../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
const { options, guild, user, client } = interaction;
|
||||
|
||||
// Get options
|
||||
const optionAmount = options?.getInteger('amount');
|
||||
const optionAmount = options?.getInteger("amount");
|
||||
|
||||
// If amount is null
|
||||
if (optionAmount === null) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':dollar: Credits [Gift]' as string,
|
||||
description: 'We could not read your requested amount.' as string,
|
||||
title: ":dollar: Credits [Gift]" as string,
|
||||
description: "We could not read your requested amount." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -54,13 +54,13 @@ export default async (interaction: CommandInteraction) => {
|
|||
// Stop if amount or user credits is below 100
|
||||
if ((optionAmount || userDB?.credits) < 100) {
|
||||
const embed = {
|
||||
title: ':shopping_cart: Shop [Pterodactyl]' as string,
|
||||
title: ":shopping_cart: Shop [Pterodactyl]" as string,
|
||||
description:
|
||||
`You **can't** withdraw for __Pterodactyl__ below **100**.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
fields: [
|
||||
{
|
||||
name: 'Your balance' as string,
|
||||
name: "Your balance" as string,
|
||||
value: `${creditNoun(userDB?.credits)}` as string,
|
||||
},
|
||||
],
|
||||
|
@ -76,13 +76,13 @@ export default async (interaction: CommandInteraction) => {
|
|||
// Stop if amount or user credits is above 1.000.000
|
||||
if ((optionAmount || userDB?.credits) > 1000000) {
|
||||
const embed = {
|
||||
title: ':shopping_cart: Shop [Pterodactyl]' as string,
|
||||
title: ":shopping_cart: Shop [Pterodactyl]" as string,
|
||||
description:
|
||||
`You **can't** withdraw for __Pterodactyl__ above **1.000.000**.` as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
fields: [
|
||||
{
|
||||
name: 'Your balance' as string,
|
||||
name: "Your balance" as string,
|
||||
value: `${creditNoun(userDB?.credits)}` as string,
|
||||
},
|
||||
],
|
||||
|
@ -98,12 +98,12 @@ export default async (interaction: CommandInteraction) => {
|
|||
// Stop if user credits is below amount
|
||||
if (userDB?.credits < optionAmount) {
|
||||
const embed = {
|
||||
title: ':shopping_cart: Shop [Pterodactyl]' as string,
|
||||
title: ":shopping_cart: Shop [Pterodactyl]" as string,
|
||||
description: `You have **insufficient** credits.` as string,
|
||||
color: config.colors.error as ColorResolvable,
|
||||
fields: [
|
||||
{
|
||||
name: 'Your balance' as string,
|
||||
name: "Your balance" as string,
|
||||
value: `${creditNoun(userDB?.credits)}` as string,
|
||||
},
|
||||
],
|
||||
|
@ -131,13 +131,13 @@ export default async (interaction: CommandInteraction) => {
|
|||
});
|
||||
|
||||
// Get shop URL
|
||||
const shopUrl = apiCredentials?.url?.replace('/api', '/store');
|
||||
const shopUrl = apiCredentials?.url?.replace("/api", "/store");
|
||||
|
||||
// Make API request
|
||||
await api
|
||||
|
||||
// Make a post request to the API
|
||||
?.post('vouchers', {
|
||||
?.post("vouchers", {
|
||||
uses: 1,
|
||||
code,
|
||||
credits: optionAmount || userDB?.credits,
|
||||
|
@ -148,12 +148,12 @@ export default async (interaction: CommandInteraction) => {
|
|||
?.then(async () => {
|
||||
// Create DM embed object
|
||||
const dmEmbed = {
|
||||
title: ':shopping_cart: Shop [Pterodactyl]' as string,
|
||||
title: ":shopping_cart: Shop [Pterodactyl]" as string,
|
||||
description: `Redeem this voucher [here](${shopUrl})!` as string,
|
||||
fields: [
|
||||
{ name: 'Code' as string, value: `${code}` as string, inline: true },
|
||||
{ name: "Code" as string, value: `${code}` as string, inline: true },
|
||||
{
|
||||
name: 'Credits' as string,
|
||||
name: "Credits" as string,
|
||||
value: `${optionAmount || userDB?.credits}` as string,
|
||||
inline: true,
|
||||
},
|
||||
|
@ -168,8 +168,8 @@ export default async (interaction: CommandInteraction) => {
|
|||
|
||||
// Create interaction embed object
|
||||
const interactionEmbed = {
|
||||
title: ':shopping_cart: Shop [Pterodactyl]' as string,
|
||||
description: 'I have sent you the code in DM!' as string,
|
||||
title: ":shopping_cart: Shop [Pterodactyl]" as string,
|
||||
description: "I have sent you the code in DM!" as string,
|
||||
color: config?.colors?.success as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -204,9 +204,9 @@ export default async (interaction: CommandInteraction) => {
|
|||
.catch(async (e: any) => {
|
||||
logger?.error(e);
|
||||
const embed = {
|
||||
title: ':shopping_cart: Shop [Pterodactyl]' as string,
|
||||
title: ":shopping_cart: Shop [Pterodactyl]" as string,
|
||||
description:
|
||||
'Something went wrong, please try again later.' as string,
|
||||
"Something went wrong, please try again later." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -222,8 +222,8 @@ export default async (interaction: CommandInteraction) => {
|
|||
.catch(async (e) => {
|
||||
logger?.error(e);
|
||||
const embed = {
|
||||
title: ':shopping_cart: Shop [Pterodactyl]' as string,
|
||||
description: 'Something went wrong, please try again later.' as string,
|
||||
title: ":shopping_cart: Shop [Pterodactyl]" as string,
|
||||
description: "Something went wrong, please try again later." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
|
|
@ -3,31 +3,31 @@ import {
|
|||
CommandInteraction,
|
||||
ColorResolvable,
|
||||
GuildMemberRoleManager,
|
||||
} from 'discord.js';
|
||||
} from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../../config.json';
|
||||
import config from "../../../../../config.json";
|
||||
|
||||
// Models
|
||||
import shopRolesSchema from '../../../../helpers/database/models/shopRolesSchema';
|
||||
import guildSchema from '../../../../helpers/database/models/guildSchema';
|
||||
import shopRolesSchema from "../../../../helpers/database/models/shopRolesSchema";
|
||||
import guildSchema from "../../../../helpers/database/models/guildSchema";
|
||||
|
||||
// Helpers
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
import fetchUser from '../../../../helpers/fetchUser';
|
||||
import creditNoun from "../../../../helpers/creditNoun";
|
||||
import fetchUser from "../../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
const { options, guild, user, member } = interaction;
|
||||
|
||||
const optionName = options?.getString('name');
|
||||
const optionName = options?.getString("name");
|
||||
|
||||
// If amount is null
|
||||
if (optionName === null) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':dollar: Shop - Roles [Buy]' as string,
|
||||
description: 'We could not read your requested name.' as string,
|
||||
title: ":dollar: Shop - Roles [Buy]" as string,
|
||||
description: "We could not read your requested name." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -43,7 +43,7 @@ export default async (interaction: CommandInteraction) => {
|
|||
await guild?.roles
|
||||
.create({
|
||||
name: optionName,
|
||||
color: 'RED',
|
||||
color: "RED",
|
||||
reason: `${user?.id} bought from shop`,
|
||||
})
|
||||
.then(async (role) => {
|
||||
|
@ -74,13 +74,13 @@ export default async (interaction: CommandInteraction) => {
|
|||
await shopRolesSchema?.find()?.then((role: any) => console.log(role));
|
||||
|
||||
const embed = {
|
||||
title: ':shopping_cart: Shop - Roles [Buy]' as string,
|
||||
title: ":shopping_cart: Shop - Roles [Buy]" as string,
|
||||
description:
|
||||
`You have bought ${role?.name} for ${guildDB?.shop?.roles?.pricePerHour} per hour.` as string,
|
||||
color: config?.colors?.success as ColorResolvable,
|
||||
fields: [
|
||||
{
|
||||
name: 'Your balance' as string,
|
||||
name: "Your balance" as string,
|
||||
value: `${creditNoun(userDB?.credits)}` as string,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -3,30 +3,30 @@ import {
|
|||
CommandInteraction,
|
||||
ColorResolvable,
|
||||
GuildMemberRoleManager,
|
||||
} from 'discord.js';
|
||||
} from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../../config.json';
|
||||
import config from "../../../../../config.json";
|
||||
|
||||
// Models
|
||||
import shopRolesSchema from '../../../../helpers/database/models/shopRolesSchema';
|
||||
import shopRolesSchema from "../../../../helpers/database/models/shopRolesSchema";
|
||||
|
||||
// Helpers
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
import fetchUser from '../../../../helpers/fetchUser';
|
||||
import creditNoun from "../../../../helpers/creditNoun";
|
||||
import fetchUser from "../../../../helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
const { options, guild, user, member } = interaction;
|
||||
|
||||
const optionRole = options.getRole('role');
|
||||
const optionRole = options.getRole("role");
|
||||
|
||||
// If amount is null
|
||||
if (optionRole === null) {
|
||||
// Embed object
|
||||
const embed = {
|
||||
title: ':dollar: Shop - Roles [Cancel]' as string,
|
||||
description: 'We could not read your requested role.' as string,
|
||||
title: ":dollar: Shop - Roles [Cancel]" as string,
|
||||
description: "We could not read your requested role." as string,
|
||||
color: config?.colors?.error as ColorResolvable,
|
||||
timestamp: new Date() as Date,
|
||||
footer: {
|
||||
|
@ -62,12 +62,12 @@ export default async (interaction: CommandInteraction) => {
|
|||
});
|
||||
|
||||
const embed = {
|
||||
title: ':shopping_cart: Shop - Roles [Cancel]' as string,
|
||||
title: ":shopping_cart: Shop - Roles [Cancel]" as string,
|
||||
description: `You have canceled ${optionRole.name}.` as string,
|
||||
color: config?.colors?.success as ColorResolvable,
|
||||
fields: [
|
||||
{
|
||||
name: 'Your balance' as string,
|
||||
name: "Your balance" as string,
|
||||
value: `${creditNoun(userDB?.credits)}` as string,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// Dependencies
|
||||
import { Guild } from 'discord.js';
|
||||
import { Guild } from "discord.js";
|
||||
|
||||
// Helpers
|
||||
import updatePresence from '../../helpers/updatePresence';
|
||||
import fetchGuild from '../../helpers/fetchGuild';
|
||||
import updatePresence from "../../helpers/updatePresence";
|
||||
import fetchGuild from "../../helpers/fetchGuild";
|
||||
|
||||
// Function
|
||||
export default {
|
||||
name: 'guildCreate',
|
||||
name: "guildCreate",
|
||||
async execute(guild: Guild) {
|
||||
// Destructure
|
||||
const { client } = guild;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// Dependencies
|
||||
import { Guild } from 'discord.js';
|
||||
import { Guild } from "discord.js";
|
||||
|
||||
// Helpers
|
||||
import updatePresence from '../../helpers/updatePresence';
|
||||
import dropGuild from '../../helpers/dropGuild';
|
||||
import updatePresence from "../../helpers/updatePresence";
|
||||
import dropGuild from "../../helpers/dropGuild";
|
||||
|
||||
// Function
|
||||
export default {
|
||||
name: 'guildDelete',
|
||||
name: "guildDelete",
|
||||
async execute(guild: Guild) {
|
||||
// Destructure client
|
||||
const { client } = guild;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import users from '../../helpers/database/models/userSchema';
|
||||
import logger from '../../handlers/logger';
|
||||
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';
|
||||
import { GuildMember } from "discord.js";
|
||||
import updatePresence from "../../helpers/updatePresence";
|
||||
import fetchUser from "../../helpers/fetchUser";
|
||||
|
||||
export default {
|
||||
name: 'guildMemberAdd',
|
||||
name: "guildMemberAdd",
|
||||
async execute(member: GuildMember) {
|
||||
const { client, user, guild } = member;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import users from '../../helpers/database/models/userSchema';
|
||||
import logger from '../../handlers/logger';
|
||||
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';
|
||||
import { GuildMember } from "discord.js";
|
||||
import updatePresence from "../../helpers/updatePresence";
|
||||
import dropUser from "../../helpers/dropUser";
|
||||
|
||||
export default {
|
||||
name: 'guildMemberRemove',
|
||||
name: "guildMemberRemove",
|
||||
async execute(member: GuildMember) {
|
||||
const { client, user, guild } = member;
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import config from '../../../config.json';
|
||||
import logger from '../../handlers/logger';
|
||||
import guilds from '../../helpers/database/models/guildSchema';
|
||||
import config from "../../../config.json";
|
||||
import logger from "../../handlers/logger";
|
||||
import guilds from "../../helpers/database/models/guildSchema";
|
||||
|
||||
import { Interaction, ColorResolvable } from 'discord.js';
|
||||
import { Interaction, ColorResolvable } from "discord.js";
|
||||
|
||||
export default {
|
||||
name: 'interactionCreate',
|
||||
name: "interactionCreate",
|
||||
async execute(interaction: Interaction) {
|
||||
// Destructure member, client
|
||||
const { client, guild } = interaction;
|
||||
|
@ -41,10 +41,10 @@ export default {
|
|||
author: {
|
||||
name: client?.user?.username,
|
||||
icon_url: client?.user?.displayAvatarURL(),
|
||||
url: 'https://bot.zyner.org/',
|
||||
url: "https://bot.zyner.org/",
|
||||
},
|
||||
title: 'Error',
|
||||
description: 'There was an error while executing this command!',
|
||||
title: "Error",
|
||||
description: "There was an error while executing this command!",
|
||||
color: config.colors.error as ColorResolvable,
|
||||
timestamp: new Date(),
|
||||
},
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
// 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';
|
||||
import counters from './modules/counters';
|
||||
import fetchUser from '../../helpers/fetchUser';
|
||||
import fetchGuild from '../../helpers/fetchGuild';
|
||||
|
||||
// Function
|
||||
export default {
|
||||
name: 'messageCreate',
|
||||
async execute(message: Message) {
|
||||
const { author, guild } = message;
|
||||
|
||||
// If message author is bot
|
||||
if (author?.bot) return;
|
||||
|
||||
if (guild === null) return;
|
||||
|
||||
// Get guild object
|
||||
const guildObj = await fetchGuild(guild);
|
||||
|
||||
// Get guild object
|
||||
const userObj = await fetchUser(author, guild);
|
||||
|
||||
// Execute Module - Credits
|
||||
await credits(guildObj, userObj, message);
|
||||
|
||||
// Execute Module - Points
|
||||
await points(guildObj, userObj, message);
|
||||
|
||||
// Execute Module - Counters
|
||||
await counters(guildObj, userObj, message);
|
||||
},
|
||||
};
|
||||
// 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";
|
||||
import counters from "./modules/counters";
|
||||
import fetchUser from "../../helpers/fetchUser";
|
||||
import fetchGuild from "../../helpers/fetchGuild";
|
||||
|
||||
// Function
|
||||
export default {
|
||||
name: "messageCreate",
|
||||
async execute(message: Message) {
|
||||
const { author, guild } = message;
|
||||
|
||||
// If message author is bot
|
||||
if (author?.bot) return;
|
||||
|
||||
if (guild === null) return;
|
||||
|
||||
// Get guild object
|
||||
const guildObj = await fetchGuild(guild);
|
||||
|
||||
// Get guild object
|
||||
const userObj = await fetchUser(author, guild);
|
||||
|
||||
// Execute Module - Credits
|
||||
await credits(guildObj, userObj, message);
|
||||
|
||||
// Execute Module - Points
|
||||
await points(guildObj, userObj, message);
|
||||
|
||||
// Execute Module - Counters
|
||||
await counters(guildObj, userObj, message);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import logger from '../../../handlers/logger';
|
||||
import counters from '../../../helpers/database/models/counterSchema';
|
||||
import logger from "../../../handlers/logger";
|
||||
import counters from "../../../helpers/database/models/counterSchema";
|
||||
|
||||
import { Message } from 'discord.js';
|
||||
import { Message } from "discord.js";
|
||||
|
||||
export default async (guildDB: any, userDB: any, message: Message) => {
|
||||
const { guild, channel, content } = message;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import counters from '../../helpers/database/models/counterSchema';
|
||||
import { Message } from 'discord.js';
|
||||
import counters from "../../helpers/database/models/counterSchema";
|
||||
import { Message } from "discord.js";
|
||||
export default {
|
||||
name: 'messageUpdate',
|
||||
name: "messageUpdate",
|
||||
async execute(oldMessage: Message, newMessage: Message) {
|
||||
// If message author is bot
|
||||
if (newMessage.author.bot) return;
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import logger from '../../handlers/logger';
|
||||
import config from '../../../config.json';
|
||||
import deployCommands from '../../helpers/deployCommands';
|
||||
import dbGuildFix from '../../helpers/dbGuildFix';
|
||||
import dbMemberFix from '../../helpers/dbMemberFix';
|
||||
import logger from "../../handlers/logger";
|
||||
import config from "../../../config.json";
|
||||
import deployCommands from "../../helpers/deployCommands";
|
||||
import dbGuildFix from "../../helpers/dbGuildFix";
|
||||
import dbMemberFix from "../../helpers/dbMemberFix";
|
||||
|
||||
import userSchema from '../../helpers/database/models/userSchema';
|
||||
import userSchema from "../../helpers/database/models/userSchema";
|
||||
|
||||
import { Client } from 'discord.js';
|
||||
import updatePresence from '../../helpers/updatePresence';
|
||||
import { Client } from "discord.js";
|
||||
import updatePresence from "../../helpers/updatePresence";
|
||||
export default {
|
||||
name: 'ready',
|
||||
name: "ready",
|
||||
once: true,
|
||||
async execute(client: Client) {
|
||||
// Send info message
|
||||
|
|
|
@ -1,59 +1,59 @@
|
|||
import schedule from 'node-schedule';
|
||||
import users from '../helpers/database/models/userSchema';
|
||||
import shopRoles from '../helpers/database/models/shopRolesSchema';
|
||||
import guilds from '../helpers/database/models/guildSchema';
|
||||
import logger from './logger';
|
||||
import { Client } from 'discord.js';
|
||||
|
||||
export default async (client: Client) => {
|
||||
schedule.scheduleJob('*/5 * * * *', async () => {
|
||||
shopRoles.find().then(async (shopRoles: any) => {
|
||||
shopRoles.map(async (shopRole: any) => {
|
||||
const payed = new Date(shopRole.lastPayed);
|
||||
|
||||
const oneHourAfterPayed = payed.setHours(payed.getHours() + 1);
|
||||
|
||||
if (new Date() > new Date(oneHourAfterPayed)) {
|
||||
logger.debug(
|
||||
`Role: ${shopRole.roleId} Expires: ${
|
||||
new Date() < new Date(oneHourAfterPayed)
|
||||
} Last Payed: ${shopRole.lastPayed}`
|
||||
);
|
||||
|
||||
// Get guild object
|
||||
const guild = await guilds.findOne({
|
||||
guildId: shopRole.guildId,
|
||||
});
|
||||
|
||||
const userDB = await users.findOne({
|
||||
userId: shopRole.userId,
|
||||
guildId: shopRole.guildId,
|
||||
});
|
||||
const { pricePerHour } = guild.shop.roles;
|
||||
|
||||
if (userDB === null) return;
|
||||
|
||||
if (userDB.credits < pricePerHour) {
|
||||
const rGuild = await client.guilds.cache.get(`${shopRole.guildId}`);
|
||||
const rMember = await rGuild?.members.fetch(`${shopRole.userId}`);
|
||||
|
||||
await rMember?.roles
|
||||
.remove(`${shopRole.roleId}`)
|
||||
.then(async (test) => console.log('4', test))
|
||||
.catch(async (test) => console.log('5', test)); // Removes all roles
|
||||
}
|
||||
|
||||
shopRole.lastPayed = new Date();
|
||||
shopRole.save();
|
||||
userDB.credits -= pricePerHour;
|
||||
userDB.save();
|
||||
await logger.debug(
|
||||
`${shopRole.roleId} was payed one hour later. BEFORE: ${payed} AFTER: ${oneHourAfterPayed} UPDATED: ${shopRole.updatedAt} CREATED: ${shopRole.createdAt}`
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await logger.debug('Checking schedules! (Every 5 minutes)');
|
||||
});
|
||||
};
|
||||
import schedule from "node-schedule";
|
||||
import users from "../helpers/database/models/userSchema";
|
||||
import shopRoles from "../helpers/database/models/shopRolesSchema";
|
||||
import guilds from "../helpers/database/models/guildSchema";
|
||||
import logger from "./logger";
|
||||
import { Client } from "discord.js";
|
||||
|
||||
export default async (client: Client) => {
|
||||
schedule.scheduleJob("*/5 * * * *", async () => {
|
||||
shopRoles.find().then(async (shopRoles: any) => {
|
||||
shopRoles.map(async (shopRole: any) => {
|
||||
const payed = new Date(shopRole.lastPayed);
|
||||
|
||||
const oneHourAfterPayed = payed.setHours(payed.getHours() + 1);
|
||||
|
||||
if (new Date() > new Date(oneHourAfterPayed)) {
|
||||
logger.debug(
|
||||
`Role: ${shopRole.roleId} Expires: ${
|
||||
new Date() < new Date(oneHourAfterPayed)
|
||||
} Last Payed: ${shopRole.lastPayed}`
|
||||
);
|
||||
|
||||
// Get guild object
|
||||
const guild = await guilds.findOne({
|
||||
guildId: shopRole.guildId,
|
||||
});
|
||||
|
||||
const userDB = await users.findOne({
|
||||
userId: shopRole.userId,
|
||||
guildId: shopRole.guildId,
|
||||
});
|
||||
const { pricePerHour } = guild.shop.roles;
|
||||
|
||||
if (userDB === null) return;
|
||||
|
||||
if (userDB.credits < pricePerHour) {
|
||||
const rGuild = await client.guilds.cache.get(`${shopRole.guildId}`);
|
||||
const rMember = await rGuild?.members.fetch(`${shopRole.userId}`);
|
||||
|
||||
await rMember?.roles
|
||||
.remove(`${shopRole.roleId}`)
|
||||
.then(async (test) => console.log("4", test))
|
||||
.catch(async (test) => console.log("5", test)); // Removes all roles
|
||||
}
|
||||
|
||||
shopRole.lastPayed = new Date();
|
||||
shopRole.save();
|
||||
userDB.credits -= pricePerHour;
|
||||
userDB.save();
|
||||
await logger.debug(
|
||||
`${shopRole.roleId} was payed one hour later. BEFORE: ${payed} AFTER: ${oneHourAfterPayed} UPDATED: ${shopRole.updatedAt} CREATED: ${shopRole.createdAt}`
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await logger.debug("Checking schedules! (Every 5 minutes)");
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
import { Snowflake } from 'discord.js';
|
||||
import { Schema, model } from 'mongoose';
|
||||
|
||||
export interface IUser {
|
||||
guildId: Snowflake;
|
||||
userId: Snowflake;
|
||||
language: string;
|
||||
reputation: number;
|
||||
credits: number;
|
||||
level: number;
|
||||
points: number;
|
||||
updatedAt: Date;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
const userSchema = new Schema(
|
||||
{
|
||||
guildId: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
userId: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
language: {
|
||||
type: String,
|
||||
default: 'en',
|
||||
},
|
||||
reputation: { type: Number, default: 0 },
|
||||
credits: { type: Number, default: 0 },
|
||||
level: { type: Number, default: 0 },
|
||||
points: { type: Number, default: 0 },
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default model<IUser>('user', userSchema);
|
||||
import { Snowflake } from "discord.js";
|
||||
import { Schema, model } from "mongoose";
|
||||
|
||||
export interface IUser {
|
||||
guildId: Snowflake;
|
||||
userId: Snowflake;
|
||||
language: string;
|
||||
reputation: number;
|
||||
credits: number;
|
||||
level: number;
|
||||
points: number;
|
||||
updatedAt: Date;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
const userSchema = new Schema(
|
||||
{
|
||||
guildId: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
userId: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
language: {
|
||||
type: String,
|
||||
default: "en",
|
||||
},
|
||||
reputation: { type: Number, default: 0 },
|
||||
credits: { type: Number, default: 0 },
|
||||
level: { type: Number, default: 0 },
|
||||
points: { type: Number, default: 0 },
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default model<IUser>("user", userSchema);
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import guilds from '../helpers/database/models/guildSchema';
|
||||
import users from '../helpers/database/models/userSchema';
|
||||
import apis from '../helpers/database/models/apiSchema';
|
||||
import counters from '../helpers/database/models/counterSchema';
|
||||
import shopRoles from '../helpers/database/models/shopRolesSchema';
|
||||
import timeouts from '../helpers/database/models/timeoutSchema';
|
||||
import guilds from "../helpers/database/models/guildSchema";
|
||||
import users from "../helpers/database/models/userSchema";
|
||||
import apis from "../helpers/database/models/apiSchema";
|
||||
import counters from "../helpers/database/models/counterSchema";
|
||||
import shopRoles from "../helpers/database/models/shopRolesSchema";
|
||||
import timeouts from "../helpers/database/models/timeoutSchema";
|
||||
|
||||
import logger from '../handlers/logger';
|
||||
import logger from "../handlers/logger";
|
||||
|
||||
import { Guild } from 'discord.js';
|
||||
import updatePresence from '../helpers/updatePresence';
|
||||
import { Guild } from "discord.js";
|
||||
import updatePresence from "../helpers/updatePresence";
|
||||
|
||||
export default async (guild: Guild) => {
|
||||
guilds
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import users from '../helpers/database/models/userSchema';
|
||||
import users from "../helpers/database/models/userSchema";
|
||||
|
||||
import logger from '../handlers/logger';
|
||||
import logger from "../handlers/logger";
|
||||
|
||||
import { Guild, User } from 'discord.js';
|
||||
import { Guild, User } from "discord.js";
|
||||
|
||||
export default async (user: User, guild: Guild) => {
|
||||
await users
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Dependencies
|
||||
import { Guild } from 'discord.js';
|
||||
import { Guild } from "discord.js";
|
||||
|
||||
// Models
|
||||
import guildSchema from './database/models/guildSchema';
|
||||
import guildSchema from "./database/models/guildSchema";
|
||||
|
||||
// Handlers
|
||||
import logger from '../handlers/logger';
|
||||
import logger from "../handlers/logger";
|
||||
|
||||
// Function
|
||||
export default async (guild: Guild) => {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Dependencies
|
||||
import { Guild, User } from 'discord.js';
|
||||
import { Guild, User } from "discord.js";
|
||||
|
||||
// Models
|
||||
import userSchema from './database/models/userSchema';
|
||||
import userSchema from "./database/models/userSchema";
|
||||
|
||||
// Handlers
|
||||
import logger from '../handlers/logger';
|
||||
import logger from "../handlers/logger";
|
||||
|
||||
// Function
|
||||
export default async (user: User, guild: Guild) => {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// Dependencies
|
||||
import { Client } from 'discord.js';
|
||||
import { Client } from "discord.js";
|
||||
|
||||
// Function
|
||||
export default async (client: Client) => {
|
||||
// Set client status
|
||||
client?.user?.setPresence({
|
||||
activities: [
|
||||
{ type: 'WATCHING', name: `${client?.guilds?.cache?.size} guilds` },
|
||||
{ type: "WATCHING", name: `${client?.guilds?.cache?.size} guilds` },
|
||||
],
|
||||
status: 'online',
|
||||
status: "online",
|
||||
});
|
||||
};
|
||||
|
|
14
src/index.ts
14
src/index.ts
|
@ -1,13 +1,13 @@
|
|||
// Dependencies
|
||||
import { Client, Intents } from 'discord.js'; // discord.js
|
||||
import { Client, Intents } from "discord.js"; // discord.js
|
||||
|
||||
import database from './helpers/database';
|
||||
import events from './handlers/events';
|
||||
import commands from './handlers/commands';
|
||||
import locale from './handlers/locale';
|
||||
import schedules from './handlers/schedules';
|
||||
import database from "./helpers/database";
|
||||
import events from "./handlers/events";
|
||||
import commands from "./handlers/commands";
|
||||
import locale from "./handlers/locale";
|
||||
import schedules from "./handlers/schedules";
|
||||
|
||||
import config from '../config.json'; // config.json
|
||||
import config from "../config.json"; // config.json
|
||||
|
||||
(async () => {
|
||||
// Initialize discord.js client
|
||||
|
|
Loading…
Add table
Reference in a new issue