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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,13 +1,13 @@
// Dependencies
import { CommandInteraction, ColorResolvable } from "discord.js";
import { CommandInteraction, ColorResolvable } from 'discord.js';
// Configurations
import config from "../../../../config.json";
import config from '../../../../config.json';
// Function
export default async (interaction: CommandInteraction) => {
const interactionEmbed = {
title: ":hammer: Utilities [About]" as string,
title: ':hammer: Utilities [About]' as string,
description: `This bot is hosted by ${
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,
color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date,
timestamp: new Date(),
footer: {
iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string,

View file

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

View file

@ -1,5 +1,5 @@
import config from "../../../../config.json";
import { CommandInteraction, ColorResolvable } from "discord.js";
import config from '../../../../config.json';
import { CommandInteraction, ColorResolvable } from 'discord.js';
export default async (interaction: CommandInteraction) => {
const { client } = interaction;
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 interactionEmbed = {
title: ":hammer: Utilities - Stats" as string,
title: ':hammer: Utilities - Stats' as string,
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: [
{
name: "⏰ Latency" as string,
name: '⏰ Latency' as string,
value: `${Date?.now() - interaction?.createdTimestamp} ms` as string,
inline: true,
},
{
name: "⏰ API Latency" as string,
name: '⏰ API Latency' as string,
value: `${Math?.round(client?.ws?.ping)} ms` as string,
inline: true,
},
{
name: "⏰ Uptime" as string,
name: '⏰ Uptime' as string,
value: `${uptime}` as string,
inline: false,
},
{
name: "📈 Guilds" as string,
name: '📈 Guilds' as string,
value: `${client?.guilds?.cache?.size}` as string,
inline: true,
},
{
name: "📈 Users (non-unique)" as string,
name: '📈 Users (non-unique)' as string,
value: `${client?.guilds?.cache?.reduce(
(acc, guild) => acc + guild?.memberCount,
0
@ -48,7 +48,7 @@ export default async (interaction: CommandInteraction) => {
},
],
color: config?.colors?.success as ColorResolvable,
timestamp: new Date() as Date,
timestamp: new Date(),
footer: {
iconURL: config?.footer?.icon as string,
text: config?.footer?.text as string,