Process of format fixing
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
||||
REST,
|
||||
RESTGetAPIApplicationGuildCommandResult,
|
||||
RESTPutAPIApplicationGuildCommandsJSONBody,
|
||||
Routes,
|
||||
Routes
|
||||
} from "discord.js"
|
||||
import fs from "fs"
|
||||
type FileType = "js" | "ts"
|
||||
@@ -47,27 +47,27 @@ export default async function autoDeployCommands(fileType: FileType) {
|
||||
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!)
|
||||
|
||||
const currentCommands = (await rest.get(
|
||||
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
|
||||
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!)
|
||||
)) as RESTGetAPIApplicationGuildCommandResult[]
|
||||
|
||||
const currentCommandsInfo = currentCommands.map(command => {
|
||||
return {
|
||||
name: command.name,
|
||||
description: command.description,
|
||||
description: command.description
|
||||
}
|
||||
})
|
||||
const newCommandsInfo = commands.map(command => {
|
||||
return {
|
||||
name: command.name,
|
||||
description: command.description,
|
||||
description: command.description
|
||||
}
|
||||
})
|
||||
|
||||
const sortedCurrentCommandsInfo = currentCommandsInfo.sort((a, b) =>
|
||||
a.name.localeCompare(b.name),
|
||||
a.name.localeCompare(b.name)
|
||||
)
|
||||
const sortedNewCommandsInfo = newCommandsInfo.sort((a, b) =>
|
||||
a.name.localeCompare(b.name),
|
||||
a.name.localeCompare(b.name)
|
||||
)
|
||||
|
||||
const newCmds = sortedNewCommandsInfo
|
||||
@@ -86,7 +86,7 @@ export default async function autoDeployCommands(fileType: FileType) {
|
||||
JSON.stringify(sortedCurrentCommandsInfo)
|
||||
) {
|
||||
console.log(
|
||||
color("Commands are the same, skipping deploy.", "lavender"),
|
||||
color("Commands are the same, skipping deploy.", "lavender")
|
||||
)
|
||||
console.log(color(newCmds, "lavender"))
|
||||
return
|
||||
@@ -96,18 +96,18 @@ export default async function autoDeployCommands(fileType: FileType) {
|
||||
console.log(color("Commands are different, starting deploy.", "red"))
|
||||
console.log(color(currentCmds, "red"))
|
||||
console.log(
|
||||
`Started refreshing ${commands.length} application (/) commands.`,
|
||||
`Started refreshing ${commands.length} application (/) commands.`
|
||||
)
|
||||
|
||||
const data = (await rest.put(
|
||||
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
|
||||
{ body: commands },
|
||||
{ body: commands }
|
||||
)) as RESTPutAPIApplicationGuildCommandsJSONBody[]
|
||||
|
||||
console.log(color("New commands deployed.", "lavender"))
|
||||
console.log(color(newCmds, "lavender"))
|
||||
console.log(
|
||||
`Successfully reloaded ${data.length} application (/) commands.`,
|
||||
`Successfully reloaded ${data.length} application (/) commands.`
|
||||
)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
||||
@@ -20,14 +20,14 @@ export class ExtendedClient extends Client {
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.MessageContent,
|
||||
GatewayIntentBits.DirectMessages,
|
||||
GatewayIntentBits.GuildVoiceStates,
|
||||
GatewayIntentBits.GuildVoiceStates
|
||||
],
|
||||
partials: [
|
||||
Partials.GuildMember,
|
||||
Partials.User,
|
||||
Partials.Message,
|
||||
Partials.Channel,
|
||||
],
|
||||
Partials.Channel
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export class ExtendedClient extends Client {
|
||||
let token: string
|
||||
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT) {
|
||||
console.log(
|
||||
color("Running in development mode. [ts-node]", "lavender"),
|
||||
color("Running in development mode. [ts-node]", "lavender")
|
||||
)
|
||||
loadAllEvents(this, "ts")
|
||||
token = env.dev.devtoken!
|
||||
|
||||
@@ -7,14 +7,14 @@ const env: Env = {
|
||||
mongoURI: process.env.MONGOURI,
|
||||
dev: process.env.DEV,
|
||||
hypixelapikey: process.env.HYPIXELAPIKEY,
|
||||
redisURI: process.env.REDISURI,
|
||||
redisURI: process.env.REDISURI
|
||||
},
|
||||
dev: {
|
||||
devtoken: process.env.DEVTOKEN,
|
||||
clientid: process.env.CLIENTID,
|
||||
devid: process.env.DEVID,
|
||||
guildid: process.env.GUILDID,
|
||||
},
|
||||
guildid: process.env.GUILDID
|
||||
}
|
||||
}
|
||||
|
||||
export default env
|
||||
|
||||
@@ -15,7 +15,7 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
|
||||
"..",
|
||||
"..",
|
||||
"components",
|
||||
"autocomplete",
|
||||
"autocomplete"
|
||||
)
|
||||
const autocompleteFiles = fs
|
||||
.readdirSync(autocompletePath)
|
||||
@@ -31,8 +31,8 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
|
||||
console.log(
|
||||
colorLog(
|
||||
`[WARNING] The autocomplete at ${filePath} is missing a required "name", "execute" or "type" property.`,
|
||||
"red",
|
||||
),
|
||||
"red"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
|
||||
|
||||
if (!autocomplete) {
|
||||
console.error(
|
||||
`No autocomplete matching ${interaction.commandName} was found.`,
|
||||
`No autocomplete matching ${interaction.commandName} was found.`
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -65,10 +65,10 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
|
||||
text:
|
||||
interaction.user.username +
|
||||
" | " +
|
||||
interaction.commandName,
|
||||
},
|
||||
},
|
||||
],
|
||||
interaction.commandName
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
console.error(error)
|
||||
|
||||
@@ -23,8 +23,8 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
|
||||
console.log(
|
||||
colorLog(
|
||||
`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`,
|
||||
"red",
|
||||
),
|
||||
"red"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
|
||||
|
||||
if (!button) {
|
||||
console.error(
|
||||
`No event matching ${interaction.customId} was found.`,
|
||||
`No event matching ${interaction.customId} was found.`
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -57,10 +57,10 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
|
||||
text:
|
||||
interaction.user.username +
|
||||
" | " +
|
||||
interaction.customId,
|
||||
},
|
||||
},
|
||||
],
|
||||
interaction.customId
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -71,10 +71,10 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
|
||||
{
|
||||
description:
|
||||
"There was an error while executing this button!",
|
||||
color: embedColor,
|
||||
},
|
||||
color: embedColor
|
||||
}
|
||||
],
|
||||
ephemeral: true,
|
||||
ephemeral: true
|
||||
})
|
||||
} else {
|
||||
await interaction.editReply({
|
||||
@@ -82,9 +82,9 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
|
||||
{
|
||||
description:
|
||||
"There was an error while executing this button! 2",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
console.log(
|
||||
colorLog(
|
||||
`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`,
|
||||
"red",
|
||||
),
|
||||
"red"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
|
||||
if (!command) {
|
||||
console.error(
|
||||
`No command matching ${interaction.commandName} was found.`,
|
||||
`No command matching ${interaction.commandName} was found.`
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -58,10 +58,10 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
text:
|
||||
interaction.user.username +
|
||||
" | " +
|
||||
interaction.commandName,
|
||||
},
|
||||
},
|
||||
],
|
||||
interaction.commandName
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -72,10 +72,10 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
{
|
||||
description:
|
||||
"There was an error while executing this command!",
|
||||
color: embedColor,
|
||||
},
|
||||
color: embedColor
|
||||
}
|
||||
],
|
||||
ephemeral: true,
|
||||
ephemeral: true
|
||||
})
|
||||
} else {
|
||||
await interaction.editReply({
|
||||
@@ -83,9 +83,9 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
{
|
||||
description:
|
||||
"There was an error while executing this command!",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
__dirname,
|
||||
"..",
|
||||
"..",
|
||||
"commands-contextmenu",
|
||||
"commands-contextmenu"
|
||||
)
|
||||
const contextMenuFiles = fs
|
||||
.readdirSync(contextMenuPath)
|
||||
@@ -30,8 +30,8 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
console.log(
|
||||
colorLog(
|
||||
`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`,
|
||||
"red",
|
||||
),
|
||||
"red"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
|
||||
if (!command) {
|
||||
console.error(
|
||||
`No command matching ${interaction.commandName} was found.`,
|
||||
`No command matching ${interaction.commandName} was found.`
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -65,10 +65,10 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
text:
|
||||
interaction.user.username +
|
||||
" | " +
|
||||
interaction.commandName,
|
||||
},
|
||||
},
|
||||
],
|
||||
interaction.commandName
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,10 +79,10 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
{
|
||||
description:
|
||||
"There was an error while executing this contextmenu command!",
|
||||
color: embedColor,
|
||||
},
|
||||
color: embedColor
|
||||
}
|
||||
],
|
||||
ephemeral: true,
|
||||
ephemeral: true
|
||||
})
|
||||
} else {
|
||||
await interaction.editReply({
|
||||
@@ -90,9 +90,9 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
{
|
||||
description:
|
||||
"There was an error while executing this contextmenu command!",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export default function loadCronEvents() {
|
||||
cron.execute,
|
||||
cron.onComplete,
|
||||
cron.start,
|
||||
cron.timeZone,
|
||||
cron.timeZone
|
||||
).start()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ export default function loadModalEvents(client: Client, ft: FileType) {
|
||||
console.log(
|
||||
colorLog(
|
||||
`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`,
|
||||
"red",
|
||||
),
|
||||
"red"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export default function loadModalEvents(client: Client, ft: FileType) {
|
||||
|
||||
if (!modal) {
|
||||
console.error(
|
||||
`No modal matching ${interaction.customId} was found.`,
|
||||
`No modal matching ${interaction.customId} was found.`
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -59,10 +59,10 @@ export default function loadModalEvents(client: Client, ft: FileType) {
|
||||
text:
|
||||
interaction.user.username +
|
||||
" | " +
|
||||
interaction.customId,
|
||||
},
|
||||
},
|
||||
],
|
||||
interaction.customId
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -73,9 +73,9 @@ export default function loadModalEvents(client: Client, ft: FileType) {
|
||||
{
|
||||
description:
|
||||
"There was an error while executing this modal!",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
})
|
||||
} else {
|
||||
await interaction.editReply({
|
||||
@@ -83,9 +83,9 @@ export default function loadModalEvents(client: Client, ft: FileType) {
|
||||
{
|
||||
description:
|
||||
"There was an error while executing this modal!",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ async function getPlayer(uuid: string): Promise<PlayerData | null> {
|
||||
const playerReq: Player = await fetch(hypixel, {
|
||||
params: {
|
||||
key: apikey,
|
||||
uuid: uuid,
|
||||
},
|
||||
uuid: uuid
|
||||
}
|
||||
})
|
||||
|
||||
if (!playerReq.data.player) {
|
||||
@@ -61,15 +61,15 @@ async function getPlayer(uuid: string): Promise<PlayerData | null> {
|
||||
|
||||
async function getGuild(
|
||||
query: string,
|
||||
type?: GuildQuerqType,
|
||||
type?: GuildQuerqType
|
||||
): Promise<GuildData | null> {
|
||||
const reqType = type ? type : "player"
|
||||
|
||||
const guildReq: Guild = await fetch(guild, {
|
||||
params: {
|
||||
key: apikey,
|
||||
[reqType]: query,
|
||||
},
|
||||
[reqType]: query
|
||||
}
|
||||
})
|
||||
|
||||
if (!guildReq.data.guild) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
function guildLevel(exp: number): number {
|
||||
const EXP_NEEDED = [
|
||||
100000, 150000, 250000, 500000, 750000, 1000000, 1250000, 1500000,
|
||||
2000000, 2500000, 2500000, 2500000, 2500000, 2500000, 3000000,
|
||||
2000000, 2500000, 2500000, 2500000, 2500000, 2500000, 3000000
|
||||
]
|
||||
|
||||
let level = 0
|
||||
|
||||
@@ -12,7 +12,7 @@ function getLevel(exp: number): number {
|
||||
if (exp <= 1) return 1
|
||||
|
||||
return Math.floor(
|
||||
1 + REVERSE_PQ_PREFIX + Math.sqrt(REVERSE_CONST + GROWTHDIV2 * exp),
|
||||
1 + REVERSE_PQ_PREFIX + Math.sqrt(REVERSE_CONST + GROWTHDIV2 * exp)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const colors = {
|
||||
red: "#f38ba8",
|
||||
lavender: "#b4befe",
|
||||
green: "#a6e3a1",
|
||||
pink: "#f5c2e7",
|
||||
pink: "#f5c2e7"
|
||||
}
|
||||
|
||||
export default function color(text: string, type: keyof typeof colors) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
guildLogChannel,
|
||||
errorLogChannel,
|
||||
moderationLogChannel,
|
||||
devLogChannel,
|
||||
devLogChannel
|
||||
} from "config/options.json"
|
||||
import { Guild, MessageCreateOptions, TextChannel } from "discord.js"
|
||||
import Illegitimate from "utils/Illegitimate"
|
||||
@@ -16,14 +16,14 @@ const channels = {
|
||||
guild: guildLogChannel,
|
||||
error: errorLogChannel,
|
||||
mod: moderationLogChannel,
|
||||
dev: devLogChannel,
|
||||
dev: devLogChannel
|
||||
}
|
||||
|
||||
type Channel = keyof typeof channels
|
||||
|
||||
export default async function logToChannel(
|
||||
channel: Channel,
|
||||
message: MessageCreateOptions,
|
||||
message: MessageCreateOptions
|
||||
): Promise<void | null> {
|
||||
const guild = Illegitimate.client.guilds.cache.get(guildid) as Guild
|
||||
let logChannel: TextChannel
|
||||
@@ -36,7 +36,7 @@ export default async function logToChannel(
|
||||
|
||||
if (!logChannel) {
|
||||
console.log(
|
||||
`[ERROR] Could not find channel used for ${channel} logging.`,
|
||||
`[ERROR] Could not find channel used for ${channel} logging.`
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
member,
|
||||
guildStaff,
|
||||
guildRole,
|
||||
defaultMember,
|
||||
defaultMember
|
||||
} from "config/roles.json"
|
||||
const roles = [
|
||||
gm,
|
||||
@@ -17,7 +17,7 @@ const roles = [
|
||||
elite,
|
||||
member,
|
||||
guildStaff,
|
||||
guildRole,
|
||||
guildRole
|
||||
]
|
||||
|
||||
type RoleType =
|
||||
@@ -36,7 +36,7 @@ export default function roleManage(role: RoleType): {
|
||||
} {
|
||||
if (role === "gm") {
|
||||
const rolesToRemove = roles.filter(
|
||||
role => role !== gm && role !== guildStaff && role !== guildRole,
|
||||
role => role !== gm && role !== guildStaff && role !== guildRole
|
||||
)
|
||||
const rolesToAdd = [gm, guildStaff, guildRole]
|
||||
return { rolesToRemove, rolesToAdd }
|
||||
@@ -45,7 +45,7 @@ export default function roleManage(role: RoleType): {
|
||||
if (role === "manager") {
|
||||
const rolesToRemove = roles.filter(
|
||||
role =>
|
||||
role !== manager && role !== guildStaff && role !== guildRole,
|
||||
role !== manager && role !== guildStaff && role !== guildRole
|
||||
)
|
||||
const rolesToAdd = [manager, guildStaff, guildRole]
|
||||
return { rolesToRemove, rolesToAdd }
|
||||
@@ -54,7 +54,7 @@ export default function roleManage(role: RoleType): {
|
||||
if (role === "moderator") {
|
||||
const rolesToRemove = roles.filter(
|
||||
role =>
|
||||
role !== moderator && role !== guildStaff && role !== guildRole,
|
||||
role !== moderator && role !== guildStaff && role !== guildRole
|
||||
)
|
||||
const rolesToAdd = [moderator, guildStaff, guildRole]
|
||||
return { rolesToRemove, rolesToAdd }
|
||||
@@ -62,7 +62,7 @@ export default function roleManage(role: RoleType): {
|
||||
|
||||
if (role === "beast") {
|
||||
const rolesToRemove = roles.filter(
|
||||
role => role !== beast && role !== guildRole,
|
||||
role => role !== beast && role !== guildRole
|
||||
)
|
||||
const rolesToAdd = [beast, guildRole]
|
||||
return { rolesToRemove, rolesToAdd }
|
||||
@@ -70,7 +70,7 @@ export default function roleManage(role: RoleType): {
|
||||
|
||||
if (role === "elite") {
|
||||
const rolesToRemove = roles.filter(
|
||||
role => role !== elite && role !== guildRole,
|
||||
role => role !== elite && role !== guildRole
|
||||
)
|
||||
const rolesToAdd = [elite, guildRole]
|
||||
return { rolesToRemove, rolesToAdd }
|
||||
@@ -78,7 +78,7 @@ export default function roleManage(role: RoleType): {
|
||||
|
||||
if (role === "member") {
|
||||
const rolesToRemove = roles.filter(
|
||||
role => role !== member && role !== guildRole,
|
||||
role => role !== member && role !== guildRole
|
||||
)
|
||||
const rolesToAdd = [member, guildRole]
|
||||
return { rolesToRemove, rolesToAdd }
|
||||
|
||||
Reference in New Issue
Block a user