Changed small functions to methods

Added custom color function
This commit is contained in:
2024-09-07 20:09:29 +02:00
parent a9fb41cece
commit 7a2a136f30
33 changed files with 74 additions and 76 deletions

View File

@@ -2,7 +2,7 @@ import { REST, RESTPutAPIApplicationCommandsJSONBody, Routes } from "discord.js"
import fs from "node:fs"
import { ICommand } from "../src/interfaces"
import env from "../src/utils/Env"
import color from "../src/utils/functions/colors"
import { color } from "../src/utils/functions/colors"
const rest = new REST({ version: "10" }).setToken(env.prod.token)
const commands: RESTPutAPIApplicationCommandsJSONBody = []

View File

@@ -2,14 +2,12 @@ import { anilist } from "anilist"
import { devMessage, embedColor } from "config/options.js"
import { SlashCommandBuilder } from "discord.js"
import { ICommand } from "interfaces"
import { capitalizeFirstLetter, removeIndents } from "utils/functions/funcs.js"
export default {
name: "anime",
description: "Anime subcommands",
public: true,
dev: false,
subcommands: true,
data: new SlashCommandBuilder()
.setName("anime")
@@ -59,14 +57,14 @@ export default {
const animeEpisodes = anime.episodes ? animeEpisodesRaw : "No episodes available"
const animeStartDate = [anime.startDate?.day || "??", anime.startDate?.month || "??", anime.startDate?.year || "????"].join(".")
const animeEndDate = [anime.endDate?.day || "??", anime.endDate?.month || "??", anime.endDate?.year || "????"].join(".")
const animeSeasonRaw = capitalizeFirstLetter(anime.season ?? "null") + " " + anime.startDate?.year
const animeSeasonRaw = anime.season?.capitalizeFirstLetter() + " " + anime.startDate?.year
const animeSeason = anime.season ? animeSeasonRaw : "No season available"
await interaction.editReply({
embeds: [{
title: romaji + " | " + english,
url: anime.siteUrl || "",
description: removeIndents(`
description: `
**Description:** ${animeDescription}
**Genres:** ${anime.genres.join(", ")}
@@ -76,7 +74,7 @@ export default {
**Season:** ${animeSeason}
**Start Date:** ${animeStartDate}
**End Date:** ${animeEndDate}
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: anime.coverImage?.medium || ""

View File

@@ -2,7 +2,6 @@ import { devMessage, embedColor } from "config/options.js"
import { admin, helper } from "config/roles.js"
import { GuildMember, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
import { ICommand } from "interfaces"
import { removeIndents } from "utils/functions/funcs.js"
import logToChannel from "utils/functions/logtochannel.js"
export default {
@@ -102,12 +101,12 @@ export default {
icon_url: mod.user.avatarURL() || undefined
},
title: "Member Banned",
description: removeIndents(`
description: `
**User:** ${userMention(member.user.id)}
**Mod:** ${userMention(mod.user.id)}
**Reason:** ${reason}
**Messages Deleted:** ${messageDeletionDays} days
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: mod.user.avatarURL() || ""

View File

@@ -5,7 +5,6 @@ import { ICommand } from "interfaces"
import { createRequire } from "node:module"
import os from "os"
import prettyMs from "pretty-ms"
import { removeIndents } from "utils/functions/funcs.js"
const require = createRequire(import.meta.url)
const { dependencies, devDependencies } = require("../../package.json")
@@ -46,7 +45,7 @@ export default {
await interaction.reply({
embeds: [{
title: "Bot Info",
description: removeIndents(`
description: `
__**Bot**__
> **Name**: \`${client.user!.username}\`
> **ID**: \`${client.user!.id}\`
@@ -67,7 +66,7 @@ export default {
> **Channels:** \`${client.channels.cache.size}\`
> **Users:** \`${client.users.cache.size}\`
> **Roles:** \`${client.guilds.cache.reduce((a, b) => a + b.roles.cache.size, 0)}\`
`),
`.removeIndents(),
thumbnail: {
url: client.user!.avatarURL() || ""
},

View File

@@ -1,7 +1,6 @@
import { embedColor } from "config/options.js"
import { channelMention, PermissionFlagsBits, SlashCommandBuilder, TextChannel, userMention } from "discord.js"
import { ICommand } from "interfaces"
import { removeIndents } from "utils/functions/funcs.js"
import logToChannel from "utils/functions/logtochannel.js"
export default {
@@ -53,11 +52,11 @@ export default {
icon_url: interaction.user.avatarURL() || undefined
},
title: "Messages Cleared",
description: removeIndents(`
description: `
**Channel:** ${channelMention(channel.id)}
**Amount:** \`${messages.size}\` messages
**Mod:** ${userMention(interaction.user.id)}
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: interaction.user.avatarURL() || ""

View File

@@ -2,7 +2,6 @@ import { devMessage, embedColor } from "config/options.js"
import { GuildMember, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
import { ICommand } from "interfaces"
import verify from "schemas/verifyTag.js"
import { removeIndents } from "utils/functions/funcs.js"
import logToChannel from "utils/functions/logtochannel.js"
import roleManage from "utils/functions/rolesmanage.js"
import { getIGN } from "utils/Hypixel.js"
@@ -58,12 +57,12 @@ export default {
name: mod.username,
icon_url: mod.avatarURL() || undefined
},
description: removeIndents(`
description: `
**User:** ${userMention(member.user.id)}
**Mod:** ${userMention(mod.id)}
**IGN:** \`${ign}\`
**UUID:** \`${uuid}\`
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: mod.avatarURL() || ""

View File

@@ -3,7 +3,6 @@ import { waitingListRole } from "config/roles.js"
import { GuildMember, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
import { ICommand } from "interfaces"
import verify from "schemas/verifyTag.js"
import { removeIndents } from "utils/functions/funcs.js"
import roleManage from "utils/functions/rolesmanage.js"
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel.js"
@@ -85,11 +84,11 @@ export default {
await interaction.editReply({
embeds: [{
description: removeIndents(`
description: `
${usermentioned} was given the \`Default Member\` role.
IGN: \`${ign}\`
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: head!
@@ -159,11 +158,11 @@ export default {
await interaction.editReply({
embeds: [{
description: removeIndents(`
description: `
${usermentioned} was given the \`${replyRank}\` role.
IGN: \`${ign}\`
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: head!

View File

@@ -2,7 +2,6 @@ import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
import { GuildMember, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
import { ICommand } from "interfaces"
import verify from "schemas/verifyTag.js"
import { removeIndents } from "utils/functions/funcs.js"
import logToChannel from "utils/functions/logtochannel.js"
import roleManage from "utils/functions/rolesmanage.js"
import { getGuild, getHeadURL, getPlayer, getUUID } from "utils/Hypixel.js"
@@ -173,12 +172,12 @@ export default {
icon_url: mod.avatarURL() || undefined
},
title: "Force Verified",
description: removeIndents(`
description: `
**User:** ${userMention(user.id)}
**Mod:** ${userMention(mod.id)}
**IGN:** \`${player.displayname}\`
**UUID:** \`${uuid}\`
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: mod.avatarURL() || ""

View File

@@ -1,7 +1,6 @@
import { devMessage, embedColor, instructionsgif } from "config/options.js"
import { PermissionFlagsBits, SlashCommandBuilder } from "discord.js"
import { ICommand } from "interfaces"
import { removeIndents } from "utils/functions/funcs.js"
export default {
name: "instructions",
@@ -19,14 +18,14 @@ export default {
await interaction.reply({
embeds: [{
title: "Verification",
description: removeIndents(`
description: `
- Log onto hypixel.
- Right click with the head in your hotbar.
- Click on the social media icon.
- Click on the discord icon.
- Type your username in the chat and press enter.
- Run the \`/verify\` command in this channel.
`),
`.removeIndents(),
thumbnail: {
url: interaction.guild?.iconURL() || ""
},

View File

@@ -2,7 +2,6 @@ import { devMessage, embedColor } from "config/options.js"
import { admin, helper } from "config/roles.js"
import { GuildMember, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
import { ICommand } from "interfaces"
import { removeIndents } from "utils/functions/funcs.js"
import logToChannel from "utils/functions/logtochannel.js"
export default {
@@ -76,11 +75,11 @@ export default {
icon_url: mod.user.avatarURL() || undefined
},
title: "Member Kicked",
description: removeIndents(`
description: `
**User:** ${userMention(member.user.id)}
**Mod:** ${userMention(mod.user.id)}
**Reason:** ${reason}
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: mod.user.avatarURL() || ""

View File

@@ -1,7 +1,6 @@
import { embedColor } from "config/options.js"
import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction } from "discord.js"
import { removeIndents } from "utils/functions/funcs.js"
export default async function nowplaying(interaction: ChatInputCommandInteraction) {
await interaction.deferReply()
@@ -42,11 +41,11 @@ export default async function nowplaying(interaction: ChatInputCommandInteractio
await interaction.editReply({
embeds: [{
title: "Now Playing",
description: removeIndents(`
description: `
[${current.title}](${current.url})
${progressBar}
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: current.thumbnail

View File

@@ -3,7 +3,6 @@ import { waitingListRole } from "config/roles.js"
import { GuildMember, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
import { ICommand } from "interfaces"
import waitinglist from "schemas/waitinglistTag.js"
import { removeIndents } from "utils/functions/funcs.js"
import logToChannel from "utils/functions/logtochannel.js"
export default {
@@ -58,11 +57,11 @@ export default {
icon_url: mod.avatarURL() || undefined
},
title: "Waiting List - Remove User",
description: removeIndents(`
description: `
**User:** ${userMention(member.user.id)}
**Reason:** ${reason}
**Mod:** ${userMention(mod.id)}
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: mod.avatarURL() || ""

View File

@@ -1,7 +1,6 @@
import { devMessage, embedColor } from "config/options.js"
import { GuildMember, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
import { ICommand } from "interfaces"
import { removeIndents } from "utils/functions/funcs.js"
import logToChannel from "utils/functions/logtochannel.js"
export default {
@@ -49,11 +48,11 @@ export default {
icon_url: interaction.user.avatarURL() || undefined
},
title: "Nickname",
description: removeIndents(`
description: `
**User:** ${userMention(member.id)}
**Nickname:** ${nickname}
**Moderator:** ${userMention(interaction.user.id)}
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: interaction.user.avatarURL() || ""

View File

@@ -1,7 +1,6 @@
import { devMessage, embedColor } from "config/options.js"
import { channelMention, ChannelType, PermissionFlagsBits, SlashCommandBuilder, TextChannel, userMention } from "discord.js"
import { ICommand } from "interfaces"
import { removeIndents } from "utils/functions/funcs.js"
import logToChannel from "utils/functions/logtochannel.js"
export default {
@@ -55,11 +54,11 @@ export default {
icon_url: interaction.user.avatarURL() || undefined
},
title: "Slowmode Update",
description: removeIndents(`
description: `
**Channel:** ${channelMention(channel.id)}
**Slowmode:** ${seconds} seconds
**Mod:** ${userMention(interaction.user.id)}
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: interaction.user.avatarURL() || ""

View File

@@ -3,7 +3,7 @@ import { ChatInputCommandInteraction, GuildMember } from "discord.js"
import { IGuildData } from "interfaces"
import verify from "schemas/verifyTag.js"
import env from "utils/Env.js"
import color from "utils/functions/colors.js"
import { color } from "utils/functions/colors.js"
import roleManage from "utils/functions/rolesmanage.js"
import { getGuild, getIGN } from "utils/Hypixel.js"

View File

@@ -3,7 +3,6 @@ import { GuildMember, PermissionFlagsBits, SlashCommandBuilder, userMention } fr
import { ICommand } from "interfaces"
import ms from "ms"
import prettyMs from "pretty-ms"
import { removeIndents } from "utils/functions/funcs.js"
import logToChannel from "utils/functions/logtochannel.js"
export default {
@@ -144,12 +143,12 @@ export default {
icon_url: mod.user.avatarURL() || undefined
},
title: title,
description: removeIndents(`
description: `
**User:** ${userMention(target.id)}
${timeouttime === null ? "**Time:** `None`" : "**Time:** `" + prettyTime + "`"}
**Reason:** \`${reason}\`
**Mod:** ${userMention(mod.id)}
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: mod.user.avatarURL() || ""

View File

@@ -1,7 +1,6 @@
import { devMessage, embedColor } from "config/options.js"
import { PermissionFlagsBits, SlashCommandBuilder, User, userMention } from "discord.js"
import { ICommand } from "interfaces"
import { removeIndents } from "utils/functions/funcs.js"
import logToChannel from "utils/functions/logtochannel.js"
export default {
@@ -69,11 +68,11 @@ export default {
icon_url: mod.avatarURL() || undefined
},
title: "Member Unbanned",
description: removeIndents(`
description: `
**User:** ${userMention(user!.id)}
**Mod:** ${userMention(mod.id)}
**Reason:** ${reason}
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: mod.avatarURL() || ""

View File

@@ -3,7 +3,6 @@ import { waitingListRole } from "config/roles.js"
import { GuildMember, SlashCommandBuilder } from "discord.js"
import { ICommand } from "interfaces"
import verify from "schemas/verifyTag.js"
import { removeIndents } from "utils/functions/funcs.js"
import roleManage from "utils/functions/rolesmanage.js"
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel.js"
@@ -68,11 +67,11 @@ export default {
await interaction.editReply({
embeds: [{
description: removeIndents(`
description: `
Updated your roles to \`Default Member\`
IGN: \`${ign}\`
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: head!
@@ -143,11 +142,11 @@ export default {
await interaction.editReply({
embeds: [{
description: removeIndents(`
description: `
Updated your roles to \`${replyRank}\`
IGN: \`${ign}\`
`),
`.removeIndents(),
color: embedColor,
thumbnail: {
url: head!

View File

@@ -4,7 +4,7 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, TextChannel } from "disco
import { IButton } from "interfaces"
import guildapp from "schemas/guildAppTag.js"
import waitingList from "schemas/waitinglistTag.js"
import color from "utils/functions/colors.js"
import { color } from "utils/functions/colors.js"
import { getGuild, getIGN } from "utils/Hypixel.js"
export default {

7
src/enviroment.d.ts vendored
View File

@@ -7,4 +7,11 @@ declare global {
}
}
declare global {
interface String {
removeIndents(): string
capitalizeFirstLetter(): string
}
}
export {}

View File

@@ -1,7 +1,7 @@
import { devMessage, embedColor, guildLogChannel, hypixelGuildID } from "config/options.js"
import { TextChannel } from "discord.js"
import { ICron, IGuildData } from "interfaces"
import color from "utils/functions/colors.js"
import { color } from "utils/functions/colors.js"
import { getGuild, getIGN } from "utils/Hypixel.js"
import { client } from "utils/Illegitimate.js"

View File

@@ -1,6 +1,6 @@
import { ButtonInteraction, ChatInputCommandInteraction } from "discord.js"
import { IEvent } from "interfaces"
import color from "utils/functions/colors.js"
import { color } from "utils/functions/colors.js"
export default {
name: "logBtnsCmds",

View File

@@ -1,6 +1,6 @@
import { IEvent } from "interfaces"
import { ExtendedClient as Client } from "utils/Client.js"
import color from "utils/functions/colors.js"
import { color } from "utils/functions/colors.js"
export default {
name: "conolelog",

View File

@@ -3,7 +3,7 @@ import fs from "fs"
import { ICommand } from "interfaces"
import { ExtendedClient } from "./Client.js"
import env from "./Env.js"
import color from "./functions/colors.js"
import { color } from "./functions/colors.js"
type FileType = "js" | "ts"
export default async function autoDeployCommands(fileType: FileType, client: ExtendedClient) {

View File

@@ -2,7 +2,7 @@ import { Client, Collection, GatewayIntentBits, Partials } from "discord.js"
import { IAutocomplete, IButton, ICommand, IContextMenu, IModal } from "interfaces"
import autoDeployCommands from "./Autodeploy.js"
import env from "./Env.js"
import color from "./functions/colors.js"
import { color } from "./functions/colors.js"
export class ExtendedClient extends Client {
commands: Collection<string, ICommand> = new Collection()

View File

@@ -4,7 +4,7 @@ import fs from "fs"
import { IAutocomplete } from "interfaces"
import path from "path"
import { ExtendedClient as Client } from "utils/Client.js"
import color from "utils/functions/colors.js"
import { color } from "utils/functions/colors.js"
import logToChannel from "utils/functions/logtochannel.js"
type FileType = "js" | "ts"
const __dirname = import.meta.dirname

View File

@@ -4,7 +4,7 @@ import fs from "fs"
import { IButton } from "interfaces"
import path from "path"
import { ExtendedClient as Client } from "utils/Client.js"
import color from "utils/functions/colors.js"
import { color } from "utils/functions/colors.js"
import logToChannel from "utils/functions/logtochannel.js"
type FileType = "js" | "ts"
const __dirname = import.meta.dirname

View File

@@ -4,7 +4,7 @@ import fs from "fs"
import { ICommand } from "interfaces"
import path from "path"
import { ExtendedClient as Client } from "utils/Client.js"
import color from "utils/functions/colors.js"
import { color } from "utils/functions/colors.js"
import logToChannel from "utils/functions/logtochannel.js"
type FileType = "js" | "ts"
const __dirname = import.meta.dirname

View File

@@ -4,7 +4,7 @@ import fs from "fs"
import { IContextMenu } from "interfaces"
import path from "path"
import { ExtendedClient as Client } from "utils/Client.js"
import color from "utils/functions/colors.js"
import { color } from "utils/functions/colors.js"
import logToChannel from "utils/functions/logtochannel.js"
type FileType = "js" | "ts"
const __dirname = import.meta.dirname

View File

@@ -4,7 +4,7 @@ import fs from "fs"
import { IModal } from "interfaces"
import path from "path"
import { ExtendedClient as Client } from "utils/Client.js"
import color from "utils/functions/colors.js"
import { color } from "utils/functions/colors.js"
import logToChannel from "utils/functions/logtochannel.js"
type FileType = "js" | "ts"
const __dirname = import.meta.dirname

View File

@@ -1,7 +1,7 @@
import { Redis } from "ioredis"
import { ExtendedClient as Client } from "utils/Client.js"
import env from "utils/Env.js"
import color from "utils/functions/colors.js"
import { color } from "utils/functions/colors.js"
// import { connect } from "mongoose"
import { Player } from "discord-player"
import { YoutubeiExtractor } from "discord-player-youtubei"
@@ -38,6 +38,7 @@ class Illegitimate {
await player.extractors.register(YoutubeiExtractor, {})
await client.start()
await this.databases()
this.loadMethods()
}
private async databases() {
@@ -71,6 +72,16 @@ class Illegitimate {
}
}
}
private loadMethods() {
String.prototype.removeIndents = function(this: string) {
return this.replace(/^ */gm, "")
}
String.prototype.capitalizeFirstLetter = function(this: string) {
return this[0].toUpperCase() + this.slice(1).toLowerCase()
}
}
}
export { client, Illegitimate, redis, sequelize }

View File

@@ -7,10 +7,14 @@ const colors = {
pink: "#f5c2e7"
}
export default function color(text: string, type: keyof typeof colors) {
export function color(text: string, type: keyof typeof colors) {
return chalk.hex(colors[type])(text)
}
export function colorCustom(text: string, color: string) {
return chalk.hex(color)(text)
}
/* const colors = {
reset: "\x1b[0m",
bright: "\x1b[1m",

View File

@@ -1,7 +0,0 @@
export function capitalizeFirstLetter(str: string): string {
return str[0].toUpperCase() + str.slice(1).toLowerCase()
}
export function removeIndents(str: string): string {
return str.replace(/^ */gm, "")
}