forked from engineering/crv2
misc fixes
parent
373cb814c3
commit
7ea009714b
|
@ -117,7 +117,7 @@ export default class Whois extends DiscordInteractionCommand {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'offline':
|
case 'offline':
|
||||||
embed.addFields({ name: 'Status', value: 'offline', inline: true });
|
embed.addFields({ name: 'Status', value: 'Offline', inline: true });
|
||||||
break;
|
break;
|
||||||
case 'invisible':
|
case 'invisible':
|
||||||
embed.addFields({ name: 'Status', value: 'invisible', inline: true });
|
embed.addFields({ name: 'Status', value: 'invisible', inline: true });
|
||||||
|
|
51
index.ts
51
index.ts
|
@ -1,13 +1,14 @@
|
||||||
import { Client, GatewayIntentBits, Partials, REST, Routes } from "discord.js";
|
import { Client, GatewayIntentBits, Partials, REST, Routes } from 'discord.js';
|
||||||
import { discordBotToken, discordClientID } from "./config.json"
|
import { discordBotToken, discordClientID, MongoDbUrl } from './config.json';
|
||||||
import Collection from "./util/Collection";
|
import Collection from './util/Collection';
|
||||||
import DiscordInteractionCommand from "./util/DiscordInteractionCommand";
|
import DiscordInteractionCommand from './util/DiscordInteractionCommand';
|
||||||
import DiscordEvent from "./util/DiscordEvent";
|
import DiscordEvent from './util/DiscordEvent';
|
||||||
import * as DiscordInteractionCommandsIndex from "./discord/commands";
|
import * as DiscordInteractionCommandsIndex from './discord/commands';
|
||||||
import * as DiscordEventsIndex from "./discord/events";
|
import * as DiscordEventsIndex from './discord/events';
|
||||||
import mongoose from "mongoose";
|
import mongoose from 'mongoose';
|
||||||
|
|
||||||
export const DiscordInteractionCommands: Collection<DiscordInteractionCommand> = new Collection();
|
export const DiscordInteractionCommands: Collection<DiscordInteractionCommand> =
|
||||||
|
new Collection();
|
||||||
export const DiscordEvents: Collection<DiscordEvent> = new Collection();
|
export const DiscordEvents: Collection<DiscordEvent> = new Collection();
|
||||||
|
|
||||||
// Instantiates a new Discord client
|
// Instantiates a new Discord client
|
||||||
|
@ -21,7 +22,12 @@ const discordClient = new Client({
|
||||||
GatewayIntentBits.GuildInvites,
|
GatewayIntentBits.GuildInvites,
|
||||||
GatewayIntentBits.GuildModeration,
|
GatewayIntentBits.GuildModeration,
|
||||||
],
|
],
|
||||||
partials: [ Partials.GuildMember, Partials.Message, Partials.User, Partials.Channel, ],
|
partials: [
|
||||||
|
Partials.GuildMember,
|
||||||
|
Partials.Message,
|
||||||
|
Partials.User,
|
||||||
|
Partials.Channel,
|
||||||
|
],
|
||||||
});
|
});
|
||||||
const discordREST = new REST().setToken(discordBotToken);
|
const discordREST = new REST().setToken(discordBotToken);
|
||||||
// const stripeClient = new Stripe(stripeToken, { typescript: true });
|
// const stripeClient = new Stripe(stripeToken, { typescript: true });
|
||||||
|
@ -29,11 +35,12 @@ const discordREST = new REST().setToken(discordBotToken);
|
||||||
export async function main() {
|
export async function main() {
|
||||||
// Connect to the databases
|
// Connect to the databases
|
||||||
try {
|
try {
|
||||||
mongoose.connection.once("open", () => {
|
//@ts-ignore
|
||||||
console.info("[Info - Database] Connected to MongoDB");
|
mongoose.connection.once('open', () => {
|
||||||
})
|
console.info('[Info - Database] Connected to MongoDB');
|
||||||
|
});
|
||||||
// TODO: Fetch the MongoDB URI from the config file
|
// TODO: Fetch the MongoDB URI from the config file
|
||||||
await mongoose.connect("mongodb://localhost:27017/crra-main", {});
|
await mongoose.connect(MongoDbUrl, {});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`[Error - Database] Failed to connect to MongoDB: ${error}`);
|
console.error(`[Error - Database] Failed to connect to MongoDB: ${error}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -42,7 +49,9 @@ export async function main() {
|
||||||
for (const Command of Object.values(DiscordInteractionCommandsIndex)) {
|
for (const Command of Object.values(DiscordInteractionCommandsIndex)) {
|
||||||
const instance = new Command();
|
const instance = new Command();
|
||||||
DiscordInteractionCommands.add(instance.name, instance);
|
DiscordInteractionCommands.add(instance.name, instance);
|
||||||
console.info(`[Info - Discord] Loaded interaction command: ${instance.name}`);
|
console.info(
|
||||||
|
`[Info - Discord] Loaded interaction command: ${instance.name}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// Load Discord events
|
// Load Discord events
|
||||||
for (const Event of Object.values(DiscordEventsIndex)) {
|
for (const Event of Object.values(DiscordEventsIndex)) {
|
||||||
|
@ -54,7 +63,9 @@ export async function main() {
|
||||||
await discordClient.login(discordBotToken);
|
await discordClient.login(discordBotToken);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(`Started refreshing ${DiscordInteractionCommands.size} application (/) commands.`);
|
console.log(
|
||||||
|
`Started refreshing ${DiscordInteractionCommands.size} application (/) commands.`
|
||||||
|
);
|
||||||
const interactionCommandsData = [];
|
const interactionCommandsData = [];
|
||||||
for (const command of DiscordInteractionCommands.values()) {
|
for (const command of DiscordInteractionCommands.values()) {
|
||||||
interactionCommandsData.push(command.builder.toJSON());
|
interactionCommandsData.push(command.builder.toJSON());
|
||||||
|
@ -63,11 +74,11 @@ export async function main() {
|
||||||
// The put method is used to fully refresh all commands in the guild with the current set
|
// The put method is used to fully refresh all commands in the guild with the current set
|
||||||
const data = await discordREST.put(
|
const data = await discordREST.put(
|
||||||
Routes.applicationCommands(discordClientID),
|
Routes.applicationCommands(discordClientID),
|
||||||
{ body: interactionCommandsData },
|
{ body: interactionCommandsData }
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`Successfully reloaded ${interactionCommandsData?.length} application (/) commands.`
|
||||||
);
|
);
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
console.log(`Successfully reloaded ${data?.length} application (/) commands.`);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// And of course, make sure you catch and log any errors!
|
// And of course, make sure you catch and log any errors!
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
Loading…
Reference in New Issue