diff --git a/src/bot/commands/messagemacro.ts b/src/bot/commands/messagemacro.ts index 6c0b28a..44ca61b 100644 --- a/src/bot/commands/messagemacro.ts +++ b/src/bot/commands/messagemacro.ts @@ -1,6 +1,6 @@ import { Client, ChatInputCommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js"; -//@ts-expect-error + import YALAS from 'mcstatusbot-logger'; import * as AddMessageMacro from './messagemacro/add'; @@ -9,9 +9,7 @@ import { GuildInstance } from "../../database/schemas/Guild"; import { UserInstance } from "../../database/schemas/User"; const data = { - serverOnly: false, - guildId: null, - allowSuspendedUserAccess: true, + allowSuspendedUserAccess: false, command: new SlashCommandBuilder() .setName('messagemacro') .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) diff --git a/src/bot/commands/messagemacro/add.ts b/src/bot/commands/messagemacro/add.ts index d6ac585..991a330 100644 --- a/src/bot/commands/messagemacro/add.ts +++ b/src/bot/commands/messagemacro/add.ts @@ -1,7 +1,7 @@ import { Client, ChatInputCommandInteraction, Role, GuildChannelResolvable, PermissionsBitField, ChannelType } from "discord.js"; import { schemas } from "../../../database"; -//@ts-expect-error + import YALAS from 'mcstatusbot-logger'; import { GuildInstance } from "../../../database/schemas/Guild"; diff --git a/src/bot/commands/messagemacro/list.ts b/src/bot/commands/messagemacro/list.ts index 83e91fc..943463f 100644 --- a/src/bot/commands/messagemacro/list.ts +++ b/src/bot/commands/messagemacro/list.ts @@ -8,7 +8,7 @@ import { } from "discord.js"; import { schemas } from "../../../database"; -//@ts-expect-error + import YALAS from "mcstatusbot-logger"; import { GuildInstance } from "../../../database/schemas/Guild"; @@ -26,7 +26,7 @@ export async function chatInputCommand(client: Client, interaction: ChatInputCom await interaction.deferReply(); - let msgMacros = []; + let msgMacros:MessageMacroAttributes[]; try { const msgMacroDocs = await schemas["MessageMacro"].findAll({ where: { diff --git a/src/bot/commands/reactionrole.ts b/src/bot/commands/reactionrole.ts index 5305394..7320e3f 100644 --- a/src/bot/commands/reactionrole.ts +++ b/src/bot/commands/reactionrole.ts @@ -1,6 +1,6 @@ import { Client, ChatInputCommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js"; -//@ts-expect-error + import YALAS from 'mcstatusbot-logger'; import * as AddReactionRole from './reactionrole/add'; @@ -9,9 +9,7 @@ import { GuildInstance } from "../../database/schemas/Guild"; import { UserInstance } from "../../database/schemas/User"; const data = { - serverOnly: false, - guildId: null, - allowSuspendedUserAccess: true, + allowSuspendedUserAccess: false, command: new SlashCommandBuilder() .setName('reactionrole') .setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles) diff --git a/src/bot/commands/reactionrole/add.ts b/src/bot/commands/reactionrole/add.ts index f427314..accd6c1 100644 --- a/src/bot/commands/reactionrole/add.ts +++ b/src/bot/commands/reactionrole/add.ts @@ -2,7 +2,7 @@ import { Client, ChatInputCommandInteraction, Role, GuildChannelResolvable, Perm import parseEmoji from "../../functions/parseEmoji"; import { schemas } from "../../../database"; -//@ts-expect-error + import YALAS from 'mcstatusbot-logger'; import SendReactionRoleEmbed from "../../functions/SendReactionRoleEmbed"; diff --git a/src/bot/commands/reactionrole/remove.ts b/src/bot/commands/reactionrole/remove.ts index 8222da0..550f018 100644 --- a/src/bot/commands/reactionrole/remove.ts +++ b/src/bot/commands/reactionrole/remove.ts @@ -5,7 +5,7 @@ import { Client, ChatInputCommandInteraction, Role, GuildChannelResolvable, Text import parseEmoji from "../../functions/parseEmoji"; import { schemas } from "../../../database"; -//@ts-expect-error + import YALAS from 'mcstatusbot-logger'; import SendReactionRoleEmbed from "../../functions/SendReactionRoleEmbed"; diff --git a/src/bot/commands/setprefix.ts b/src/bot/commands/setprefix.ts index 019cc99..ccd5dc6 100644 --- a/src/bot/commands/setprefix.ts +++ b/src/bot/commands/setprefix.ts @@ -1,16 +1,14 @@ import { Client, ChatInputCommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js"; import { schemas } from "../../database/index"; -//@ts-expect-error + import YALAS from 'mcstatusbot-logger'; import { GuildInstance } from "../../database/schemas/Guild"; import { UserInstance } from "../../database/schemas/User"; const data = { - serverOnly: false, - guildId: null, - allowSuspendedUserAccess: true, + allowSuspendedUserAccess: false, command: new SlashCommandBuilder() .setName('setprefix') .setDescription("sets the message prefix for your server") diff --git a/src/bot/functions/BanReactionRoleHandler.ts b/src/bot/functions/BanReactionRoleHandler.ts index 267d56c..5126e22 100644 --- a/src/bot/functions/BanReactionRoleHandler.ts +++ b/src/bot/functions/BanReactionRoleHandler.ts @@ -1,6 +1,6 @@ import { Client, MessageReaction, PartialMessageReaction, User, PartialUser, Guild, Role, GuildMember } from "discord.js"; import { schemas } from "../../database"; -//@ts-expect-error + import * as YALAS from 'mcstatusbot-logger'; export default async function ReactionRoleAddHandler(reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser) { diff --git a/src/bot/functions/LookupGuild.ts b/src/bot/functions/LookupGuild.ts index e8021cb..dcdf1ad 100644 --- a/src/bot/functions/LookupGuild.ts +++ b/src/bot/functions/LookupGuild.ts @@ -1,5 +1,5 @@ import { schemas } from "../../database"; -//@ts-expect-error + import * as YALAS from 'mcstatusbot-logger'; import { GuildAttributes } from "../../database/schemas/Guild"; import { Guild } from "discord.js"; diff --git a/src/bot/functions/LookupUser.ts b/src/bot/functions/LookupUser.ts index dcfa9fb..d8ca54a 100644 --- a/src/bot/functions/LookupUser.ts +++ b/src/bot/functions/LookupUser.ts @@ -1,6 +1,6 @@ import { User } from "discord.js"; import { schemas } from "../../database"; -//@ts-expect-error + import * as YALAS from 'mcstatusbot-logger'; import { UserAttributes } from '../../database/schemas/User'; export default async function LookupUser(user: User | null): Promise { diff --git a/src/bot/functions/ReactionRoleAddHandler.ts b/src/bot/functions/ReactionRoleAddHandler.ts index 2ae3056..a780ec2 100644 --- a/src/bot/functions/ReactionRoleAddHandler.ts +++ b/src/bot/functions/ReactionRoleAddHandler.ts @@ -1,6 +1,6 @@ import { Client, MessageReaction, PartialMessageReaction, User, PartialUser, Guild, Role, GuildMember, TextChannel } from "discord.js"; import { schemas } from "../../database"; -//@ts-expect-error + import * as YALAS from 'mcstatusbot-logger'; export default async function ReactionRoleAddHandler(reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser) { if (reaction.message.guild === undefined) return; @@ -53,8 +53,8 @@ export default async function ReactionRoleAddHandler(reaction: MessageReaction | //TODO: implement ignore reaction reomve when using this //reaction.users.remove(user.id); - //@ts-expect-error - const errUsrMsg = await channel.send(`Sorry <@!${user.id}>, that did not work please try again later or ask a moderator.`); + + const errUsrMsg = await (channel as TextChannel).send(`Sorry <@!${user.id}>, that did not work please try again later or ask a moderator.`); setTimeout(() => { errUsrMsg.delete().catch((e: any) => null); diff --git a/src/bot/functions/ReactionRoleRemoveHandler.ts b/src/bot/functions/ReactionRoleRemoveHandler.ts index 9633040..a6bae82 100644 --- a/src/bot/functions/ReactionRoleRemoveHandler.ts +++ b/src/bot/functions/ReactionRoleRemoveHandler.ts @@ -1,6 +1,6 @@ import { Client, MessageReaction, PartialMessageReaction, User, PartialUser, Guild, Role, GuildMember, TextChannel, flatten } from "discord.js"; import { schemas } from "../../database"; -//@ts-expect-error + import * as YALAS from 'mcstatusbot-logger'; export default async function ReactionRoleRemoveHandler(reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser) { if (reaction.message.guild === undefined) return; @@ -52,8 +52,8 @@ export default async function ReactionRoleRemoveHandler(reaction: MessageReactio if (process.env.DEBUG === 'true') YALAS.info(`Added role "${role.name}" to user "${user.tag}".`); } catch (error) { reaction.users.remove(user.id); - //@ts-expect-error - const errUsrMsg = await channel.send(`Sorry <@!${user.id}>, that did not work please try again later or ask a moderator.`); + + const errUsrMsg = await (channel as TextChannel).send(`Sorry <@!${user.id}>, that did not work please try again later or ask a moderator.`); setTimeout(() => { errUsrMsg.delete().catch((e: any) => null); diff --git a/src/bot/handlers/InteractionCreate.ts b/src/bot/handlers/InteractionCreate.ts index 582cc06..a5318d4 100644 --- a/src/bot/handlers/InteractionCreate.ts +++ b/src/bot/handlers/InteractionCreate.ts @@ -1,6 +1,6 @@ import { Client, Interaction, ChatInputCommandInteraction, User } from "discord.js"; import { schemas } from '../../database/index'; -//@ts-expect-error + import YALAS from 'mcstatusbot-logger'; import LookupUser from "../functions/LookupUser"; import LookupGuild from "../functions/LookupGuild"; diff --git a/src/bot/handlers/MessageCreate.ts b/src/bot/handlers/MessageCreate.ts index 0322266..2127b06 100644 --- a/src/bot/handlers/MessageCreate.ts +++ b/src/bot/handlers/MessageCreate.ts @@ -2,7 +2,7 @@ import { Client, Guild, Message } from "discord.js"; import MessageMacro from "../messageHandler/plugins/MesageMacro"; import { schemas } from "../../database"; import LookupUser from "../functions/LookupUser"; -//@ts-expect-error + import * as YALAS from 'mcstatusbot-logger'; import { UserAttributes } from "../../database/schemas/User"; import { GuildAttributes } from "../../database/schemas/Guild"; diff --git a/src/bot/handlers/MessageReactionAdd.ts b/src/bot/handlers/MessageReactionAdd.ts index d0c5b18..036a9c0 100644 --- a/src/bot/handlers/MessageReactionAdd.ts +++ b/src/bot/handlers/MessageReactionAdd.ts @@ -1,6 +1,6 @@ import { Client, MessageReaction, PartialMessageReaction, User, PartialUser } from "discord.js"; import ReactionRoleAddHandler from "../functions/ReactionRoleAddHandler"; -//@ts-expect-error + import * as YALAS from 'mcstatusbot-logger'; export default async function MessageReactionAdd(client: Client, reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser) { diff --git a/src/bot/handlers/MessageReactionRemove.ts b/src/bot/handlers/MessageReactionRemove.ts index 1c01dbc..ecdf7b2 100644 --- a/src/bot/handlers/MessageReactionRemove.ts +++ b/src/bot/handlers/MessageReactionRemove.ts @@ -1,6 +1,6 @@ import { Client, MessageReaction, PartialMessageReaction, User, PartialUser } from "discord.js"; import ReactionRoleRemoveHandler from "../functions/ReactionRoleRemoveHandler"; -//@ts-expect-error + import * as YALAS from 'mcstatusbot-logger'; export default async function MessageReactionRemove(client: Client, reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser) { if (!reaction.message.guild) return; diff --git a/src/bot/handlers/Ready.ts b/src/bot/handlers/Ready.ts index 08a07a9..3d820fd 100644 --- a/src/bot/handlers/Ready.ts +++ b/src/bot/handlers/Ready.ts @@ -1,5 +1,5 @@ import { Client, ActivityType } from 'discord.js'; -//@ts-expect-error + import YALAS from 'mcstatusbot-logger'; export default function Ready(client: Client) { diff --git a/src/bot/messageHandler/plugins/MesageMacro.ts b/src/bot/messageHandler/plugins/MesageMacro.ts index 6134311..146328c 100644 --- a/src/bot/messageHandler/plugins/MesageMacro.ts +++ b/src/bot/messageHandler/plugins/MesageMacro.ts @@ -4,13 +4,13 @@ import { GuildAttributes, GuildInstance } from "../../../database/schemas/Guild" import { MessageCreateOptions } from "../../../../types/MessageCreate"; import { schemas } from "../../../database"; import LookupGuild from "../../functions/LookupGuild"; -//@ts-expect-error + import * as YALAS from 'mcstatusbot-logger'; export default async function MessageMacro(client: Client, msg: Message, msgCmds: string[]) { if (msg.guild === null) return; if (msg.member === null) return; - + const guild: GuildAttributes | null = await LookupGuild(msg.guild); if (guild == null) return YALAS.error("MessageCreate guild null") diff --git a/src/index.ts b/src/index.ts index 04591c2..27f2e8c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,6 +10,4 @@ async function main(): Promise { await login(); if (process.env.RELOADCMDS !== 'false') await updateSlashCommands(); await start(); -} - -main(); \ No newline at end of file +} \ No newline at end of file diff --git a/src/updateSlashCommands.ts b/src/updateSlashCommands.ts index 265f688..736bc9a 100644 --- a/src/updateSlashCommands.ts +++ b/src/updateSlashCommands.ts @@ -2,34 +2,26 @@ import * as fs from 'fs'; import { REST } from '@discordjs/rest'; import { Routes } from 'discord-api-types/v9'; -//@ts-expect-error + import YALAS from 'mcstatusbot-logger'; //makes slash command + export default async function updateSlashCommands() { if (!process.env.CLIENT_ID) throw new Error("a CLIENT_ID must be included in the env "); if (!process.env.BOT_TOKEN) throw new Error("a BOT_TOKEN must be included in the env "); //add slash commands - const commands = []; - const guildCommands = [] + + let commands: any[] = []; const commandFiles = fs.readdirSync(__dirname + '/bot/commands').filter((file) => file.endsWith('.js') || file.endsWith('.ts')); for (const file of commandFiles) { const command = require(`${__dirname}/bot/commands/${file}`); try { - if (command.data.serverOnly == true) { - let index = guildCommands.findIndex(o => o.guild == command.data.guildId); - if (index < 0) { - guildCommands.push({ guild: command.data.guildId, commands: [command.data.command.toJSON()] }); - } else { - guildCommands[index].commands.push(command.data.command.toJSON()); - } - } else { - commands.push(command.data.command.toJSON()); - } + commands.push(command.data.command.toJSON()); } catch (err) { YALAS.error("command " + file + " cant be added because it has no data"); } @@ -40,11 +32,6 @@ export default async function updateSlashCommands() { YALAS.info("Started refreshing application (/) commands."); await rest.put(Routes.applicationCommands(process.env.CLIENT_ID), { body: commands }); - - for (const guildCommand of guildCommands) { - await rest.put(Routes.applicationGuildCommands(process.env.CLIENT_ID, guildCommand.guild), { body: guildCommand.commands }) - } - YALAS.success("Successfully reloaded application (/) commands."); //process.exit(); } catch (error: any) { diff --git a/tsconfig.json b/tsconfig.json index 3a7c962..9c79a3e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,19 @@ { "compilerOptions": { - "target": "es6", - "lib": ["es2017"], - "module": "commonjs", - "declaration": true, + "target": "ES2022", // Use the latest syntax supported by Node.js 23 + "module": "NodeNext", // Enables ES Modules with support for .js extensions + "moduleResolution": "NodeNext", // Required for NodeNext modules + "strict": true, + "esModuleInterop": true, + "resolveJsonModule": true, "outDir": "./dist", "rootDir": "./src", - "strict": true, - "resolveJsonModule": true, - "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, "allowSyntheticDefaultImports": true, - "typeRoots": ["./node_modules/@types", "./types"] // Ensure custom types are included + "noImplicitAny": false, + "typeRoots": ["./node_modules/@types", "./types"] }, - "include": ["src/**/*.ts", "types/**/*.d.ts"], + "include": ["src/**/*.ts", "types/**/*.d.ts", "types/Client.d.ts"], "exclude": ["node_modules"] -} +} \ No newline at end of file