Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rdeisenroth committed Oct 23, 2023
1 parent bcc1840 commit d89697d
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 14 deletions.
5 changes: 5 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"execMap": {
"ts": "ts-node"
}
}
124 changes: 120 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"type": "commonjs",
"scripts": {
"start": "tsc --build --clean tsconfig.json; tsc --build tsconfig.json; node dist/index.js",
"nodemon": "nodemon --watch 'src/**/*.ts' src/index.ts",
"build": "tsc --build --clean tsconfig.json; tsc --build tsconfig.json",
"lint": "eslint --ext .ts src/",
"watch": "tsc -p tsconfig.json -w",
Expand Down Expand Up @@ -49,7 +50,7 @@
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.5",
"@types/mocha": "^10.0.2",
"@types/moment-duration-format": "^2.2.4",
"@types/moment-duration-format": "^2.2.5",
"@types/urban-dictionary": "^3.0.0",
"@types/yargs": "^17.0.28",
"@types/yargs-parser": "^21.0.1",
Expand All @@ -59,6 +60,7 @@
"eslint": "^8.51.0",
"jest": "^29.7.0",
"mocha": "^10.2.0",
"nodemon": "^3.0.1",
"ts-jest": "^29.1.1",
"ts-mockito": "^2.6.1",
"ts-node": "^10.9.1",
Expand Down
9 changes: 8 additions & 1 deletion src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ export class Bot extends Client {
*/
public async start(): Promise<void> {
this.logger.info("starting Bot...");
this.login(this.config.get("token")).catch((e) => this.logger.error(e));
try {
await this.login(this.config.get("token"));
} catch (error) {
this.logger.error("Invalid token", error);
process.exit(1);
}

// Commands
this.logger.info("Loading Commands...");
Expand Down Expand Up @@ -189,6 +194,8 @@ export class Bot extends Client {
}, null, true, "America/Los_Angeles");
queueGuardJob.start();

this.logger.ready(`Bot ${this.user?.displayName} is Ready!`);

// public async createGuildCommand(data:any, guildId:string) {
// return await this.api.appl
// }
Expand Down
2 changes: 2 additions & 0 deletions src/events/InteractionCreateEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Command, ExecuteEvent } from "../../typings";
import { ChatInputCommandInteraction, Collection, CommandInteractionOption } from "discord.js";
export const name = "interactionCreate";
import {GuildModel} from "../models/guilds";
import { DocumentType, isDocument } from "@typegoose/typegoose";
import { GuildSettings } from "../models/guild_settings";

export const execute: ExecuteEvent<"interactionCreate"> = async (client, interaction) => {

Expand Down
4 changes: 2 additions & 2 deletions src/models/guild_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export class GuildSettings {
/**
* The Guild Specific command Settings
*/
@prop({ required: true, default: [], type: () => [SlashCommandSettings] })
@prop({ required: true, default: [], type: () => SlashCommandSettings })
slashCommands!: mongoose.Types.DocumentArray<ArraySubDocumentType<SlashCommandSettings>>;
/**
* The Guild Specific role Settings
*/
@prop({ default: [], type: () => [DBRole] })
@prop({ default: [], type: () => DBRole })
roles?: mongoose.Types.DocumentArray<ArraySubDocumentType<DBRole>>;
/**
* The User Account URL related to the guild
Expand Down
2 changes: 1 addition & 1 deletion src/models/guilds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class Guild {
/**
* The Settings for the Guild
*/
@prop({ required: true })
@prop({ required: true, type: () => GuildSettings })
guild_settings!: SubDocumentType<GuildSettings>;
/**
* The Relevant Text Channels of the Guild
Expand Down
7 changes: 4 additions & 3 deletions src/models/queues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { VoiceChannel } from "./voice_channels";
import { QueueEntry } from "./queue_entry";
import * as utils from "../utils/utils";
import { StringReplacements } from "../../typings";
import moment from "moment";
import * as moment from "moment";
import momentDurationFormatSetup from "moment-duration-format";
import { QueueSpan } from "./queue_span";
import { Guild } from "./guilds";
import { VoiceChannelSpawner } from "./voice_channel_spawner";
Expand Down Expand Up @@ -65,7 +66,7 @@ export class Queue {
/**
* A Template for spawning in Rooms (if empty default template is used)
*/
@prop({ type: () => VoiceChannel })
@prop({ type: () => VoiceChannelSpawner })
room_spawner?: SubDocumentType<VoiceChannelSpawner>;
/**
* A text Channel to use if dms are disabled
Expand Down Expand Up @@ -315,7 +316,7 @@ export class Queue {
* Returns `true` if the Queue is Empty
*/
public isEmpty(this: DocumentType<Queue>): boolean{
return !!this.entries.length;
return this.entries.length < 1;
}
/**
* Locks the queue. This removes the voice Channel Permissions and disallows the queue from the /queue join command
Expand Down
2 changes: 1 addition & 1 deletion src/models/slash_command_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class SlashCommandSettings {
* The Default Command Permission overwrite
*/
@prop({ required: false })
defaultPermission?: SubDocumentType<PermissionResolvable>;
defaultPermission?: PermissionResolvable;
/**
* If the command should be completely removed from the slash command List
*/
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2019",
"target": "ES2022",
"module": "commonjs",
// "moduleResolution": "node",
"strict": true,
Expand Down

0 comments on commit d89697d

Please sign in to comment.