ts settings update and fix

This commit is contained in:
404invalid-user 2025-01-18 14:46:30 +00:00
parent 666638c956
commit 0a8017af72
21 changed files with 45 additions and 64 deletions

View file

@ -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)

View file

@ -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";

View file

@ -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: {

View file

@ -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)

View file

@ -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";

View file

@ -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";

View file

@ -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")

View file

@ -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) {

View file

@ -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";

View file

@ -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<UserAttributes | null> {

View file

@ -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);

View file

@ -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);

View file

@ -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";

View file

@ -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";

View file

@ -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) {

View file

@ -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;

View file

@ -1,5 +1,5 @@
import { Client, ActivityType } from 'discord.js';
//@ts-expect-error
import YALAS from 'mcstatusbot-logger';
export default function Ready(client: Client) {

View file

@ -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")

View file

@ -10,6 +10,4 @@ async function main(): Promise<void> {
await login();
if (process.env.RELOADCMDS !== 'false') await updateSlashCommands();
await start();
}
main();
}

View file

@ -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) {

View file

@ -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"]
}
}