misc fixes
parent
373cb814c3
commit
7ea009714b
|
@ -117,7 +117,7 @@ export default class Whois extends DiscordInteractionCommand {
|
|||
});
|
||||
break;
|
||||
case 'offline':
|
||||
embed.addFields({ name: 'Status', value: 'offline', inline: true });
|
||||
embed.addFields({ name: 'Status', value: 'Offline', inline: true });
|
||||
break;
|
||||
case 'invisible':
|
||||
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 { discordBotToken, discordClientID } from "./config.json"
|
||||
import Collection from "./util/Collection";
|
||||
import DiscordInteractionCommand from "./util/DiscordInteractionCommand";
|
||||
import DiscordEvent from "./util/DiscordEvent";
|
||||
import * as DiscordInteractionCommandsIndex from "./discord/commands";
|
||||
import * as DiscordEventsIndex from "./discord/events";
|
||||
import mongoose from "mongoose";
|
||||
import { Client, GatewayIntentBits, Partials, REST, Routes } from 'discord.js';
|
||||
import { discordBotToken, discordClientID, MongoDbUrl } from './config.json';
|
||||
import Collection from './util/Collection';
|
||||
import DiscordInteractionCommand from './util/DiscordInteractionCommand';
|
||||
import DiscordEvent from './util/DiscordEvent';
|
||||
import * as DiscordInteractionCommandsIndex from './discord/commands';
|
||||
import * as DiscordEventsIndex from './discord/events';
|
||||
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();
|
||||
|
||||
// Instantiates a new Discord client
|
||||
|
@ -21,7 +22,12 @@ const discordClient = new Client({
|
|||
GatewayIntentBits.GuildInvites,
|
||||
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 stripeClient = new Stripe(stripeToken, { typescript: true });
|
||||
|
@ -29,11 +35,12 @@ const discordREST = new REST().setToken(discordBotToken);
|
|||
export async function main() {
|
||||
// Connect to the databases
|
||||
try {
|
||||
mongoose.connection.once("open", () => {
|
||||
console.info("[Info - Database] Connected to MongoDB");
|
||||
})
|
||||
//@ts-ignore
|
||||
mongoose.connection.once('open', () => {
|
||||
console.info('[Info - Database] Connected to MongoDB');
|
||||
});
|
||||
// TODO: Fetch the MongoDB URI from the config file
|
||||
await mongoose.connect("mongodb://localhost:27017/crra-main", {});
|
||||
await mongoose.connect(MongoDbUrl, {});
|
||||
} catch (error) {
|
||||
console.error(`[Error - Database] Failed to connect to MongoDB: ${error}`);
|
||||
process.exit(1);
|
||||
|
@ -42,7 +49,9 @@ export async function main() {
|
|||
for (const Command of Object.values(DiscordInteractionCommandsIndex)) {
|
||||
const instance = new Command();
|
||||
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
|
||||
for (const Event of Object.values(DiscordEventsIndex)) {
|
||||
|
@ -54,7 +63,9 @@ export async function main() {
|
|||
await discordClient.login(discordBotToken);
|
||||
|
||||
try {
|
||||
console.log(`Started refreshing ${DiscordInteractionCommands.size} application (/) commands.`);
|
||||
console.log(
|
||||
`Started refreshing ${DiscordInteractionCommands.size} application (/) commands.`
|
||||
);
|
||||
const interactionCommandsData = [];
|
||||
for (const command of DiscordInteractionCommands.values()) {
|
||||
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
|
||||
const data = await discordREST.put(
|
||||
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) {
|
||||
// And of course, make sure you catch and log any errors!
|
||||
console.error(error);
|
||||
|
|
Loading…
Reference in New Issue