Merge pull request #205 from VermiumSifell/201-fix-code-smells

Fix admin commands
This commit is contained in:
Axel Olausson Holtenäs 2022-04-10 23:17:19 +02:00 committed by GitHub
commit 0b6ccc9cb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 60 deletions

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,17 +19,17 @@ 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(), timestamp: new Date(),
footer: { footer: {
@ -46,8 +46,8 @@ export default async (interaction: CommandInteraction) => {
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(), timestamp: new Date(),
footer: { footer: {
@ -70,7 +70,7 @@ 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.`, description: `We could not find ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),
@ -85,10 +85,10 @@ export default async (interaction: CommandInteraction) => {
} }
// If toUser.credits does not exist // If toUser.credits does not exist
if (!toUser?.credits) { if (toUser?.credits === 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 find credits for ${optionUser} in our database.`, description: `We could not find credits for ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),
@ -109,7 +109,7 @@ 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(optionAmount)}.`, description: `We have given ${optionUser}, ${creditNoun(optionAmount)}.`,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),

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,17 +19,17 @@ 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(), timestamp: new Date(),
footer: { footer: {
@ -52,7 +52,7 @@ 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.`, description: `We could not find ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),
@ -67,10 +67,10 @@ export default async (interaction: CommandInteraction) => {
} }
// If toUser.credits does not exist // If toUser.credits does not exist
if (!toUser?.credits) { if (toUser?.credits === 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 find credits for ${optionUser} in our database.`, description: `We could not find credits for ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),
@ -91,7 +91,7 @@ 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(optionAmount)}`, description: `We have set ${optionUser} to ${creditNoun(optionAmount)}`,
color: config?.colors?.success as ColorResolvable, color: config?.colors?.success as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),

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,17 +19,17 @@ 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(), timestamp: new Date(),
footer: { footer: {
@ -46,8 +46,8 @@ export default async (interaction: CommandInteraction) => {
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(), timestamp: new Date(),
footer: { footer: {
@ -70,7 +70,7 @@ 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.`, description: `We could not find ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),
@ -85,10 +85,10 @@ export default async (interaction: CommandInteraction) => {
} }
// If toUser.credits does not exist // If toUser.credits does not exist
if (!toUser?.credits) { if (toUser?.credits === 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 find credits for ${optionUser} in our database.`, description: `We could not find credits for ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),
@ -109,7 +109,7 @@ 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}`, )} from ${optionUser}`,

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,16 +20,16 @@ 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(), timestamp: new Date(),
footer: { footer: {
@ -56,7 +56,7 @@ 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: `We could not find ${optionFromUser} in our database.`, description: `We could not find ${optionFromUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),
@ -74,7 +74,7 @@ export default async (interaction: CommandInteraction) => {
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: `We could not find credits for ${optionFromUser} in our database.`, description: `We could not find credits for ${optionFromUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),
@ -92,7 +92,7 @@ export default async (interaction: CommandInteraction) => {
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: `We could not find ${optionToUser} in our database.`, description: `We could not find ${optionToUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),
@ -107,10 +107,10 @@ export default async (interaction: CommandInteraction) => {
} }
// If toUser.credits does not exist // If toUser.credits does not exist
if (!toUser?.credits) { if (toUser?.credits === 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 find credits for ${optionToUser} in our database.`, description: `We could not find credits for ${optionToUser} in our database.`,
color: config?.colors?.error as ColorResolvable, color: config?.colors?.error as ColorResolvable,
timestamp: new Date(), timestamp: new Date(),
@ -134,7 +134,7 @@ 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}.`, )} from ${optionFromUser} to ${optionToUser}.`,