mirror of
https://github.com/ahmadk953/poixpixel-discord-bot.git
synced 2025-04-02 09:44:14 +00:00
Fixes and Improvements
This commit is contained in:
parent
4c5a8d2e66
commit
82f354db1c
12 changed files with 137 additions and 105 deletions
|
@ -99,7 +99,7 @@ export default [
|
||||||
"no-var": "error",
|
"no-var": "error",
|
||||||
"object-curly-spacing": ["error", "always"],
|
"object-curly-spacing": ["error", "always"],
|
||||||
"prefer-const": "error",
|
"prefer-const": "error",
|
||||||
quotes: ["warning", "single"],
|
quotes: ["warn", "single"],
|
||||||
semi: ["error", "always"],
|
semi: ["error", "always"],
|
||||||
"space-before-blocks": "error",
|
"space-before-blocks": "error",
|
||||||
|
|
||||||
|
|
|
@ -30,5 +30,5 @@
|
||||||
"tsx": "^4.19.2",
|
"tsx": "^4.19.2",
|
||||||
"typescript": "^5.7.2"
|
"typescript": "^5.7.2"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@4.5.2"
|
"packageManager": "yarn@4.5.3"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,29 @@
|
||||||
import { SlashCommandBuilder, CommandInteraction, EmbedBuilder } from "discord.js";
|
import {
|
||||||
import { getAllMembers } from "../util/db.js";
|
SlashCommandBuilder,
|
||||||
|
CommandInteraction,
|
||||||
|
EmbedBuilder,
|
||||||
|
} from 'discord.js';
|
||||||
|
import { getAllMembers } from '../util/db.js';
|
||||||
|
|
||||||
interface Command {
|
interface Command {
|
||||||
data: Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">;
|
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
||||||
execute: (interaction: CommandInteraction) => Promise<void>;
|
execute: (interaction: CommandInteraction) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const command: Command = {
|
const command: Command = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("members")
|
.setName('members')
|
||||||
.setDescription("Lists all non-bot members of the server"),
|
.setDescription('Lists all non-bot members of the server'),
|
||||||
execute: async (interaction) => {
|
execute: async (interaction) => {
|
||||||
const members = await getAllMembers();
|
const members = await getAllMembers();
|
||||||
const memberList = members.map(m => `**${m.discordUsername}** (${m.discordId})`).join("\n");
|
const memberList = members
|
||||||
|
.map((m) => `**${m.discordUsername}** (${m.discordId})`)
|
||||||
|
.join('\n');
|
||||||
const membersEmbed = new EmbedBuilder()
|
const membersEmbed = new EmbedBuilder()
|
||||||
.setTitle("Members")
|
.setTitle('Members')
|
||||||
.setDescription(memberList)
|
.setDescription(memberList)
|
||||||
.setColor(0x0099ff);
|
.setColor(0x0099ff)
|
||||||
|
.addFields({ name: 'Total Members', value: members.length.toString() });
|
||||||
await interaction.reply({ embeds: [membersEmbed] });
|
await interaction.reply({ embeds: [membersEmbed] });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { SlashCommandBuilder, CommandInteraction } from "discord.js";
|
import { SlashCommandBuilder, CommandInteraction } from 'discord.js';
|
||||||
|
|
||||||
interface Command {
|
interface Command {
|
||||||
data: Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">;
|
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
||||||
execute: (interaction: CommandInteraction) => Promise<void>;
|
execute: (interaction: CommandInteraction) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const command: Command = {
|
const command: Command = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("ping")
|
.setName('ping')
|
||||||
.setDescription("Check the latency from you to the bot"),
|
.setDescription('Check the latency from you to the bot'),
|
||||||
execute: async (interaction) => {
|
execute: async (interaction) => {
|
||||||
await interaction.reply(`Pong! Latency: ${Date.now() - interaction.createdTimestamp}ms`);
|
await interaction.reply(`Pong! Latency: ${Date.now() - interaction.createdTimestamp}ms`);
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,107 +2,107 @@ import {
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
CommandInteraction,
|
CommandInteraction,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
} from "discord.js";
|
} from 'discord.js';
|
||||||
|
|
||||||
interface Command {
|
interface Command {
|
||||||
data: Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">;
|
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
||||||
execute: (interaction: CommandInteraction) => Promise<void>;
|
execute: (interaction: CommandInteraction) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rulesEmbed = new EmbedBuilder()
|
const rulesEmbed = new EmbedBuilder()
|
||||||
.setColor(0x0099ff)
|
.setColor(0x0099ff)
|
||||||
.setTitle("Server Rules")
|
.setTitle('Server Rules')
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: "Poixixel",
|
name: 'Poixixel',
|
||||||
iconURL:
|
iconURL:
|
||||||
"https://cdn.discordapp.com/avatars/1052017329376071781/922947c726d7866d313744186c42ef49.webp",
|
'https://cdn.discordapp.com/avatars/1052017329376071781/922947c726d7866d313744186c42ef49.webp',
|
||||||
})
|
})
|
||||||
.setDescription(
|
.setDescription(
|
||||||
"These are the rules for the server. Please read and follow them carefully."
|
'These are the rules for the server. Please read and follow them carefully.'
|
||||||
)
|
)
|
||||||
.addFields(
|
.addFields(
|
||||||
{
|
{
|
||||||
name: "**Rule #1: Be respectful**",
|
name: '**Rule #1: Be respectful**',
|
||||||
value:
|
value:
|
||||||
"Treat everyone with kindness. No harassment, bullying, hate speech, or toxic behavior.",
|
'Treat everyone with kindness. No harassment, bullying, hate speech, or toxic behavior.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #2: Keep it Family-Friendly**",
|
name: '**Rule #2: Keep it Family-Friendly**',
|
||||||
value:
|
value:
|
||||||
"No explicit content, including NSFW images, language, or discussions. This is a safe space for everyone.",
|
'No explicit content, including NSFW images, language, or discussions. This is a safe space for everyone.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #3: Use Common Sense**",
|
name: '**Rule #3: Use Common Sense**',
|
||||||
value:
|
value:
|
||||||
"Think before you act or post. If something seems questionable, it’s probably best not to do it.",
|
'Think before you act or post. If something seems questionable, it’s probably best not to do it.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #4: No Spamming**",
|
name: '**Rule #4: No Spamming**',
|
||||||
value:
|
value:
|
||||||
"Avoid excessive messages, emoji use, or CAPS LOCK. Keep the chat clean and readable.",
|
'Avoid excessive messages, emoji use, or CAPS LOCK. Keep the chat clean and readable.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #5: No Raiding**",
|
name: '**Rule #5: No Raiding**',
|
||||||
value:
|
value:
|
||||||
"Do not disrupt the server or other servers with spam, unwanted content, or malicious behavior.",
|
'Do not disrupt the server or other servers with spam, unwanted content, or malicious behavior.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #6: No Self-Promotion**",
|
name: '**Rule #6: No Self-Promotion**',
|
||||||
value:
|
value:
|
||||||
"Do not advertise your own content or other servers without permission from staff.",
|
'Do not advertise your own content or other servers without permission from staff.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #7: No Impersonation**",
|
name: '**Rule #7: No Impersonation**',
|
||||||
value:
|
value:
|
||||||
"Do not pretend to be someone else, including staff or other members.",
|
'Do not pretend to be someone else, including staff or other members.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #8: No Violence**",
|
name: '**Rule #8: No Violence**',
|
||||||
value:
|
value:
|
||||||
"Do not post or share content that is offensive, harmful, or contains violent or dangerous content.",
|
'Do not post or share content that is offensive, harmful, or contains violent or dangerous content.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #9: No Doxxing or Sharing Personal Information**",
|
name: '**Rule #9: No Doxxing or Sharing Personal Information**',
|
||||||
value:
|
value:
|
||||||
"Protect your privacy and the privacy of others. Do not share personal details.",
|
'Protect your privacy and the privacy of others. Do not share personal details.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #10: No Ping Abuse**",
|
name: '**Rule #10: No Ping Abuse**',
|
||||||
value:
|
value:
|
||||||
"Do not ping staff members unless it's absolutely necessary. Use pings responsibly for all members.",
|
'Do not ping staff members unless it\'s absolutely necessary. Use pings responsibly for all members.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #11: Use Appropriate Channels**",
|
name: '**Rule #11: Use Appropriate Channels**',
|
||||||
value:
|
value:
|
||||||
"Post content in the right channels. Off-topic content may be moved or deleted.",
|
'Post content in the right channels. Off-topic content may be moved or deleted.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #12: Follow Discord's ToS and Community Guidelines**",
|
name: '**Rule #12: Follow Discord\'s ToS and Community Guidelines**',
|
||||||
value:
|
value:
|
||||||
"All members must adhere to Discord’s Terms of Service and Community Guidelines.",
|
'All members must adhere to Discord’s Terms of Service and Community Guidelines.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Rule #13: Moderator Discretion**",
|
name: '**Rule #13: Moderator Discretion**',
|
||||||
value:
|
value:
|
||||||
"Moderators reserve the right to moderate at their discretion. If you feel mistreated, please create a support ticket.",
|
'Moderators reserve the right to moderate at their discretion. If you feel mistreated, please create a support ticket.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "**Disclaimer:**",
|
name: '**Disclaimer:**',
|
||||||
value:
|
value:
|
||||||
"**These rules may be updated at any time. It is your responsibility to review them regularly. Moderators and admins have the authority to enforce these rules and take appropriate action.**",
|
'**These rules may be updated at any time. It is your responsibility to review them regularly. Moderators and admins have the authority to enforce these rules and take appropriate action.**',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: "Sent by the Poixpixel Bot",
|
text: 'Sent by the Poixpixel Bot',
|
||||||
iconURL:
|
iconURL:
|
||||||
"https://cdn.discordapp.com/avatars/1052017329376071781/922947c726d7866d313744186c42ef49.webp",
|
'https://cdn.discordapp.com/avatars/1052017329376071781/922947c726d7866d313744186c42ef49.webp',
|
||||||
});
|
});
|
||||||
|
|
||||||
const command: Command = {
|
const command: Command = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("rules")
|
.setName('rules')
|
||||||
.setDescription("Sends the server rules"),
|
.setDescription('Sends the server rules'),
|
||||||
execute: async (interaction) => {
|
execute: async (interaction) => {
|
||||||
await interaction.reply({ embeds: [rulesEmbed] });
|
await interaction.reply({ embeds: [rulesEmbed] });
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import { SlashCommandBuilder, CommandInteraction } from "discord.js";
|
import { SlashCommandBuilder, CommandInteraction } from 'discord.js';
|
||||||
|
|
||||||
interface Command {
|
interface Command {
|
||||||
data: Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">;
|
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
||||||
execute: (interaction: CommandInteraction) => Promise<void>;
|
execute: (interaction: CommandInteraction) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const command: Command = {
|
const command: Command = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("server")
|
.setName('server')
|
||||||
.setDescription("Provides information about the server."),
|
.setDescription('Provides information about the server.'),
|
||||||
execute: async (interaction) => {
|
execute: async (interaction) => {
|
||||||
await interaction.reply(
|
await interaction.reply(
|
||||||
`The server ${interaction?.guild?.name} has ${interaction?.guild?.memberCount} members and was created on ${interaction?.guild?.createdAt}. It is ${new Date().getFullYear() - interaction?.guild?.createdAt?.getFullYear()!} years old.`
|
`The server ${interaction!.guild!.name} has ${interaction!.guild!.memberCount} members and was created on ${interaction!.guild!.createdAt}. It is ${new Date().getFullYear() - interaction!.guild!.createdAt.getFullYear()!} years old.`
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,23 +2,24 @@ import {
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
CommandInteraction,
|
CommandInteraction,
|
||||||
GuildMember,
|
GuildMember,
|
||||||
} from "discord.js";
|
} from 'discord.js';
|
||||||
|
|
||||||
interface Command {
|
interface Command {
|
||||||
data: Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">;
|
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
||||||
execute: (interaction: CommandInteraction) => Promise<void>;
|
execute: (interaction: CommandInteraction) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const command: Command = {
|
const command: Command = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("user")
|
.setName('user')
|
||||||
.setDescription("Provides information about the user."),
|
.setDescription('Provides information about the user.'),
|
||||||
execute: async (interaction) => {
|
execute: async (interaction) => {
|
||||||
if (interaction.member instanceof GuildMember) {
|
if (interaction.member instanceof GuildMember) {
|
||||||
await interaction.reply(
|
await interaction.reply(
|
||||||
`This command was run by ${interaction.user.username}, who joined this server on ${interaction.member.joinedAt}.`
|
`This command was run by ${interaction.user.username}, who joined this server on ${interaction.member.joinedAt}.`
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
await interaction.reply(
|
await interaction.reply(
|
||||||
`This command was run by ${interaction.user.username}.`
|
`This command was run by ${interaction.user.username}.`
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { integer, pgTable, varchar } from "drizzle-orm/pg-core";
|
import { integer, pgTable, varchar } from 'drizzle-orm/pg-core';
|
||||||
|
|
||||||
export const memberTable = pgTable("members", {
|
export const memberTable = pgTable('members', {
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity(),
|
id: integer().primaryKey().generatedAlwaysAsIdentity(),
|
||||||
discordId: varchar("discord_id").notNull().unique(),
|
discordId: varchar('discord_id').notNull().unique(),
|
||||||
discordUsername: varchar("discord_username").notNull(),
|
discordUsername: varchar('discord_username').notNull(),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import fs from "node:fs";
|
import fs from 'node:fs';
|
||||||
import path from "node:path";
|
import path from 'node:path';
|
||||||
import { Client, Collection, Events, GatewayIntentBits } from "discord.js";
|
import { Client, Collection, Events, GatewayIntentBits } from 'discord.js';
|
||||||
|
|
||||||
import { deployCommands } from "./util/deployCommand.js";
|
import { deployCommands } from './util/deployCommand.js';
|
||||||
import { getAllMembers, setMembers } from "./util/db.js";
|
import { removeMember, setMembers } from './util/db.js';
|
||||||
|
|
||||||
const config = JSON.parse(fs.readFileSync("./config.json", "utf8"));
|
const config = JSON.parse(fs.readFileSync('./config.json', 'utf8'));
|
||||||
const { token, guildId } = config;
|
const { token, guildId } = config;
|
||||||
|
|
||||||
const client: any = new Client({
|
const client: any = new Client({
|
||||||
|
@ -16,35 +16,38 @@ client.commands = new Collection();
|
||||||
try {
|
try {
|
||||||
const __dirname = path.resolve();
|
const __dirname = path.resolve();
|
||||||
|
|
||||||
const commandsPath = path.join(__dirname, "/target/commands/");
|
const commandsPath = path.join(__dirname, '/target/commands/');
|
||||||
const commandFiles = fs
|
const commandFiles = fs
|
||||||
.readdirSync(commandsPath)
|
.readdirSync(commandsPath)
|
||||||
.filter((file) => file.endsWith(".js"));
|
.filter((file) => file.endsWith('.js'));
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
for (const file of commandFiles) {
|
||||||
const filePath = path.join("file://", commandsPath, file);
|
const filePath = path.join('file://', commandsPath, file);
|
||||||
const commandModule = await import(filePath);
|
const commandModule = await import(filePath);
|
||||||
const command = commandModule.default;
|
const command = commandModule.default;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
command instanceof Object &&
|
command instanceof Object &&
|
||||||
"data" in command &&
|
'data' in command &&
|
||||||
"execute" in command
|
'execute' in command
|
||||||
) {
|
) {
|
||||||
client.commands.set(command.data.name, command);
|
client.commands.set(command.data.name, command);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
console.log(
|
console.log(
|
||||||
`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`
|
`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
}
|
||||||
|
catch (error: any) {
|
||||||
console.log(`Error while getting commands up: ${error}`);
|
console.log(`Error while getting commands up: ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await deployCommands();
|
await deployCommands();
|
||||||
} catch (error: any) {
|
}
|
||||||
|
catch (error: any) {
|
||||||
console.log(`Error while registering commands: ${error}`);
|
console.log(`Error while registering commands: ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,20 +73,34 @@ client.on(Events.InteractionCreate, async (interaction: any) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await command.execute(interaction);
|
await command.execute(interaction);
|
||||||
} catch (error) {
|
}
|
||||||
|
catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
if (interaction.replied || interaction.deferred) {
|
if (interaction.replied || interaction.deferred) {
|
||||||
await interaction.followUp({
|
await interaction.followUp({
|
||||||
content: "There was an error while executing this command!",
|
content: 'There was an error while executing this command!',
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: "There was an error while executing this command!",
|
content: 'There was an error while executing this command!',
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
client.on(Events.GuildMemberAdd, async () => {
|
||||||
|
const guild = await client.guilds.fetch(guildId);
|
||||||
|
const members = await guild.members.fetch();
|
||||||
|
const nonBotMembers = members.filter((member: any) => !member.user.bot);
|
||||||
|
|
||||||
|
await setMembers(nonBotMembers);
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on(Events.GuildMemberRemove, async (member: any) => {
|
||||||
|
await removeMember(member.user.id);
|
||||||
|
});
|
||||||
|
|
||||||
client.login(token);
|
client.login(token);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import fs from "node:fs";
|
import fs from 'node:fs';
|
||||||
import pkg from "pg";
|
import pkg from 'pg';
|
||||||
import { drizzle } from "drizzle-orm/node-postgres";
|
import { drizzle } from 'drizzle-orm/node-postgres';
|
||||||
import { memberTable } from "../db/schema.js";
|
import { memberTable } from '../db/schema.js';
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from 'drizzle-orm';
|
||||||
|
|
||||||
const { Pool } = pkg;
|
const { Pool } = pkg;
|
||||||
const config = JSON.parse(fs.readFileSync("./config.json", "utf8"));
|
const config = JSON.parse(fs.readFileSync('./config.json', 'utf8'));
|
||||||
const { dbConnectionString, guildId } = config;
|
const { dbConnectionString } = config;
|
||||||
|
|
||||||
const dbPool = new Pool({
|
const dbPool = new Pool({
|
||||||
connectionString: dbConnectionString,
|
connectionString: dbConnectionString,
|
||||||
|
@ -29,7 +29,8 @@ export async function setMembers(nonBotMembers: any) {
|
||||||
.update(memberTable)
|
.update(memberTable)
|
||||||
.set({ discordUsername: member.user.username })
|
.set({ discordUsername: member.user.username })
|
||||||
.where(eq(memberTable.discordId, member.user.id));
|
.where(eq(memberTable.discordId, member.user.id));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
const members: typeof memberTable.$inferInsert = {
|
const members: typeof memberTable.$inferInsert = {
|
||||||
discordId: member.user.id,
|
discordId: member.user.id,
|
||||||
discordUsername: member.user.username,
|
discordUsername: member.user.username,
|
||||||
|
@ -38,3 +39,7 @@ export async function setMembers(nonBotMembers: any) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function removeMember(discordId: string) {
|
||||||
|
await db.delete(memberTable).where(eq(memberTable.discordId, discordId));
|
||||||
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import { REST, Routes } from "discord.js";
|
import { REST, Routes } from 'discord.js';
|
||||||
import fs from "fs";
|
import fs from 'fs';
|
||||||
import path from "path";
|
import path from 'path';
|
||||||
|
|
||||||
const config = JSON.parse(fs.readFileSync("./config.json", "utf8"));
|
const config = JSON.parse(fs.readFileSync('./config.json', 'utf8'));
|
||||||
const { token, clientId, guildId } = config;
|
const { token, clientId, guildId } = config;
|
||||||
|
|
||||||
const __dirname = path.resolve();
|
const __dirname = path.resolve();
|
||||||
const commandsPath = path.join(__dirname, "target", "commands");
|
const commandsPath = path.join(__dirname, 'target', 'commands');
|
||||||
const commandFiles = fs
|
const commandFiles = fs
|
||||||
.readdirSync(commandsPath)
|
.readdirSync(commandsPath)
|
||||||
.filter((file) => file.endsWith(".js"));
|
.filter((file) => file.endsWith('.js'));
|
||||||
|
|
||||||
const rest = new REST({ version: "9" }).setToken(token);
|
const rest = new REST({ version: '9' }).setToken(token);
|
||||||
|
|
||||||
export const deployCommands = async () => {
|
export const deployCommands = async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -20,13 +20,14 @@ export const deployCommands = async () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const commands = commandFiles.map(async (file) => {
|
const commands = commandFiles.map(async (file) => {
|
||||||
const filePath = path.join("file://", commandsPath, file);
|
const filePath = path.join('file://', commandsPath, file);
|
||||||
const commandModule = await import(filePath);
|
const commandModule = await import(filePath);
|
||||||
const command = commandModule.default;
|
const command = commandModule.default;
|
||||||
|
|
||||||
if (command instanceof Object && "data" in command) {
|
if (command instanceof Object && 'data' in command) {
|
||||||
return command.data.toJSON();
|
return command.data.toJSON();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
console.log(
|
console.log(
|
||||||
`[WARNING] The command at ${filePath} is missing a required "data" property.`
|
`[WARNING] The command at ${filePath} is missing a required "data" property.`
|
||||||
);
|
);
|
||||||
|
@ -46,7 +47,8 @@ export const deployCommands = async () => {
|
||||||
console.log(
|
console.log(
|
||||||
`Successfully reloaded ${data.length} application (/) commands.`
|
`Successfully reloaded ${data.length} application (/) commands.`
|
||||||
);
|
);
|
||||||
} catch (error) {
|
}
|
||||||
|
catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||||
|
|
||||||
/* Language and Environment */
|
/* Language and Environment */
|
||||||
"target": "es2017", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
"target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||||
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
"lib": ["ES2022"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||||
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||||
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
||||||
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue