🎨 admin commands code smells fixed

This commit is contained in:
Axel Olausson Holtenäs 2022-04-10 22:19:45 +02:00
parent bcd6852310
commit 41832827eb
No known key found for this signature in database
GPG key ID: 9347A5E873995701
29 changed files with 578 additions and 589 deletions

View file

@ -1,38 +1,38 @@
// Dependencies // Dependencies
import { CommandInteraction } from "discord.js"; import { CommandInteraction } from 'discord.js';
// Modules // Modules
import give from "./modules/give"; import give from './modules/give';
import take from "./modules/take"; import take from './modules/take';
import set from "./modules/set"; import set from './modules/set';
import transfer from "./modules/transfer"; import transfer from './modules/transfer';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
// Destructure // Destructure
const { user, guild, commandName, options } = interaction; const { options } = interaction;
// Module - Give // Module - Give
if (options?.getSubcommand() === "give") { if (options?.getSubcommand() === 'give') {
// Execute Module - Give // Execute Module - Give
return await give(interaction); return give(interaction);
} }
// Module - Take // Module - Take
else if (options?.getSubcommand() === "take") { else if (options?.getSubcommand() === 'take') {
// Execute Module - Take // Execute Module - Take
return await take(interaction); return take(interaction);
} }
// Module - Set // Module - Set
else if (options?.getSubcommand() === "set") { else if (options?.getSubcommand() === 'set') {
// Execute Module - Set // Execute Module - Set
return await set(interaction); return set(interaction);
} }
// Module - Transfer // Module - Transfer
else if (options?.getSubcommand() === "transfer") { else if (options?.getSubcommand() === 'transfer') {
// Execute Module - Transfer // Execute Module - Transfer
return await transfer(interaction); return transfer(interaction);
} }
}; };

View file

@ -1,17 +1,17 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../../config.json"; import config from '../../../../../config.json';
// Handlers // Handlers
import logger from "../../../../handlers/logger"; import logger from '../../../../handlers/logger';
// Helpers // Helpers
import creditNoun from "../../../../helpers/creditNoun"; import creditNoun from '../../../../helpers/creditNoun';
// Models // Models
import fetchUser from "../../../../helpers/fetchUser"; import fetchUser from '../../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -19,19 +19,19 @@ export default async (interaction: CommandInteraction) => {
const { guild, user, options } = interaction; const { guild, user, options } = interaction;
// User option // User option
const optionUser = options?.getUser("user"); const optionUser = options?.getUser('user');
// Amount option // Amount option
const optionAmount = options?.getInteger("amount"); const optionAmount = options?.getInteger('amount');
// If amount option is null // If amount option is null
if (optionAmount === null) { if (optionAmount === null) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Give]" as string, title: ':toolbox: Admin - Credits [Give]' as string,
description: "We could not read your requested amount." as string, description: 'We could not read your requested amount.' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -39,17 +39,17 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If amount is zero or below // If amount is zero or below
if (optionAmount <= 0) { if (optionAmount <= 0) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Give]" as string, title: ':toolbox: Admin - Credits [Give]' as string,
description: "You can not give zero credits or below." as string, description: 'You can not give zero credits or below.' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -57,7 +57,7 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
if (optionUser === null) return; if (optionUser === null) return;
@ -70,10 +70,10 @@ export default async (interaction: CommandInteraction) => {
if (!toUser) { if (!toUser) {
// Embed object // Embed object
const embed = { 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, description: `We could not find ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -81,18 +81,17 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If toUser.credits does not exist // If toUser.credits does not exist
if (!toUser?.credits) { if (!toUser?.credits) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Give]" as string, title: ':toolbox: Admin - Credits [Give]' as string,
description: description: `We could not find credits for ${optionUser} in our database.`,
`We could not find credits for ${optionUser} in our database.` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -100,7 +99,7 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// Deposit amount to toUser // Deposit amount to toUser
@ -110,12 +109,10 @@ export default async (interaction: CommandInteraction) => {
await toUser?.save()?.then(async () => { await toUser?.save()?.then(async () => {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Give]" as string, title: ':toolbox: Admin - Credits [Give]' as string,
description: `We have given ${optionUser}, ${creditNoun( description: `We have given ${optionUser}, ${creditNoun(optionAmount)}.`,
optionAmount
)}.` as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -130,6 +127,6 @@ export default async (interaction: CommandInteraction) => {
); );
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}); });
}; };

View file

@ -1,17 +1,17 @@
// Dependencies // Dependencies
import { Permissions, CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../../config.json"; import config from '../../../../../config.json';
// Handlers // Handlers
import logger from "../../../../handlers/logger"; import logger from '../../../../handlers/logger';
// Helpers // Helpers
import creditNoun from "../../../../helpers/creditNoun"; import creditNoun from '../../../../helpers/creditNoun';
// Models // Models
import fetchUser from "../../../../helpers/fetchUser"; import fetchUser from '../../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -19,19 +19,19 @@ export default async (interaction: CommandInteraction) => {
const { options, user, guild } = interaction; const { options, user, guild } = interaction;
// User Option // User Option
const optionUser = options.getUser("user"); const optionUser = options.getUser('user');
// Amount Option // Amount Option
const optionAmount = options.getInteger("amount"); const optionAmount = options.getInteger('amount');
// If amount is null // If amount is null
if (optionAmount === null) { if (optionAmount === null) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Set]" as string, title: ':toolbox: Admin - Credits [Set]' as string,
description: "We could not read your requested amount." as string, description: 'We could not read your requested amount.' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -39,7 +39,7 @@ export default async (interaction: CommandInteraction) => {
}; };
// Send interaction reply // Send interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
if (optionUser === null) return; if (optionUser === null) return;
@ -52,10 +52,10 @@ export default async (interaction: CommandInteraction) => {
if (!toUser) { if (!toUser) {
// Embed object // Embed object
const embed = { 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, description: `We could not find ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -63,18 +63,17 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If toUser.credits does not exist // If toUser.credits does not exist
if (!toUser?.credits) { if (!toUser?.credits) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Set]" as string, title: ':toolbox: Admin - Credits [Set]' as string,
description: description: `We could not find credits for ${optionUser} in our database.`,
`We could not find credits for ${optionUser} in our database.` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -82,7 +81,7 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// Set toUser with amount // Set toUser with amount
@ -92,12 +91,10 @@ export default async (interaction: CommandInteraction) => {
await toUser?.save()?.then(async () => { await toUser?.save()?.then(async () => {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Set]" as string, title: ':toolbox: Admin - Credits [Set]' as string,
description: `We have set ${optionUser} to ${creditNoun( description: `We have set ${optionUser} to ${creditNoun(optionAmount)}`,
optionAmount
)}` as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -112,6 +109,6 @@ export default async (interaction: CommandInteraction) => {
); );
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}); });
}; };

View file

@ -1,17 +1,17 @@
// Dependencies // Dependencies
import { Permissions, CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../../config.json"; import config from '../../../../../config.json';
// Handlers // Handlers
import logger from "../../../../handlers/logger"; import logger from '../../../../handlers/logger';
// Helpers // Helpers
import creditNoun from "../../../../helpers/creditNoun"; import creditNoun from '../../../../helpers/creditNoun';
// Models // Models
import fetchUser from "../../../../helpers/fetchUser"; import fetchUser from '../../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -19,19 +19,19 @@ export default async (interaction: CommandInteraction) => {
const { guild, user, options } = interaction; const { guild, user, options } = interaction;
// User option // User option
const optionUser = options?.getUser("user"); const optionUser = options?.getUser('user');
// Amount option // Amount option
const optionAmount = options?.getInteger("amount"); const optionAmount = options?.getInteger('amount');
// If amount is null // If amount is null
if (optionAmount === null) { if (optionAmount === null) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Take]" as string, title: ':toolbox: Admin - Credits [Take]' as string,
description: "We could not read your requested amount." as string, description: 'We could not read your requested amount.' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -39,17 +39,17 @@ export default async (interaction: CommandInteraction) => {
}; };
// Send interaction reply // Send interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If amount is zero or below // If amount is zero or below
if (optionAmount <= 0) { if (optionAmount <= 0) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Take]" as string, title: ':toolbox: Admin - Credits [Take]' as string,
description: "You can not take zero credits or below." as string, description: 'You can not take zero credits or below.' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -57,7 +57,7 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
if (optionUser === null) return; if (optionUser === null) return;
@ -70,10 +70,10 @@ export default async (interaction: CommandInteraction) => {
if (!toUser) { if (!toUser) {
// Embed object // Embed object
const embed = { 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, description: `We could not find ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -81,18 +81,17 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If toUser.credits does not exist // If toUser.credits does not exist
if (!toUser?.credits) { if (!toUser?.credits) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Take]" as string, title: ':toolbox: Admin - Credits [Take]' as string,
description: description: `We could not find credits for ${optionUser} in our database.`,
`We could not find credits for ${optionUser} in our database.` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -100,7 +99,7 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// Withdraw amount from toUser // Withdraw amount from toUser
@ -110,12 +109,12 @@ export default async (interaction: CommandInteraction) => {
await toUser?.save()?.then(async () => { await toUser?.save()?.then(async () => {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Set]" as string, title: ':toolbox: Admin - Credits [Set]' as string,
description: `We have taken ${creditNoun( description: `We have taken ${creditNoun(
optionAmount optionAmount
)} from ${optionUser}` as string, )} from ${optionUser}`,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -130,6 +129,6 @@ export default async (interaction: CommandInteraction) => {
); );
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}); });
}; };

View file

@ -1,18 +1,18 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../../config.json"; import config from '../../../../../config.json';
// Handlers // Handlers
import logger from "../../../../handlers/logger"; import logger from '../../../../handlers/logger';
// Helpers // Helpers
import creditNoun from "../../../../helpers/creditNoun"; import creditNoun from '../../../../helpers/creditNoun';
import saveUser from "../../../../helpers/saveUser"; import saveUser from '../../../../helpers/saveUser';
// Models // Models
import fetchUser from "../../../../helpers/fetchUser"; import fetchUser from '../../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -20,18 +20,18 @@ export default async (interaction: CommandInteraction) => {
const { guild, options, user } = interaction; const { guild, options, user } = interaction;
// Get options // Get options
const optionFromUser = options?.getUser("from"); const optionFromUser = options?.getUser('from');
const optionToUser = options?.getUser("to"); const optionToUser = options?.getUser('to');
const optionAmount = options?.getInteger("amount"); const optionAmount = options?.getInteger('amount');
// If amount is null // If amount is null
if (optionAmount === null) { if (optionAmount === null) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string, title: ':toolbox: Admin - Credits [Transfer]' as string,
description: "We could not read your requested amount." as string, description: 'We could not read your requested amount.' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -39,7 +39,7 @@ export default async (interaction: CommandInteraction) => {
}; };
// Send interaction reply // Send interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
if (guild === null) return; if (guild === null) return;
@ -56,11 +56,10 @@ export default async (interaction: CommandInteraction) => {
if (!fromUser) { if (!fromUser) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string, title: ':toolbox: Admin - Credits [Transfer]' as string,
description: description: `We could not find ${optionFromUser} in our database.`,
`We could not find ${optionFromUser} in our database.` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -68,18 +67,17 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If toUser.credits does not exist // If toUser.credits does not exist
if (!fromUser?.credits) { if (!fromUser?.credits) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string, title: ':toolbox: Admin - Credits [Transfer]' as string,
description: description: `We could not find credits for ${optionFromUser} in our database.`,
`We could not find credits for ${optionFromUser} in our database.` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -87,18 +85,17 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If toUser does not exist // If toUser does not exist
if (!toUser) { if (!toUser) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string, title: ':toolbox: Admin - Credits [Transfer]' as string,
description: description: `We could not find ${optionToUser} in our database.`,
`We could not find ${optionToUser} in our database.` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -106,18 +103,17 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If toUser.credits does not exist // If toUser.credits does not exist
if (!toUser?.credits) { if (!toUser?.credits) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string, title: ':toolbox: Admin - Credits [Transfer]' as string,
description: description: `We could not find credits for ${optionToUser} in our database.`,
`We could not find credits for ${optionToUser} in our database.` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -125,7 +121,7 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// Withdraw amount from fromUser // Withdraw amount from fromUser
@ -138,10 +134,10 @@ export default async (interaction: CommandInteraction) => {
await saveUser(fromUser, toUser)?.then(async () => { await saveUser(fromUser, toUser)?.then(async () => {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string, title: ':toolbox: Admin - Credits [Transfer]' as string,
description: `You sent ${creditNoun( description: `You sent ${creditNoun(
optionAmount optionAmount
)} from ${optionFromUser} to ${optionToUser}.` as string, )} from ${optionFromUser} to ${optionToUser}.`,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
fields: [ fields: [
{ {
@ -155,7 +151,7 @@ export default async (interaction: CommandInteraction) => {
inline: true, inline: true,
}, },
], ],
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -170,6 +166,6 @@ export default async (interaction: CommandInteraction) => {
); );
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}); });
}; };

View file

@ -1,133 +1,133 @@
//Dependencies //Dependencies
import { SlashCommandBuilder } from "@discordjs/builders"; import { SlashCommandBuilder } from '@discordjs/builders';
import { CommandInteraction, ColorResolvable, Permissions } from "discord.js"; import { CommandInteraction, ColorResolvable, Permissions } from 'discord.js';
// Configurations // Configurations
import config from "../../../config.json"; import config from '../../../config.json';
// Handlers // Handlers
import logger from "../../handlers/logger"; import logger from '../../handlers/logger';
// Groups // Groups
import credits from "./credits"; import credits from './credits';
import counters from "./counters"; import counters from './counters';
// Function // Function
export default { export default {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("admin") .setName('admin')
.setDescription("Admin actions.") .setDescription('Admin actions.')
.addSubcommandGroup((group) => .addSubcommandGroup((group) =>
group group
.setName("credits") .setName('credits')
.setDescription("Manage credits.") .setDescription('Manage credits.')
.addSubcommand((command) => .addSubcommand((command) =>
command command
.setName("give") .setName('give')
.setDescription("Give credits to a user") .setDescription('Give credits to a user')
.addUserOption((option) => .addUserOption((option) =>
option option
.setName("user") .setName('user')
.setDescription("The user you want to pay.") .setDescription('The user you want to pay.')
.setRequired(true) .setRequired(true)
) )
.addIntegerOption((option) => .addIntegerOption((option) =>
option option
.setName("amount") .setName('amount')
.setDescription("The amount you will pay.") .setDescription('The amount you will pay.')
.setRequired(true) .setRequired(true)
) )
) )
.addSubcommand((command) => .addSubcommand((command) =>
command command
.setName("set") .setName('set')
.setDescription("Set credits to a user") .setDescription('Set credits to a user')
.addUserOption((option) => .addUserOption((option) =>
option option
.setName("user") .setName('user')
.setDescription("The user you want to set credits on.") .setDescription('The user you want to set credits on.')
.setRequired(true) .setRequired(true)
) )
.addIntegerOption((option) => .addIntegerOption((option) =>
option option
.setName("amount") .setName('amount')
.setDescription("The amount you will set.") .setDescription('The amount you will set.')
.setRequired(true) .setRequired(true)
) )
) )
.addSubcommand((command) => .addSubcommand((command) =>
command command
.setName("take") .setName('take')
.setDescription("Take credits from a user") .setDescription('Take credits from a user')
.addUserOption((option) => .addUserOption((option) =>
option option
.setName("user") .setName('user')
.setDescription("The user you want to take credits from.") .setDescription('The user you want to take credits from.')
.setRequired(true) .setRequired(true)
) )
.addIntegerOption((option) => .addIntegerOption((option) =>
option option
.setName("amount") .setName('amount')
.setDescription("The amount you will take.") .setDescription('The amount you will take.')
.setRequired(true) .setRequired(true)
) )
) )
.addSubcommand((command) => .addSubcommand((command) =>
command command
.setName("transfer") .setName('transfer')
.setDescription("Transfer credits from a user to another user.") .setDescription('Transfer credits from a user to another user.')
.addUserOption((option) => .addUserOption((option) =>
option option
.setName("from") .setName('from')
.setDescription("The user you want to take credits from.") .setDescription('The user you want to take credits from.')
.setRequired(true) .setRequired(true)
) )
.addUserOption((option) => .addUserOption((option) =>
option option
.setName("to") .setName('to')
.setDescription("The user you want to give credits to.") .setDescription('The user you want to give credits to.')
.setRequired(true) .setRequired(true)
) )
.addIntegerOption((option) => .addIntegerOption((option) =>
option option
.setName("amount") .setName('amount')
.setDescription("The amount you will transfer.") .setDescription('The amount you will transfer.')
.setRequired(true) .setRequired(true)
) )
) )
) )
.addSubcommandGroup((group) => .addSubcommandGroup((group) =>
group group
.setName("counters") .setName('counters')
.setDescription("Manage counters.") .setDescription('Manage counters.')
.addSubcommand((command) => .addSubcommand((command) =>
command command
.setName("add") .setName('add')
.setDescription("Add a counter") .setDescription('Add a counter')
.addChannelOption((option) => .addChannelOption((option) =>
option option
.setName("channel") .setName('channel')
.setDescription("The counter channel.") .setDescription('The counter channel.')
.setRequired(true) .setRequired(true)
) )
.addStringOption((option) => .addStringOption((option) =>
option option
.setName("word") .setName('word')
.setDescription("The counter word.") .setDescription('The counter word.')
.setRequired(true) .setRequired(true)
) )
.addNumberOption((option) => .addNumberOption((option) =>
option.setName("start").setDescription("Start at number X.") option.setName('start').setDescription('Start at number X.')
) )
) )
.addSubcommand((command) => .addSubcommand((command) =>
command command
.setName("remove") .setName('remove')
.setDescription("Remove a counter") .setDescription('Remove a counter')
.addChannelOption((option) => .addChannelOption((option) =>
option option
.setName("channel") .setName('channel')
.setDescription("The counter channel.") .setDescription('The counter channel.')
.setRequired(true) .setRequired(true)
) )
) )
@ -141,10 +141,10 @@ export default {
if (!memberPermissions?.has(Permissions?.FLAGS?.MANAGE_GUILD)) { if (!memberPermissions?.has(Permissions?.FLAGS?.MANAGE_GUILD)) {
// Embed object // Embed object
const embed = { const embed = {
title: ":toolbox: Admin" as string, title: ':toolbox: Admin' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
description: "You do not have permission to manage this!" as string, description: 'You do not have permission to manage this!' as string,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -156,15 +156,15 @@ export default {
} }
// Group - Credits // Group - Credits
if (options?.getSubcommandGroup() === "credits") { if (options?.getSubcommandGroup() === 'credits') {
// Execute Group - Credits // Execute Group - Credits
return await credits(interaction); return credits(interaction);
} }
// Group - Counters // Group - Counters
else if (options?.getSubcommandGroup() === "counters") { else if (options?.getSubcommandGroup() === 'counters') {
// Execute Group - Counters // Execute Group - Counters
return await counters(interaction); return counters(interaction);
} }
// Send debug message // Send debug message

View file

@ -1,26 +1,26 @@
// Dependencies // Dependencies
import { CommandInteraction } from "discord.js"; import { CommandInteraction } from 'discord.js';
import { SlashCommandBuilder } from "@discordjs/builders"; import { SlashCommandBuilder } from '@discordjs/builders';
// Modules // Modules
import view from "./modules/view"; import view from './modules/view';
// Handlers // Handlers
import logger from "../../handlers/logger"; import logger from '../../handlers/logger';
// Function // Function
export default { export default {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("counters") .setName('counters')
.setDescription("Manage counters.") .setDescription('Manage counters.')
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand subcommand
.setName("view") .setName('view')
.setDescription("View a counter.") .setDescription('View a counter.')
.addChannelOption((option) => .addChannelOption((option) =>
option option
.setName("channel") .setName('channel')
.setDescription("The counter channel you want to view") .setDescription('The counter channel you want to view')
.setRequired(true) .setRequired(true)
) )
), ),
@ -28,9 +28,9 @@ export default {
const { options, guild, user, commandName } = interaction; const { options, guild, user, commandName } = interaction;
// Module - View // Module - View
if (options?.getSubcommand() === "view") { if (options?.getSubcommand() === 'view') {
// Execute Module - View // Execute Module - View
return await view(interaction); return view(interaction);
} }
// Send debug message // Send debug message

View file

@ -1,11 +1,11 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../config.json"; import config from '../../../../config.json';
// Models // Models
import counterSchema from "../../../helpers/database/models/counterSchema"; import counterSchema from '../../../helpers/database/models/counterSchema';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -13,7 +13,7 @@ export default async (interaction: CommandInteraction) => {
const { options, guild } = interaction; const { options, guild } = interaction;
// Get options // Get options
const optionChannel = options?.getChannel("channel"); const optionChannel = options?.getChannel('channel');
const counter = await counterSchema?.findOne({ const counter = await counterSchema?.findOne({
guildId: guild?.id, guildId: guild?.id,
@ -23,9 +23,9 @@ export default async (interaction: CommandInteraction) => {
if (!counter) { if (!counter) {
// Create embed object // Create embed object
const embed = { const embed = {
title: ":1234: Counters [View]" as string, title: ':1234: Counters [View]' as string,
description: `${optionChannel} is not a counting channel.` as string, description: `${optionChannel} is not a counting channel.` as string,
timestamp: new Date() as Date, timestamp: new Date(),
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
@ -34,15 +34,15 @@ export default async (interaction: CommandInteraction) => {
}; };
// Send interaction reply // Send interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// Embed object // Embed object
const embed = { const embed = {
title: ":1234: Counters [View]" as string, title: ':1234: Counters [View]' as string,
color: config.colors.success as ColorResolvable, color: config.colors.success as ColorResolvable,
description: `${optionChannel} is currently at number ${counter?.counter}.`, description: `${optionChannel} is currently at number ${counter?.counter}.`,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -50,5 +50,5 @@ export default async (interaction: CommandInteraction) => {
}; };
// Send interaction reply // Send interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}; };

View file

@ -1,83 +1,83 @@
// Dependencies // Dependencies
import { SlashCommandBuilder } from "@discordjs/builders"; import { SlashCommandBuilder } from '@discordjs/builders';
import { CommandInteraction } from "discord.js"; import { CommandInteraction } from 'discord.js';
// Handlers // Handlers
import logger from "../../handlers/logger"; import logger from '../../handlers/logger';
// Modules // Modules
import balance from "./modules/balance"; import balance from './modules/balance';
import gift from "./modules/gift"; import gift from './modules/gift';
import top from "./modules/top"; import top from './modules/top';
import work from "./modules/work"; import work from './modules/work';
// Function // Function
export default { export default {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("credits") .setName('credits')
.setDescription("Manage your credits.") .setDescription('Manage your credits.')
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand subcommand
.setName("balance") .setName('balance')
.setDescription("Check a user's balance.") .setDescription("Check a user's balance.")
.addUserOption((option) => .addUserOption((option) =>
option option
.setName("user") .setName('user')
.setDescription("The user whose balance you want to check.") .setDescription('The user whose balance you want to check.')
.setRequired(false) .setRequired(false)
) )
) )
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand subcommand
.setName("gift") .setName('gift')
.setDescription("Gift someone credits from your credits.") .setDescription('Gift someone credits from your credits.')
.addUserOption((option) => .addUserOption((option) =>
option option
.setName("user") .setName('user')
.setDescription("The user you want to pay.") .setDescription('The user you want to pay.')
.setRequired(true) .setRequired(true)
) )
.addIntegerOption((option) => .addIntegerOption((option) =>
option option
.setName("amount") .setName('amount')
.setDescription("The amount you will pay.") .setDescription('The amount you will pay.')
.setRequired(true) .setRequired(true)
) )
.addStringOption((option) => .addStringOption((option) =>
option.setName("reason").setDescription("Your reason.") option.setName('reason').setDescription('Your reason.')
) )
) )
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand.setName("top").setDescription("Check the top balance.") subcommand.setName('top').setDescription('Check the top balance.')
) )
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand.setName("work").setDescription("Work for credits.") subcommand.setName('work').setDescription('Work for credits.')
), ),
async execute(interaction: CommandInteraction) { async execute(interaction: CommandInteraction) {
const { options, user, guild, commandName } = interaction; const { options, user, guild, commandName } = interaction;
// Module - Balance // Module - Balance
if (options?.getSubcommand() === "balance") { if (options?.getSubcommand() === 'balance') {
// Execute Module - Balance // Execute Module - Balance
return await balance(interaction); return balance(interaction);
} }
// Module - Gift // Module - Gift
else if (options?.getSubcommand() === "gift") { else if (options?.getSubcommand() === 'gift') {
// Execute Module - Gift // Execute Module - Gift
return await gift(interaction); return gift(interaction);
} }
// Module - Top // Module - Top
else if (options?.getSubcommand() === "top") { else if (options?.getSubcommand() === 'top') {
// Execute Module - Top // Execute Module - Top
return await top(interaction); return top(interaction);
} }
// Module - Work // Module - Work
else if (options?.getSubcommand() === "work") { else if (options?.getSubcommand() === 'work') {
// Execute Module - Work // Execute Module - Work
return await work(interaction); return work(interaction);
} }
// Send debug message // Send debug message

View file

@ -1,14 +1,14 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../config.json"; import config from '../../../../config.json';
// Helpers // Helpers
import creditNoun from "../../../helpers/creditNoun"; import creditNoun from '../../../helpers/creditNoun';
// Models // Models
import fetchUser from "../../../helpers/fetchUser"; import fetchUser from '../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -16,7 +16,7 @@ export default async (interaction: CommandInteraction) => {
const { options, user, guild } = interaction; const { options, user, guild } = interaction;
// User option // User option
const optionUser = options?.getUser("user"); const optionUser = options?.getUser('user');
if (guild === null) return; if (guild === null) return;
@ -27,12 +27,12 @@ export default async (interaction: CommandInteraction) => {
if (userDB === null) { if (userDB === null) {
// Embed object // Embed object
const embed = { const embed = {
title: ":dollar: Credits [Balance]" as string, title: ':dollar: Credits [Balance]' as string,
description: `We can not find ${ description: `We can not find ${
optionUser || "you" optionUser || 'you'
} in our database.` as string, } in our database.` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -47,12 +47,12 @@ export default async (interaction: CommandInteraction) => {
if (userDB.credits === null) { if (userDB.credits === null) {
// Embed object // Embed object
const embed = { const embed = {
title: ":dollar: Credits [Balance]" as string, title: ':dollar: Credits [Balance]' as string,
description: `We can not find credits for ${ description: `We can not find credits for ${
optionUser || "you" optionUser || 'you'
} in our database.` as string, } in our database.` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -64,12 +64,12 @@ export default async (interaction: CommandInteraction) => {
} else { } else {
// Embed object // Embed object
const embed = { const embed = {
title: ":dollar: Credits [Balance]" as string, title: ':dollar: Credits [Balance]' as string,
description: `${ description: `${
optionUser ? `${optionUser} has` : "You have" optionUser ? `${optionUser} has` : 'You have'
} ${creditNoun(userDB.credits)}.` as string, } ${creditNoun(userDB.credits)}.` as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,

View file

@ -1,18 +1,18 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../config.json"; import config from '../../../../config.json';
// Handlers // Handlers
import logger from "../../../handlers/logger"; import logger from '../../../handlers/logger';
// Helpers // Helpers
import saveUser from "../../../helpers/saveUser"; import saveUser from '../../../helpers/saveUser';
import creditNoun from "../../../helpers/creditNoun"; import creditNoun from '../../../helpers/creditNoun';
// Models // Models
import fetchUser from "../../../helpers/fetchUser"; import fetchUser from '../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -20,13 +20,13 @@ export default async (interaction: CommandInteraction) => {
const { options, user, guild, client } = interaction; const { options, user, guild, client } = interaction;
// User option // User option
const optionUser = options?.getUser("user"); const optionUser = options?.getUser('user');
// Amount option // Amount option
const optionAmount = options?.getInteger("amount"); const optionAmount = options?.getInteger('amount');
// Reason option // Reason option
const optionReason = options?.getString("reason"); const optionReason = options?.getString('reason');
if (guild === null) return; if (guild === null) return;
if (optionUser === null) return; if (optionUser === null) return;
@ -44,10 +44,10 @@ export default async (interaction: CommandInteraction) => {
if (optionUser?.id === user?.id) { if (optionUser?.id === user?.id) {
// Create embed object // Create embed object
const embed = { const embed = {
title: ":dollar: Credits [Gift]" as string, title: ':dollar: Credits [Gift]' as string,
description: "You can't pay yourself." as string, description: "You can't pay yourself." as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -55,17 +55,17 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If amount is null // If amount is null
if (optionAmount === null) { if (optionAmount === null) {
// Embed object // Embed object
const embed = { const embed = {
title: ":dollar: Credits [Gift]" as string, title: ':dollar: Credits [Gift]' as string,
description: "We could not read your requested amount." as string, description: 'We could not read your requested amount.' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -73,17 +73,17 @@ export default async (interaction: CommandInteraction) => {
}; };
// Send interaction reply // Send interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If amount is zero or below // If amount is zero or below
if (optionAmount <= 0) { if (optionAmount <= 0) {
// Embed object // Embed object
const embed = { const embed = {
title: ":dollar: Credits [Gift]" as string, title: ':dollar: Credits [Gift]' as string,
description: "You can't pay zero or below." as string, description: "You can't pay zero or below." as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -91,18 +91,18 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If user has below gifting amount // If user has below gifting amount
if (fromUserDB?.credits < optionAmount) { if (fromUserDB?.credits < optionAmount) {
// Embed object // Embed object
const embed = { const embed = {
title: ":dollar: Credits [Gift]" as string, title: ':dollar: Credits [Gift]' as string,
description: description:
`You have insufficient credits. Your credits is ${fromUserDB?.credits}` as string, `You have insufficient credits. Your credits is ${fromUserDB?.credits}` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -110,18 +110,18 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If toUserDB has no credits // If toUserDB has no credits
if (!toUserDB) { if (!toUserDB) {
// Embed object // Embed object
const embed = { const embed = {
title: ":dollar: Credits [Gift]" as string, title: ':dollar: Credits [Gift]' as string,
description: description:
`That user has no credits, I can not gift credits to ${optionUser}` as string, `That user has no credits, I can not gift credits to ${optionUser}` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -129,7 +129,7 @@ export default async (interaction: CommandInteraction) => {
}; };
// Send interaction reply // Send interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// Withdraw amount from fromUserDB // Withdraw amount from fromUserDB
@ -142,12 +142,12 @@ export default async (interaction: CommandInteraction) => {
await saveUser(fromUserDB, toUserDB)?.then(async () => { await saveUser(fromUserDB, toUserDB)?.then(async () => {
// Interaction embed object // Interaction embed object
const interactionEmbed = { const interactionEmbed = {
title: ":dollar: Credits [Gift]", title: ':dollar: Credits [Gift]',
description: `You sent ${creditNoun(optionAmount)} to ${optionUser}${ description: `You sent ${creditNoun(optionAmount)} to ${optionUser}${
optionReason ? ` with reason: ${optionReason}` : "" optionReason ? ` with reason: ${optionReason}` : ''
}. Your new credits is ${creditNoun(fromUserDB?.credits)}.`, }. Your new credits is ${creditNoun(fromUserDB?.credits)}.`,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -156,12 +156,12 @@ export default async (interaction: CommandInteraction) => {
// DM embed object // DM embed object
const dmEmbed = { const dmEmbed = {
title: ":dollar: Credits [Gift]" as string, title: ':dollar: Credits [Gift]' as string,
description: `You received ${creditNoun(optionAmount)} from ${user}${ description: `You received ${creditNoun(optionAmount)} from ${user}${
optionReason ? ` with reason: ${optionReason}` : "" optionReason ? ` with reason: ${optionReason}` : ''
}. Your new credits is ${creditNoun(toUserDB?.credits)}.` as string, }. Your new credits is ${creditNoun(toUserDB?.credits)}.` as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -180,7 +180,7 @@ export default async (interaction: CommandInteraction) => {
); );
// Send interaction reply // Send interaction reply
return await interaction.editReply({ return interaction.editReply({
embeds: [interactionEmbed], embeds: [interactionEmbed],
}); });
}); });

View file

@ -1,14 +1,14 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../config.json"; import config from '../../../../config.json';
// Models // Models
import userSchema from "../../../helpers/database/models/userSchema"; import userSchema from '../../../helpers/database/models/userSchema';
// helpers // helpers
import creditNoun from "../../../helpers/creditNoun"; import creditNoun from '../../../helpers/creditNoun';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -30,12 +30,12 @@ export default async (interaction: CommandInteraction) => {
// Create embed object // Create embed object
const embed = { const embed = {
title: ":dollar: Credits [Top]" as string, title: ':dollar: Credits [Top]' as string,
description: `Below are the top ten.\n${topTen description: `Below are the top ten.\n${topTen
?.map((x, index) => entry(x, index)) ?.map((x, index) => entry(x, index))
?.join("\n")}` as string, ?.join('\n')}` as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -43,5 +43,5 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}; };

View file

@ -1,20 +1,20 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
import Chance from "chance"; import Chance from 'chance';
// Configurations // Configurations
import config from "../../../../config.json"; import config from '../../../../config.json';
// Handlers // Handlers
import logger from "../../../handlers/logger"; import logger from '../../../handlers/logger';
// Models // Models
import timeouts from "../../../helpers/database/models/timeoutSchema"; import timeouts from '../../../helpers/database/models/timeoutSchema';
// Helpers // Helpers
import creditNoun from "../../../helpers/creditNoun"; import creditNoun from '../../../helpers/creditNoun';
import fetchUser from "../../../helpers/fetchUser"; import fetchUser from '../../../helpers/fetchUser';
import fetchGuild from "../../../helpers/fetchGuild"; import fetchGuild from '../../../helpers/fetchGuild';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -28,7 +28,7 @@ export default async (interaction: CommandInteraction) => {
const isTimeout = await timeouts?.findOne({ const isTimeout = await timeouts?.findOne({
guildId: guild?.id, guildId: guild?.id,
userId: user?.id, userId: user?.id,
timeoutId: "2022-03-15-19-16", timeoutId: '2022-03-15-19-16',
}); });
if (guild === null) return; if (guild === null) return;
@ -54,10 +54,10 @@ export default async (interaction: CommandInteraction) => {
// Create embed object // Create embed object
const embed = { const embed = {
title: ":dollar: Credits [Work]" as string, title: ':dollar: Credits [Work]' as string,
description: `You have earned ${creditNoun(creditsEarned)}` as string, description: `You have earned ${creditNoun(creditsEarned)}` as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -65,14 +65,14 @@ export default async (interaction: CommandInteraction) => {
}; };
// Send interaction reply // Send interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}); });
// Create a timeout for the user // Create a timeout for the user
await timeouts?.create({ await timeouts?.create({
guildId: guild?.id, guildId: guild?.id,
userId: user?.id, userId: user?.id,
timeoutId: "2022-03-15-19-16", timeoutId: '2022-03-15-19-16',
}); });
setTimeout(async () => { setTimeout(async () => {
@ -87,17 +87,17 @@ export default async (interaction: CommandInteraction) => {
await timeouts?.deleteOne({ await timeouts?.deleteOne({
guildId: guild?.id, guildId: guild?.id,
userId: user?.id, userId: user?.id,
timeoutId: "2022-03-15-19-16", timeoutId: '2022-03-15-19-16',
}); });
}, guildDB?.credits?.workTimeout); }, guildDB?.credits?.workTimeout);
} else { } else {
// Create embed object // Create embed object
const embed = { const embed = {
title: ":dollar: Credits [Work]" as string, title: ':dollar: Credits [Work]' as string,
description: `You have worked within the last ${ description: `You have worked within the last ${
guildDB?.credits?.workTimeout / 1000 guildDB?.credits?.workTimeout / 1000
} seconds, you can not work now!` as string, } seconds, you can not work now!` as string,
timestamp: new Date() as Date, timestamp: new Date(),
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
@ -111,6 +111,6 @@ export default async (interaction: CommandInteraction) => {
); );
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
}; };

View file

@ -1,26 +1,26 @@
// Dependencies // Dependencies
import { SlashCommandBuilder } from "@discordjs/builders"; import { SlashCommandBuilder } from '@discordjs/builders';
import { CommandInteraction } from "discord.js"; import { CommandInteraction } from 'discord.js';
// Modules // Modules
import view from "./modules/view"; import view from './modules/view';
// Handlers // Handlers
import logger from "../../handlers/logger"; import logger from '../../handlers/logger';
// Function // Function
export default { export default {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("profile") .setName('profile')
.setDescription("Check a profile.") .setDescription('Check a profile.')
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand subcommand
.setName("view") .setName('view')
.setDescription("View a profile.") .setDescription('View a profile.')
.addUserOption((option) => .addUserOption((option) =>
option option
.setName("target") .setName('target')
.setDescription("The profile you wish to view") .setDescription('The profile you wish to view')
) )
), ),
async execute(interaction: CommandInteraction) { async execute(interaction: CommandInteraction) {
@ -28,9 +28,9 @@ export default {
const { options, guild, user, commandName } = interaction; const { options, guild, user, commandName } = interaction;
// Module - View // Module - View
if (options?.getSubcommand() === "view") { if (options?.getSubcommand() === 'view') {
// Execute Module - View // Execute Module - View
return await view(interaction); return view(interaction);
} }
// Send debug message // Send debug message

View file

@ -1,11 +1,11 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../config.json"; import config from '../../../../config.json';
// Models // Models
import fetchUser from "../../../helpers/fetchUser"; import fetchUser from '../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -13,7 +13,7 @@ export default async (interaction: CommandInteraction) => {
const { client, options, user, guild } = interaction; const { client, options, user, guild } = interaction;
// Target information // Target information
const target = options?.getUser("target"); const target = options?.getUser('target');
// Discord User Information // Discord User Information
const discordUser = await client?.users?.fetch( const discordUser = await client?.users?.fetch(
@ -35,31 +35,31 @@ export default async (interaction: CommandInteraction) => {
fields: [ fields: [
{ {
name: `:dollar: Credits` as string, name: `:dollar: Credits` as string,
value: `${userObj?.credits || "Not found"}` as string, value: `${userObj?.credits || 'Not found'}` as string,
inline: true, inline: true,
}, },
{ {
name: `:squeeze_bottle: Level` as string, name: `:squeeze_bottle: Level` as string,
value: `${userObj?.level || "Not found"}` as string, value: `${userObj?.level || 'Not found'}` as string,
inline: true, inline: true,
}, },
{ {
name: `:squeeze_bottle: Points` as string, name: `:squeeze_bottle: Points` as string,
value: `${userObj?.points || "Not found"}` as string, value: `${userObj?.points || 'Not found'}` as string,
inline: true, inline: true,
}, },
{ {
name: `:loudspeaker: Reputation` as string, name: `:loudspeaker: Reputation` as string,
value: `${userObj?.reputation || "Not found"}` as string, value: `${userObj?.reputation || 'Not found'}` as string,
inline: true, inline: true,
}, },
{ {
name: `:rainbow_flag: Language` as string, name: `:rainbow_flag: Language` as string,
value: `${userObj?.language || "Not found"}` as string, value: `${userObj?.language || 'Not found'}` as string,
inline: true, inline: true,
}, },
], ],
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -67,5 +67,5 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}; };

View file

@ -1,15 +1,15 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../config.json"; import config from '../../../../config.json';
// Handlers // Handlers
import logger from "../../../handlers/logger"; import logger from '../../../handlers/logger';
// Models // Models
import timeoutSchema from "../../../helpers/database/models/timeoutSchema"; import timeoutSchema from '../../../helpers/database/models/timeoutSchema';
import fetchUser from "../../../helpers/fetchUser"; import fetchUser from '../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -17,10 +17,10 @@ export default async (interaction: CommandInteraction) => {
const { options, user, guild } = interaction; const { options, user, guild } = interaction;
// Target option // Target option
const optionTarget = options?.getUser("target"); const optionTarget = options?.getUser('target');
// Type information // Type information
const optionType = options?.getString("type"); const optionType = options?.getString('type');
if (guild === null) return; if (guild === null) return;
@ -33,7 +33,7 @@ export default async (interaction: CommandInteraction) => {
const isTimeout = await timeoutSchema?.findOne({ const isTimeout = await timeoutSchema?.findOne({
guildId: guild?.id, guildId: guild?.id,
userId: user?.id, userId: user?.id,
timeoutId: "2022-04-10-16-42", timeoutId: '2022-04-10-16-42',
}); });
// If user is not on timeout // If user is not on timeout
@ -42,9 +42,9 @@ export default async (interaction: CommandInteraction) => {
if (optionTarget?.id === user?.id) { if (optionTarget?.id === user?.id) {
// Embed object // Embed object
const embed = { const embed = {
title: ":loudspeaker: Reputation [Give]" as string, title: ':loudspeaker: Reputation [Give]' as string,
description: "You can not repute yourself." as string, description: 'You can not repute yourself.' as string,
timestamp: new Date() as Date, timestamp: new Date(),
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
@ -53,16 +53,16 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// If type is positive // If type is positive
if (optionType === "positive") { if (optionType === 'positive') {
userObj.reputation += 1; userObj.reputation += 1;
} }
// If type is negative // If type is negative
else if (optionType === "negative") { else if (optionType === 'negative') {
userObj.reputation -= 1; userObj.reputation -= 1;
} }
@ -70,10 +70,10 @@ export default async (interaction: CommandInteraction) => {
await userObj?.save()?.then(async () => { await userObj?.save()?.then(async () => {
// Embed object // Embed object
const embed = { const embed = {
title: ":loudspeaker: Reputation [Give]" as string, title: ':loudspeaker: Reputation [Give]' as string,
description: description:
`You have given ${optionTarget} a ${optionType} reputation!` as string, `You have given ${optionTarget} a ${optionType} reputation!` as string,
timestamp: new Date() as Date, timestamp: new Date(),
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
@ -90,10 +90,10 @@ export default async (interaction: CommandInteraction) => {
await timeoutSchema?.create({ await timeoutSchema?.create({
guildId: guild?.id, guildId: guild?.id,
userId: user?.id, userId: user?.id,
timeoutId: "2022-04-10-16-42", timeoutId: '2022-04-10-16-42',
}); });
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}); });
setTimeout(async () => { setTimeout(async () => {
@ -108,17 +108,17 @@ export default async (interaction: CommandInteraction) => {
await timeoutSchema?.deleteOne({ await timeoutSchema?.deleteOne({
guildId: guild?.id, guildId: guild?.id,
userId: user?.id, userId: user?.id,
timeoutId: "2022-04-10-16-42", timeoutId: '2022-04-10-16-42',
}); });
}, config?.reputation?.timeout); }, config?.reputation?.timeout);
} else { } else {
// Create embed object // Create embed object
const embed = { const embed = {
title: ":loudspeaker: Reputation [Give]" as string, title: ':loudspeaker: Reputation [Give]' as string,
description: `You have given reputation within the last ${ description: `You have given reputation within the last ${
config?.reputation?.timeout / 1000 config?.reputation?.timeout / 1000
} seconds, you can not repute now!` as string, } seconds, you can not repute now!` as string,
timestamp: new Date() as Date, timestamp: new Date(),
color: config.colors.error as ColorResolvable, color: config.colors.error as ColorResolvable,
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
@ -134,6 +134,6 @@ export default async (interaction: CommandInteraction) => {
); );
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
}; };

View file

@ -1,14 +1,14 @@
// Dependencies // Dependencies
import { ColorResolvable, CommandInteraction } from "discord.js"; import { ColorResolvable, CommandInteraction } from 'discord.js';
// Configurations // Configurations
import config from "../../../../../config.json"; import config from '../../../../../config.json';
//Handlers //Handlers
import logger from "../../../../handlers/logger"; import logger from '../../../../handlers/logger';
// Models // Models
import guildSchema from "../../../../helpers/database/models/guildSchema"; import guildSchema from '../../../../helpers/database/models/guildSchema';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -16,12 +16,12 @@ export default async (interaction: CommandInteraction) => {
const { guild, user, options } = interaction; const { guild, user, options } = interaction;
// Get options // Get options
const status = options?.getBoolean("status"); const status = options?.getBoolean('status');
const rate = options?.getNumber("rate"); const rate = options?.getNumber('rate');
const timeout = options?.getNumber("timeout"); const timeout = options?.getNumber('timeout');
const minimumLength = options?.getNumber("minimum-length"); const minimumLength = options?.getNumber('minimum-length');
const workRate = options?.getNumber("work-rate"); const workRate = options?.getNumber('work-rate');
const workTimeout = options?.getNumber("work-timeout"); const workTimeout = options?.getNumber('work-timeout');
// Get guild object // Get guild object
const guildDB = await guildSchema?.findOne({ const guildDB = await guildSchema?.findOne({
@ -44,42 +44,42 @@ export default async (interaction: CommandInteraction) => {
await guildDB?.save()?.then(async () => { await guildDB?.save()?.then(async () => {
// Embed object // Embed object
const embed = { const embed = {
title: ":tools: Settings - Guild [Credits]" as string, title: ':tools: Settings - Guild [Credits]' as string,
description: "Following settings is set!" as string, description: 'Following settings is set!' as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
fields: [ fields: [
{ {
name: "🤖 Status" as string, name: '🤖 Status' as string,
value: `${guildDB?.credits?.status}` as string, value: `${guildDB?.credits?.status}` as string,
inline: true, inline: true,
}, },
{ {
name: "📈 Rate" as string, name: '📈 Rate' as string,
value: `${guildDB?.credits?.rate}` as string, value: `${guildDB?.credits?.rate}` as string,
inline: true, inline: true,
}, },
{ {
name: "📈 Work Rate" as string, name: '📈 Work Rate' as string,
value: `${guildDB?.credits?.workRate}` as string, value: `${guildDB?.credits?.workRate}` as string,
inline: true, inline: true,
}, },
{ {
name: "🔨 Minimum Length" as string, name: '🔨 Minimum Length' as string,
value: `${guildDB?.credits?.minimumLength}` as string, value: `${guildDB?.credits?.minimumLength}` as string,
inline: true, inline: true,
}, },
{ {
name: "⏰ Timeout" as string, name: '⏰ Timeout' as string,
value: `${guildDB?.credits?.timeout}` as string, value: `${guildDB?.credits?.timeout}` as string,
inline: true, inline: true,
}, },
{ {
name: "⏰ Work Timeout" as string, name: '⏰ Work Timeout' as string,
value: `${guildDB?.credits?.workTimeout}` as string, value: `${guildDB?.credits?.workTimeout}` as string,
inline: true, inline: true,
}, },
], ],
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -92,6 +92,6 @@ export default async (interaction: CommandInteraction) => {
); );
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}); });
}; };

View file

@ -1,14 +1,14 @@
// Dependencies // Dependencies
import { ColorResolvable, CommandInteraction } from "discord.js"; import { ColorResolvable, CommandInteraction } from 'discord.js';
// Configurations // Configurations
import config from "../../../../../config.json"; import config from '../../../../../config.json';
// Handlers // Handlers
import logger from "../../../../handlers/logger"; import logger from '../../../../handlers/logger';
// Models // Models
import guildSchema from "../../../../helpers/database/models/guildSchema"; import guildSchema from '../../../../helpers/database/models/guildSchema';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -16,10 +16,10 @@ export default async (interaction: CommandInteraction) => {
const { options, guild, user } = interaction; const { options, guild, user } = interaction;
// Get options // Get options
const status = options?.getBoolean("status"); const status = options?.getBoolean('status');
const rate = options?.getNumber("rate"); const rate = options?.getNumber('rate');
const timeout = options?.getNumber("timeout"); const timeout = options?.getNumber('timeout');
const minimumLength = options?.getNumber("minimum-length"); const minimumLength = options?.getNumber('minimum-length');
// Get guild object // Get guild object
const guildDB = await guildSchema?.findOne({ const guildDB = await guildSchema?.findOne({
@ -38,32 +38,32 @@ export default async (interaction: CommandInteraction) => {
await guildDB?.save()?.then(async () => { await guildDB?.save()?.then(async () => {
// Create embed object // Create embed object
const embed = { const embed = {
title: ":hammer: Settings - Guild [Points]" as string, title: ':hammer: Settings - Guild [Points]' as string,
description: "Following settings is set!" as string, description: 'Following settings is set!' as string,
color: config.colors.success as ColorResolvable, color: config.colors.success as ColorResolvable,
fields: [ fields: [
{ {
name: "🤖 Status" as string, name: '🤖 Status' as string,
value: `${guildDB?.points?.status}` as string, value: `${guildDB?.points?.status}` as string,
inline: true, inline: true,
}, },
{ {
name: "📈 Rate" as string, name: '📈 Rate' as string,
value: `${guildDB?.points?.rate}` as string, value: `${guildDB?.points?.rate}` as string,
inline: true, inline: true,
}, },
{ {
name: "🔨 Minimum Length" as string, name: '🔨 Minimum Length' as string,
value: `${guildDB?.points?.minimumLength}` as string, value: `${guildDB?.points?.minimumLength}` as string,
inline: true, inline: true,
}, },
{ {
name: "⏰ Timeout" as string, name: '⏰ Timeout' as string,
value: `${guildDB?.points?.timeout}` as string, value: `${guildDB?.points?.timeout}` as string,
inline: true, inline: true,
}, },
], ],
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -76,6 +76,6 @@ export default async (interaction: CommandInteraction) => {
); );
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}); });
}; };

View file

@ -1,14 +1,14 @@
// Dependencies // Dependencies
import { ColorResolvable, CommandInteraction } from "discord.js"; import { ColorResolvable, CommandInteraction } from 'discord.js';
// Configurations // Configurations
import config from "../../../../../config.json"; import config from '../../../../../config.json';
// Handlers // Handlers
import logger from "../../../../handlers/logger"; import logger from '../../../../handlers/logger';
// Models // Models
import apiSchema from "../../../../helpers/database/models/apiSchema"; import apiSchema from '../../../../helpers/database/models/apiSchema';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -16,8 +16,8 @@ export default async (interaction: CommandInteraction) => {
const { options, guild, user } = interaction; const { options, guild, user } = interaction;
// Get options // Get options
const url = options?.getString("url"); const url = options?.getString('url');
const token = options?.getString("token"); const token = options?.getString('token');
// Update API credentials // Update API credentials
await apiSchema await apiSchema
@ -29,10 +29,10 @@ export default async (interaction: CommandInteraction) => {
.then(async () => { .then(async () => {
// Embed object // Embed object
const embed = { const embed = {
title: ":hammer: Settings - Guild [Pterodactyl]" as string, title: ':hammer: Settings - Guild [Pterodactyl]' as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
description: "Pterodactyl settings is saved!" as string, description: 'Pterodactyl settings is saved!' as string,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -45,6 +45,6 @@ export default async (interaction: CommandInteraction) => {
); );
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}); });
}; };

View file

@ -1,16 +1,16 @@
// Dependencies // Dependencies
import { Permissions, ColorResolvable, CommandInteraction } from "discord.js"; import { Permissions, ColorResolvable, CommandInteraction } from 'discord.js';
// Configurations // Configurations
import config from "../../../../config.json"; import config from '../../../../config.json';
// Handlers // Handlers
import logger from "../../../handlers/logger"; import logger from '../../../handlers/logger';
// Modules // Modules
import pterodactyl from "./addons/pterodactyl"; import pterodactyl from './addons/pterodactyl';
import credits from "./addons/credits"; import credits from './addons/credits';
import points from "./addons/points"; import points from './addons/points';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -21,10 +21,10 @@ export default async (interaction: CommandInteraction) => {
if (!memberPermissions?.has(Permissions?.FLAGS?.MANAGE_GUILD)) { if (!memberPermissions?.has(Permissions?.FLAGS?.MANAGE_GUILD)) {
// Create embed object // Create embed object
const embed = { const embed = {
title: ":tools: Settings - Guild" as string, title: ':tools: Settings - Guild' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
description: "You do not have permission to manage this!" as string, description: 'You do not have permission to manage this!' as string,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -32,25 +32,25 @@ export default async (interaction: CommandInteraction) => {
}; };
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
// Module - Pterodactyl // Module - Pterodactyl
if (options?.getSubcommand() === "pterodactyl") { if (options?.getSubcommand() === 'pterodactyl') {
// Execute Module - Pterodactyl // Execute Module - Pterodactyl
return await pterodactyl(interaction); return pterodactyl(interaction);
} }
// Module - Credits // Module - Credits
else if (options?.getSubcommand() === "credits") { else if (options?.getSubcommand() === 'credits') {
// Execute Module - Credits // Execute Module - Credits
return await credits(interaction); return credits(interaction);
} }
// Module - Points // Module - Points
else if (options?.getSubcommand() === "points") { else if (options?.getSubcommand() === 'points') {
// Execute Module - Points // Execute Module - Points
return await points(interaction); return points(interaction);
} }
// Send debug message // Send debug message

View file

@ -1,14 +1,14 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../../config.json"; import config from '../../../../../config.json';
// Handlers // Handlers
import logger from "../../../../handlers/logger"; import logger from '../../../../handlers/logger';
// Models // Models
import fetchUser from "../../../../helpers/fetchUser"; import fetchUser from '../../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
@ -16,7 +16,7 @@ export default async (interaction: CommandInteraction) => {
const { options, user, guild } = interaction; const { options, user, guild } = interaction;
// Get options // Get options
const language = options?.getString("language"); const language = options?.getString('language');
if (guild === null) return; if (guild === null) return;
@ -32,17 +32,17 @@ export default async (interaction: CommandInteraction) => {
await userDB?.save()?.then(async () => { await userDB?.save()?.then(async () => {
// Embed object // Embed object
const embed = { const embed = {
title: ":hammer: Settings - User [Appearance]" as string, title: ':hammer: Settings - User [Appearance]' as string,
description: "Following settings is set!" as string, description: 'Following settings is set!' as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
fields: [ fields: [
{ {
name: "🏳️‍🌈 Language" as string, name: '🏳️‍🌈 Language' as string,
value: `${userDB?.language}` as string, value: `${userDB?.language}` as string,
inline: true, inline: true,
}, },
], ],
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -55,6 +55,6 @@ export default async (interaction: CommandInteraction) => {
); );
// Return interaction reply // Return interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
}); });
}; };

View file

@ -1,53 +1,53 @@
// Dependencies // Dependencies
import { SlashCommandBuilder } from "@discordjs/builders"; import { SlashCommandBuilder } from '@discordjs/builders';
import { CommandInteraction } from "discord.js"; import { CommandInteraction } from 'discord.js';
// Modules // Modules
import pterodactyl from "./modules/pterodactyl"; import pterodactyl from './modules/pterodactyl';
// Groups // Groups
import roles from "./roles"; import roles from './roles';
// Handlers // Handlers
import logger from "../../handlers/logger"; import logger from '../../handlers/logger';
// Function // Function
export default { export default {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("shop") .setName('shop')
.setDescription("Open our shop.") .setDescription('Open our shop.')
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand subcommand
.setName("pterodactyl") .setName('pterodactyl')
.setDescription("Buy pterodactyl power.") .setDescription('Buy pterodactyl power.')
.addIntegerOption((option) => .addIntegerOption((option) =>
option option
.setName("amount") .setName('amount')
.setDescription("How much credits you want to withdraw.") .setDescription('How much credits you want to withdraw.')
) )
) )
.addSubcommandGroup((group) => .addSubcommandGroup((group) =>
group group
.setName("roles") .setName('roles')
.setDescription("Manage custom roles.") .setDescription('Manage custom roles.')
.addSubcommand((command) => .addSubcommand((command) =>
command command
.setName("buy") .setName('buy')
.setDescription("Buy a custom role") .setDescription('Buy a custom role')
.addStringOption((option) => .addStringOption((option) =>
option option
.setName("name") .setName('name')
.setDescription("Name of the role you wish to purchase.") .setDescription('Name of the role you wish to purchase.')
) )
) )
.addSubcommand((command) => .addSubcommand((command) =>
command command
.setName("cancel") .setName('cancel')
.setDescription("Cancel a custom role") .setDescription('Cancel a custom role')
.addRoleOption((option) => .addRoleOption((option) =>
option option
.setName("role") .setName('role')
.setDescription("Name of the role you wish to cancel.") .setDescription('Name of the role you wish to cancel.')
) )
) )
), ),
@ -56,15 +56,15 @@ export default {
const { options, commandName, user, guild } = interaction; const { options, commandName, user, guild } = interaction;
// Module - Pterodactyl // Module - Pterodactyl
if (options?.getSubcommand() === "pterodactyl") { if (options?.getSubcommand() === 'pterodactyl') {
// Execute Module - Pterodactyl // Execute Module - Pterodactyl
return await pterodactyl(interaction); return pterodactyl(interaction);
} }
// Group - Roles // Group - Roles
else if (options?.getSubcommandGroup() === "roles") { else if (options?.getSubcommandGroup() === 'roles') {
// Execute Group - Roles // Execute Group - Roles
return await roles(interaction); return roles(interaction);
} }
// Send debug message // Send debug message

View file

@ -1,36 +1,36 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from 'uuid';
import axios from "axios"; import axios from 'axios';
// Configurations // Configurations
import config from "../../../../config.json"; import config from '../../../../config.json';
// Handlers // Handlers
import logger from "../../../handlers/logger"; import logger from '../../../handlers/logger';
// Helpers // Helpers
import creditNoun from "../../../helpers/creditNoun"; import creditNoun from '../../../helpers/creditNoun';
// Models // Models
import apiSchema from "../../../helpers/database/models/apiSchema"; import apiSchema from '../../../helpers/database/models/apiSchema';
import fetchUser from "../../../helpers/fetchUser"; import fetchUser from '../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
const { options, guild, user, client } = interaction; const { options, guild, user, client } = interaction;
// Get options // Get options
const optionAmount = options?.getInteger("amount"); const optionAmount = options?.getInteger('amount');
// If amount is null // If amount is null
if (optionAmount === null) { if (optionAmount === null) {
// Embed object // Embed object
const embed = { const embed = {
title: ":dollar: Credits [Gift]" as string, title: ':dollar: Credits [Gift]' as string,
description: "We could not read your requested amount." as string, description: 'We could not read your requested amount.' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -38,7 +38,7 @@ export default async (interaction: CommandInteraction) => {
}; };
// Send interaction reply // Send interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
if (guild === null) return; if (guild === null) return;
@ -54,17 +54,17 @@ export default async (interaction: CommandInteraction) => {
// Stop if amount or user credits is below 100 // Stop if amount or user credits is below 100
if ((optionAmount || userDB?.credits) < 100) { if ((optionAmount || userDB?.credits) < 100) {
const embed = { const embed = {
title: ":shopping_cart: Shop [Pterodactyl]" as string, title: ':shopping_cart: Shop [Pterodactyl]' as string,
description: description:
`You **can't** withdraw for __Pterodactyl__ below **100**.` as string, `You **can't** withdraw for __Pterodactyl__ below **100**.` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
fields: [ fields: [
{ {
name: "Your balance" as string, name: 'Your balance' as string,
value: `${creditNoun(userDB?.credits)}` as string, value: `${creditNoun(userDB?.credits)}` as string,
}, },
], ],
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -76,17 +76,17 @@ export default async (interaction: CommandInteraction) => {
// Stop if amount or user credits is above 1.000.000 // Stop if amount or user credits is above 1.000.000
if ((optionAmount || userDB?.credits) > 1000000) { if ((optionAmount || userDB?.credits) > 1000000) {
const embed = { const embed = {
title: ":shopping_cart: Shop [Pterodactyl]" as string, title: ':shopping_cart: Shop [Pterodactyl]' as string,
description: description:
`You **can't** withdraw for __Pterodactyl__ above **1.000.000**.` as string, `You **can't** withdraw for __Pterodactyl__ above **1.000.000**.` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
fields: [ fields: [
{ {
name: "Your balance" as string, name: 'Your balance' as string,
value: `${creditNoun(userDB?.credits)}` as string, value: `${creditNoun(userDB?.credits)}` as string,
}, },
], ],
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -98,16 +98,16 @@ export default async (interaction: CommandInteraction) => {
// Stop if user credits is below amount // Stop if user credits is below amount
if (userDB?.credits < optionAmount) { if (userDB?.credits < optionAmount) {
const embed = { const embed = {
title: ":shopping_cart: Shop [Pterodactyl]" as string, title: ':shopping_cart: Shop [Pterodactyl]' as string,
description: `You have **insufficient** credits.` as string, description: `You have **insufficient** credits.` as string,
color: config.colors.error as ColorResolvable, color: config.colors.error as ColorResolvable,
fields: [ fields: [
{ {
name: "Your balance" as string, name: 'Your balance' as string,
value: `${creditNoun(userDB?.credits)}` as string, value: `${creditNoun(userDB?.credits)}` as string,
}, },
], ],
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -131,13 +131,13 @@ export default async (interaction: CommandInteraction) => {
}); });
// Get shop URL // Get shop URL
const shopUrl = apiCredentials?.url?.replace("/api", "/store"); const shopUrl = apiCredentials?.url?.replace('/api', '/store');
// Make API request // Make API request
await api await api
// Make a post request to the API // Make a post request to the API
?.post("vouchers", { ?.post('vouchers', {
uses: 1, uses: 1,
code, code,
credits: optionAmount || userDB?.credits, credits: optionAmount || userDB?.credits,
@ -148,18 +148,18 @@ export default async (interaction: CommandInteraction) => {
?.then(async () => { ?.then(async () => {
// Create DM embed object // Create DM embed object
const dmEmbed = { const dmEmbed = {
title: ":shopping_cart: Shop [Pterodactyl]" as string, title: ':shopping_cart: Shop [Pterodactyl]' as string,
description: `Redeem this voucher [here](${shopUrl})!` as string, description: `Redeem this voucher [here](${shopUrl})!` as string,
fields: [ 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, value: `${optionAmount || userDB?.credits}` as string,
inline: true, inline: true,
}, },
], ],
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -168,10 +168,10 @@ export default async (interaction: CommandInteraction) => {
// Create interaction embed object // Create interaction embed object
const interactionEmbed = { const interactionEmbed = {
title: ":shopping_cart: Shop [Pterodactyl]" as string, title: ':shopping_cart: Shop [Pterodactyl]' as string,
description: "I have sent you the code in DM!" as string, description: 'I have sent you the code in DM!' as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -204,11 +204,11 @@ export default async (interaction: CommandInteraction) => {
.catch(async (e: any) => { .catch(async (e: any) => {
logger?.error(e); logger?.error(e);
const embed = { const embed = {
title: ":shopping_cart: Shop [Pterodactyl]" as string, title: ':shopping_cart: Shop [Pterodactyl]' as string,
description: 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, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -222,10 +222,10 @@ export default async (interaction: CommandInteraction) => {
.catch(async (e) => { .catch(async (e) => {
logger?.error(e); logger?.error(e);
const embed = { 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, description: 'Something went wrong, please try again later.' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,

View file

@ -3,33 +3,33 @@ import {
CommandInteraction, CommandInteraction,
ColorResolvable, ColorResolvable,
GuildMemberRoleManager, GuildMemberRoleManager,
} from "discord.js"; } from 'discord.js';
// Configurations // Configurations
import config from "../../../../../config.json"; import config from '../../../../../config.json';
// Models // Models
import shopRolesSchema from "../../../../helpers/database/models/shopRolesSchema"; import shopRolesSchema from '../../../../helpers/database/models/shopRolesSchema';
import guildSchema from "../../../../helpers/database/models/guildSchema"; import guildSchema from '../../../../helpers/database/models/guildSchema';
// Helpers // Helpers
import creditNoun from "../../../../helpers/creditNoun"; import creditNoun from '../../../../helpers/creditNoun';
import fetchUser from "../../../../helpers/fetchUser"; import fetchUser from '../../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
const { options, guild, user, member } = interaction; const { options, guild, user, member } = interaction;
const optionName = options?.getString("name"); const optionName = options?.getString('name');
// If amount is null // If amount is null
if (optionName === null) { if (optionName === null) {
// Embed object // Embed object
const embed = { const embed = {
title: ":dollar: Shop - Roles [Buy]" as string, title: ':dollar: Shop - Roles [Buy]' as string,
description: "We could not read your requested name." as string, description: 'We could not read your requested name.' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -37,13 +37,13 @@ export default async (interaction: CommandInteraction) => {
}; };
// Send interaction reply // Send interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
await guild?.roles await guild?.roles
.create({ .create({
name: optionName, name: optionName,
color: "RED", color: 'RED',
reason: `${user?.id} bought from shop`, reason: `${user?.id} bought from shop`,
}) })
.then(async (role) => { .then(async (role) => {
@ -74,17 +74,17 @@ export default async (interaction: CommandInteraction) => {
await shopRolesSchema?.find()?.then((role: any) => console.log(role)); await shopRolesSchema?.find()?.then((role: any) => console.log(role));
const embed = { const embed = {
title: ":shopping_cart: Shop - Roles [Buy]" as string, title: ':shopping_cart: Shop - Roles [Buy]' as string,
description: description:
`You have bought ${role?.name} for ${guildDB?.shop?.roles?.pricePerHour} per hour.` as string, `You have bought ${role?.name} for ${guildDB?.shop?.roles?.pricePerHour} per hour.` as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
fields: [ fields: [
{ {
name: "Your balance" as string, name: 'Your balance' as string,
value: `${creditNoun(userDB?.credits)}` as string, value: `${creditNoun(userDB?.credits)}` as string,
}, },
], ],
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,

View file

@ -3,32 +3,32 @@ import {
CommandInteraction, CommandInteraction,
ColorResolvable, ColorResolvable,
GuildMemberRoleManager, GuildMemberRoleManager,
} from "discord.js"; } from 'discord.js';
// Configurations // Configurations
import config from "../../../../../config.json"; import config from '../../../../../config.json';
// Models // Models
import shopRolesSchema from "../../../../helpers/database/models/shopRolesSchema"; import shopRolesSchema from '../../../../helpers/database/models/shopRolesSchema';
// Helpers // Helpers
import creditNoun from "../../../../helpers/creditNoun"; import creditNoun from '../../../../helpers/creditNoun';
import fetchUser from "../../../../helpers/fetchUser"; import fetchUser from '../../../../helpers/fetchUser';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
const { options, guild, user, member } = interaction; const { options, guild, user, member } = interaction;
const optionRole = options.getRole("role"); const optionRole = options.getRole('role');
// If amount is null // If amount is null
if (optionRole === null) { if (optionRole === null) {
// Embed object // Embed object
const embed = { const embed = {
title: ":dollar: Shop - Roles [Cancel]" as string, title: ':dollar: Shop - Roles [Cancel]' as string,
description: "We could not read your requested role." as string, description: 'We could not read your requested role.' as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -36,7 +36,7 @@ export default async (interaction: CommandInteraction) => {
}; };
// Send interaction reply // Send interaction reply
return await interaction?.editReply({ embeds: [embed] }); return interaction?.editReply({ embeds: [embed] });
} }
const roleExist = await shopRolesSchema?.find({ const roleExist = await shopRolesSchema?.find({
@ -62,16 +62,16 @@ export default async (interaction: CommandInteraction) => {
}); });
const embed = { 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, description: `You have canceled ${optionRole.name}.` as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
fields: [ fields: [
{ {
name: "Your balance" as string, name: 'Your balance' as string,
value: `${creditNoun(userDB?.credits)}` as string, value: `${creditNoun(userDB?.credits)}` as string,
}, },
], ],
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,

View file

@ -1,57 +1,57 @@
// Dependencies // Dependencies
import { SlashCommandBuilder } from "@discordjs/builders"; import { SlashCommandBuilder } from '@discordjs/builders';
import { CommandInteraction } from "discord.js"; import { CommandInteraction } from 'discord.js';
// Modules // Modules
import lookup from "./modules/lookup"; import lookup from './modules/lookup';
import about from "./modules/about"; import about from './modules/about';
import stats from "./modules/stats"; import stats from './modules/stats';
// Handlers // Handlers
import logger from "../../handlers/logger"; import logger from '../../handlers/logger';
// Function // Function
export default { export default {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("utilities") .setName('utilities')
.setDescription("Common utilities.") .setDescription('Common utilities.')
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand subcommand
.setName("lookup") .setName('lookup')
.setDescription( .setDescription(
"Lookup a domain or ip. (Request sent over HTTP, proceed with caution!)" 'Lookup a domain or ip. (Request sent over HTTP, proceed with caution!)'
) )
.addStringOption((option) => .addStringOption((option) =>
option option
.setName("query") .setName('query')
.setDescription("The query you want to look up.") .setDescription('The query you want to look up.')
.setRequired(true) .setRequired(true)
) )
) )
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand.setName("about").setDescription("About this bot!)") subcommand.setName('about').setDescription('About this bot!)')
) )
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand.setName("stats").setDescription("Check bot statistics!)") subcommand.setName('stats').setDescription('Check bot statistics!)')
), ),
async execute(interaction: CommandInteraction) { async execute(interaction: CommandInteraction) {
// Destructure // Destructure
const { options, guild, user, commandName } = interaction; const { options, guild, user, commandName } = interaction;
// Module - Lookup // Module - Lookup
if (options?.getSubcommand() === "lookup") { if (options?.getSubcommand() === 'lookup') {
// Execute Module - Lookup // Execute Module - Lookup
return await lookup(interaction); return lookup(interaction);
} }
// Module - About // Module - About
else if (options?.getSubcommand() === "about") { else if (options?.getSubcommand() === 'about') {
// Execute Module - About // Execute Module - About
return await about(interaction); return about(interaction);
} }
// Module - Stats // Module - Stats
else if (options?.getSubcommand() === "stats") { else if (options?.getSubcommand() === 'stats') {
// Execute Module - Stats // Execute Module - Stats
return await stats(interaction); return stats(interaction);
} }
// Send debug message // Send debug message

View file

@ -1,13 +1,13 @@
// Dependencies // Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../config.json"; import config from '../../../../config.json';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
const interactionEmbed = { const interactionEmbed = {
title: ":hammer: Utilities [About]" as string, title: ':hammer: Utilities [About]' as string,
description: `This bot is hosted by ${ description: `This bot is hosted by ${
config?.hoster?.url config?.hoster?.url
? `[${config?.hoster?.name}](${config?.hoster?.url})` ? `[${config?.hoster?.name}](${config?.hoster?.url})`
@ -16,7 +16,7 @@ export default async (interaction: CommandInteraction) => {
If you are interested in contributing, then just [fork it](https://github.com/ZynerOrg/xyter) yourself, we :heart: Open Source.` as string, If you are interested in contributing, then just [fork it](https://github.com/ZynerOrg/xyter) yourself, we :heart: Open Source.` as string,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,

View file

@ -1,18 +1,18 @@
// Dependencies // Dependencies
import axios from "axios"; import axios from 'axios';
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations // Configurations
import config from "../../../../config.json"; import config from '../../../../config.json';
// Handlers // Handlers
import logger from "../../../handlers/logger"; import logger from '../../../handlers/logger';
// Function // Function
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
const { options } = interaction; const { options } = interaction;
// Get lookup query // Get lookup query
const query = options?.getString("query"); const query = options?.getString('query');
// Make API request // Make API request
await axios await axios
@ -22,13 +22,13 @@ export default async (interaction: CommandInteraction) => {
// If successful // If successful
?.then(async (res) => { ?.then(async (res) => {
// If query failed // If query failed
if (res?.data?.status === "fail") { if (res?.data?.status === 'fail') {
// Create embed object // Create embed object
const embed = { const embed = {
title: ":hammer: Utilities - Lookup" as string, title: ':hammer: Utilities - Lookup' as string,
description: `${res?.data?.message}: ${res?.data?.query}` as string, description: `${res?.data?.message}: ${res?.data?.query}` as string,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,
@ -40,62 +40,62 @@ export default async (interaction: CommandInteraction) => {
} }
// If query is successful // If query is successful
else if (res?.data?.status === "success") { else if (res?.data?.status === 'success') {
// Create embed object // Create embed object
const embed = { const embed = {
title: ":hammer: Utilities - Lookup" as string, title: ':hammer: Utilities - Lookup' as string,
fields: [ fields: [
{ {
name: "AS" as string, name: 'AS' as string,
value: `${res?.data?.as || "Not available"}` as string, value: `${res?.data?.as || 'Not available'}` as string,
}, },
{ {
name: "Country" as string, name: 'Country' as string,
value: `${res?.data?.country || "Not available"}` as string, value: `${res?.data?.country || 'Not available'}` as string,
}, },
{ {
name: "Country Code" as string, name: 'Country Code' as string,
value: `${res?.data?.countryCode || "Not available"}` as string, value: `${res?.data?.countryCode || 'Not available'}` as string,
}, },
{ {
name: "Region" as string, name: 'Region' as string,
value: `${res?.data?.region || "Not available"}` as string, value: `${res?.data?.region || 'Not available'}` as string,
}, },
{ {
name: "Region Name" as string, name: 'Region Name' as string,
value: `${res?.data?.regionName || "Not available"}` as string, value: `${res?.data?.regionName || 'Not available'}` as string,
}, },
{ {
name: "City" as string, name: 'City' as string,
value: `${res?.data?.city || "Not available"}` as string, value: `${res?.data?.city || 'Not available'}` as string,
}, },
{ {
name: "ZIP Code" as string, name: 'ZIP Code' as string,
value: `${res?.data?.zip || "Not available"}` as string, value: `${res?.data?.zip || 'Not available'}` as string,
}, },
{ {
name: "Latitude" as string, name: 'Latitude' as string,
value: `${res?.data?.lat || "Not available"}` as string, value: `${res?.data?.lat || 'Not available'}` as string,
}, },
{ {
name: "Longitude" as string, name: 'Longitude' as string,
value: `${res?.data?.lon || "Not available"}` as string, value: `${res?.data?.lon || 'Not available'}` as string,
}, },
{ {
name: "Timezone" as string, name: 'Timezone' as string,
value: `${res?.data?.timezone || "Not available"}` as string, value: `${res?.data?.timezone || 'Not available'}` as string,
}, },
{ {
name: "ISP" as string, name: 'ISP' as string,
value: `${res?.data?.isp || "Not available"}` as string, value: `${res?.data?.isp || 'Not available'}` as string,
}, },
{ {
name: "Organization" as string, name: 'Organization' as string,
value: `${res?.data?.org || "Not available"}` as string, value: `${res?.data?.org || 'Not available'}` as string,
}, },
], ],
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,

View file

@ -1,5 +1,5 @@
import config from "../../../../config.json"; import config from '../../../../config.json';
import { CommandInteraction, ColorResolvable } from "discord.js"; import { CommandInteraction, ColorResolvable } from 'discord.js';
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
const { client } = interaction; const { client } = interaction;
if (client?.uptime === null) return; if (client?.uptime === null) return;
@ -14,32 +14,32 @@ export default async (interaction: CommandInteraction) => {
const uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`; const uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`;
const interactionEmbed = { const interactionEmbed = {
title: ":hammer: Utilities - Stats" as string, title: ':hammer: Utilities - Stats' as string,
description: description:
"Below you can see a list of statistics about the bot." as string, 'Below you can see a list of statistics about the bot.' as string,
fields: [ fields: [
{ {
name: "⏰ Latency" as string, name: '⏰ Latency' as string,
value: `${Date?.now() - interaction?.createdTimestamp} ms` as string, value: `${Date?.now() - interaction?.createdTimestamp} ms` as string,
inline: true, inline: true,
}, },
{ {
name: "⏰ API Latency" as string, name: '⏰ API Latency' as string,
value: `${Math?.round(client?.ws?.ping)} ms` as string, value: `${Math?.round(client?.ws?.ping)} ms` as string,
inline: true, inline: true,
}, },
{ {
name: "⏰ Uptime" as string, name: '⏰ Uptime' as string,
value: `${uptime}` as string, value: `${uptime}` as string,
inline: false, inline: false,
}, },
{ {
name: "📈 Guilds" as string, name: '📈 Guilds' as string,
value: `${client?.guilds?.cache?.size}` as string, value: `${client?.guilds?.cache?.size}` as string,
inline: true, inline: true,
}, },
{ {
name: "📈 Users (non-unique)" as string, name: '📈 Users (non-unique)' as string,
value: `${client?.guilds?.cache?.reduce( value: `${client?.guilds?.cache?.reduce(
(acc, guild) => acc + guild?.memberCount, (acc, guild) => acc + guild?.memberCount,
0 0
@ -48,7 +48,7 @@ export default async (interaction: CommandInteraction) => {
}, },
], ],
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date, timestamp: new Date(),
footer: { footer: {
iconURL: config?.footer?.icon as string, iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string, text: config?.footer?.text as string,