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

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,17 +19,17 @@ export default async (interaction: CommandInteraction) => {
const { options, user, guild } = interaction;
// User Option
const optionUser = options.getUser("user");
const optionUser = options.getUser('user');
// Amount Option
const optionAmount = options.getInteger("amount");
const optionAmount = options.getInteger('amount');
// If amount is null
if (optionAmount === null) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Set]" as string,
description: "We could not read your requested amount." as string,
title: ':toolbox: Admin - Credits [Set]' as string,
description: 'We could not read your requested amount.' as string,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
footer: {
@ -52,7 +52,7 @@ export default async (interaction: CommandInteraction) => {
if (!toUser) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Set]" as string,
title: ':toolbox: Admin - Credits [Set]' as string,
description: `We could not find ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
@ -67,10 +67,10 @@ export default async (interaction: CommandInteraction) => {
}
// If toUser.credits does not exist
if (!toUser?.credits) {
if (toUser?.credits === null) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Set]" as string,
title: ':toolbox: Admin - Credits [Set]' as string,
description: `We could not find credits for ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
@ -91,7 +91,7 @@ export default async (interaction: CommandInteraction) => {
await toUser?.save()?.then(async () => {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Set]" as string,
title: ':toolbox: Admin - Credits [Set]' as string,
description: `We have set ${optionUser} to ${creditNoun(optionAmount)}`,
color: config?.colors?.success as ColorResolvable,
timestamp: new Date(),

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,17 +19,17 @@ export default async (interaction: CommandInteraction) => {
const { guild, user, options } = interaction;
// User option
const optionUser = options?.getUser("user");
const optionUser = options?.getUser('user');
// Amount option
const optionAmount = options?.getInteger("amount");
const optionAmount = options?.getInteger('amount');
// If amount is null
if (optionAmount === null) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Take]" as string,
description: "We could not read your requested amount." as string,
title: ':toolbox: Admin - Credits [Take]' as string,
description: 'We could not read your requested amount.' as string,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
footer: {
@ -46,8 +46,8 @@ export default async (interaction: CommandInteraction) => {
if (optionAmount <= 0) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Take]" as string,
description: "You can not take zero credits or below." as string,
title: ':toolbox: Admin - Credits [Take]' as string,
description: 'You can not take zero credits or below.' as string,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
footer: {
@ -70,7 +70,7 @@ export default async (interaction: CommandInteraction) => {
if (!toUser) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Take]" as string,
title: ':toolbox: Admin - Credits [Take]' as string,
description: `We could not find ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
@ -85,10 +85,10 @@ export default async (interaction: CommandInteraction) => {
}
// If toUser.credits does not exist
if (!toUser?.credits) {
if (toUser?.credits === null) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Take]" as string,
title: ':toolbox: Admin - Credits [Take]' as string,
description: `We could not find credits for ${optionUser} in our database.`,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
@ -109,7 +109,7 @@ export default async (interaction: CommandInteraction) => {
await toUser?.save()?.then(async () => {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Set]" as string,
title: ':toolbox: Admin - Credits [Set]' as string,
description: `We have taken ${creditNoun(
optionAmount
)} from ${optionUser}`,

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,16 +20,16 @@ export default async (interaction: CommandInteraction) => {
const { guild, options, user } = interaction;
// Get options
const optionFromUser = options?.getUser("from");
const optionToUser = options?.getUser("to");
const optionAmount = options?.getInteger("amount");
const optionFromUser = options?.getUser('from');
const optionToUser = options?.getUser('to');
const optionAmount = options?.getInteger('amount');
// If amount is null
if (optionAmount === null) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string,
description: "We could not read your requested amount." as string,
title: ':toolbox: Admin - Credits [Transfer]' as string,
description: 'We could not read your requested amount.' as string,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
footer: {
@ -56,7 +56,7 @@ export default async (interaction: CommandInteraction) => {
if (!fromUser) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string,
title: ':toolbox: Admin - Credits [Transfer]' as string,
description: `We could not find ${optionFromUser} in our database.`,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
@ -74,7 +74,7 @@ export default async (interaction: CommandInteraction) => {
if (!fromUser?.credits) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string,
title: ':toolbox: Admin - Credits [Transfer]' as string,
description: `We could not find credits for ${optionFromUser} in our database.`,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
@ -92,7 +92,7 @@ export default async (interaction: CommandInteraction) => {
if (!toUser) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string,
title: ':toolbox: Admin - Credits [Transfer]' as string,
description: `We could not find ${optionToUser} in our database.`,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
@ -107,10 +107,10 @@ export default async (interaction: CommandInteraction) => {
}
// If toUser.credits does not exist
if (!toUser?.credits) {
if (toUser?.credits === null) {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string,
title: ':toolbox: Admin - Credits [Transfer]' as string,
description: `We could not find credits for ${optionToUser} in our database.`,
color: config?.colors?.error as ColorResolvable,
timestamp: new Date(),
@ -134,7 +134,7 @@ export default async (interaction: CommandInteraction) => {
await saveUser(fromUser, toUser)?.then(async () => {
// Embed object
const embed = {
title: ":toolbox: Admin - Credits [Transfer]" as string,
title: ':toolbox: Admin - Credits [Transfer]' as string,
description: `You sent ${creditNoun(
optionAmount
)} from ${optionFromUser} to ${optionToUser}.`,