Skip to content

Commit

Permalink
#53: lint remove newLine at end
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Siniecki committed Jan 26, 2024
1 parent b31cf1f commit 50b0639
Show file tree
Hide file tree
Showing 18 changed files with 140 additions and 128 deletions.
3 changes: 1 addition & 2 deletions src/models/bot_roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ export interface BotRole extends DBRole {
* The Scope of the Role
*/
scope: RoleScopes.GLOBAL,
}

}
13 changes: 1 addition & 12 deletions src/models/database_mockup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,4 @@ const rooms =
},
],
},
];
/**
* guilds
* sessions
* rooms: {
* active: boolean
* events: {
* create|join|mute|move|kick|leave|destroy
* }
* }
* users
*/
];
2 changes: 1 addition & 1 deletion src/models/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ export class VoiceChannelEvent extends Event<VoiceChannelEventType> {
export class QueueEvent extends Event<QueueEventType> {
@prop({ required: true, enum: QueueEventType, default: QueueEventType.OTHER })
type!: QueueEventType;
}
}
3 changes: 1 addition & 2 deletions src/models/guild_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,4 @@ export class GuildSettings {
}
return this.getCommandByInternalName(name)!;
}
}

}
3 changes: 1 addition & 2 deletions src/models/guilds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,4 @@ export class Guild {
// Post slash Commands
await guildData.postSlashCommands(client, g);
}
}

}
3 changes: 1 addition & 2 deletions src/models/permission_overwrite_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ export class PermissionOverwriteData implements OverwriteData {
allow?: PermissionResolvable[];
@prop({ required: true, type: String, default: [] })
deny?: PermissionResolvable[];
}

}
3 changes: 1 addition & 2 deletions src/models/queue_entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ export class QueueEntry {
*/
@prop({ required: false })
intent?: string;
}

}
3 changes: 1 addition & 2 deletions src/models/queue_span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,4 @@ export class QueueSpan {
equals(other: QueueSpan) {
return this.begin.equals(other.begin) && this.end.equals(other.end) && this.openShift === other.openShift && this.closeShift === other.closeShift && this.startDate === other.startDate && this.endDate === other.endDate;
}
}

}
116 changes: 64 additions & 52 deletions src/models/queues.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { prop, DocumentType, SubDocumentType, ArraySubDocumentType, mongoose, getModelForClass } from "@typegoose/typegoose";
import { VoiceChannel } from "./voice_channels";
import { QueueEntry } from "./queue_entry";
import {
prop,
DocumentType,
SubDocumentType,
ArraySubDocumentType,
mongoose,
} from "@typegoose/typegoose";
import {VoiceChannel} from "./voice_channels";
import {QueueEntry} from "./queue_entry";
import * as utils from "../utils/utils";
import { StringReplacements } from "../../typings";
import {StringReplacements} from "../../typings";
import * as moment from "moment";
import { QueueSpan } from "./queue_span";
import { Guild } from "./guilds";
import { VoiceChannelSpawner } from "./voice_channel_spawner";
import { QueueEventType } from "./events";
import {QueueSpan} from "./queue_span";
import {Guild} from "./guilds";
import {VoiceChannelSpawner} from "./voice_channel_spawner";
import {QueueEventType} from "./events";
import djs from "discord.js";
import {SessionModel} from "./models";

Expand All @@ -18,102 +24,102 @@ export class Queue {
/**
* The Name Of The Queue
*/
@prop({ required: true })
name!: string;
@prop({required: true})
name!: string;
/**
* A Description of the Queue
*/
@prop()
description?: string;
description?: string;
/**
* The max Amount of Users that the queue can handle
*/
@prop()
limit?: number;
limit?: number;
/**
* The Timeout in Milliseconds if the User disconnects from the Queue (usefull for VC based Queues)
*/
@prop()
disconnect_timeout?: number;
disconnect_timeout?: number;
/**
* The Timeout in Milliseconds that the user is kicked off the queue After not accepting a match
*/
@prop()
match_timeout?: number;
match_timeout?: number;
/**
* A Custom Join Message for the Queue. Use ${pos} ${total} ${eta} ${user} and so on to create Dynamic Messages.
*/
@prop()
join_message?: string;
join_message?: string;
/**
* A Custom Match Found Message for the Queue. Use ${pos} ${total} ${eta} ${user} ${match} ${match_channel} and so on to create Dynamic Messages.
*/
@prop()
match_found_message?: string;
match_found_message?: string;
/**
* A Custom Timeout Message. Use ${pos} ${total} ${eta} ${user} ${timeout} and so on to create Dynamic Messages.
*/
@prop()
timeout_message?: string;
timeout_message?: string;
/**
* A Custom Leave Message. Use ${pos} ${total} ${eta} ${user} ${timeout} and so on to create Dynamic Messages.
*/
@prop()
leave_message?: string;
leave_message?: string;
/**
* A Custom Message that is Displayed when the Room is Left (like Please confirm ur stay)
*/
@prop()
leave_room_message?: string;
leave_room_message?: string;
/**
* A Template for spawning in Rooms (if empty default template is used)
*/
@prop({ type: () => VoiceChannelSpawner })
room_spawner?: SubDocumentType<VoiceChannelSpawner>;
@prop({type: () => VoiceChannelSpawner})
room_spawner?: SubDocumentType<VoiceChannelSpawner>;
/**
* A text Channel to use if dms are disabled
*/
@prop()
text_channel?: string;
text_channel?: string;

/**
* Text Channels ids to log queue events
*/
@prop({ default: [], required: false })
info_channels!: {
channel_id: string;
events: QueueEventType[];
@prop({default: [], required: false})
info_channels!: {
channel_id: string;
events: QueueEventType[];
}[];
/**
* Whether the queue is locked (this also disables the /queue join command for this queue)
*/
@prop({ default: false })
locked?: boolean;
@prop({default: false})
locked?: boolean;
/**
* Whether to automatically lock and unlock the queue according to the opening_times
*/
@prop({ default: false })
auto_lock?: boolean;
@prop({default: false})
auto_lock?: boolean;
/**
* The opening times of the Queue
*/
@prop({ type: QueueSpan, default: [], required: true })
opening_times!: mongoose.Types.DocumentArray<ArraySubDocumentType<QueueSpan>>;
@prop({type: QueueSpan, default: [], required: true})
opening_times!: mongoose.Types.DocumentArray<ArraySubDocumentType<QueueSpan>>;
/**
* The standard time to shift the unlocking of the queue by in milliseconds
*/
@prop({ default: 0 })
openShift?: number;
@prop({default: 0})
openShift?: number;
/**
* The standard time to shift the locking of the queue by in milliseconds
*/
@prop({ default: 0 })
closeShift?: number;
@prop({default: 0})
closeShift?: number;
/**
* The Entries of the Queue
*/
@prop({ type: QueueEntry, default: [], required: true })
entries!: mongoose.Types.DocumentArray<ArraySubDocumentType<QueueEntry>>;
@prop({type: QueueEntry, default: [], required: true})
entries!: mongoose.Types.DocumentArray<ArraySubDocumentType<QueueEntry>>;

/**
* Put an Entry into the Queue
Expand Down Expand Up @@ -141,6 +147,7 @@ export class Queue {
await this.$parent()?.save();
return entry;
}

/**
* Gets the Sorted Entries with the First ones being the ones with the highest Importance
* @param limit How many entries should we get at most?
Expand All @@ -153,27 +160,31 @@ export class Queue {
});
return entries.slice(0, limit);
}

/**
* Returns true if the ID is contained in the queue
* @param discord_id the Discord ID to check if it's contained
*/
public contains(this: DocumentType<Queue>, discord_id: string): boolean {
return this.entries.some(x => x.discord_id === discord_id);
}

/**
* Gets The Entry that has the given Discord ID
* @param discord_id The Discord ID of the Entry
*/
public getEntry(this: DocumentType<Queue>, discord_id: string): DocumentType<QueueEntry> | null {
return this.entries.find(x => x.discord_id === discord_id) ?? null;
}

/**
* Gets the Position in the Current Queue
* @param discord_id the Discord ID of the entry
*/
public getPosition(this: DocumentType<Queue>, discord_id: string): number {
return this.getSortedEntries().findIndex(x => x.discord_id === discord_id);
}

/**
* Interpolates the Queue String
* @param string The String to Interpolate
Expand Down Expand Up @@ -227,7 +238,9 @@ export class Queue {
"member_id": entry.discord_id,
"user": `<@${entry.discord_id}>`,
"pos": this.getPosition(entry.discord_id) + 1,
"time_spent": (moment.duration(Date.now() - (+entry.joinedAt)) as unknown as { format: (arg0: string) => string; })
"time_spent": (moment.duration(Date.now() - (+entry.joinedAt)) as unknown as {
format: (arg0: string) => string;
})
.format("d[d ]h[h ]m[m ]s.S[s]"),
};
for (const [key, value] of Object.entries(entryReplacements)) {
Expand All @@ -242,6 +255,7 @@ export class Queue {
return null;
}
}

/**
* Gets the leave Message of the Queue
*/
Expand All @@ -265,11 +279,11 @@ export class Queue {
if (this.leave_message) {
const leave_msg = await this.interpolateQueueString(this.leave_message!, entry_resolvable);
return leave_msg ?? default_leave_message;
}
else {
} else {
return default_leave_message;
}
}

/**
* Gets the leave Room Message of the Queue
*/
Expand All @@ -293,11 +307,11 @@ export class Queue {
if (this.leave_room_message) {
const leave_msg = await this.interpolateQueueString(this.leave_room_message, entry_resolvable);
return leave_msg ?? default_leave_message;
}
else {
} else {
return default_leave_message;
}
}

/**
* Gets the join Message of the Queue
*/
Expand All @@ -321,38 +335,42 @@ export class Queue {
if (this.join_message) {
const join_msg = await this.interpolateQueueString(this.join_message, entry_resolvable);
return join_msg ?? default_join_message;
}
else {
} else {
return default_join_message;
}
}

/**
* Returns `true` if the Queue is Empty
*/
public isEmpty(this: DocumentType<Queue>): boolean {
return this.entries.length < 1;
}

/**
* Locks the queue. This removes the voice Channel Permissions and disallows the queue from the /queue join command
*/
public async lock(this: DocumentType<Queue>): Promise<void> {
this.locked = true;
await this.$parent()?.save();
}

/**
* Unlocks the queue. This restores the voice Channel Permissions and allows the queue from the /queue join command
*/
public async unlock(this: DocumentType<Queue>): Promise<void> {
this.locked = false;
await this.$parent()?.save();
}

/**
* Locks or Unlocks the queue (opposite State).
*/
public async toggleLock(this: DocumentType<Queue>): Promise<void> {
this.locked = !this.locked;
await this.$parent()?.save();
}

/**
* Resolves all Waiting rooms for the current Queue
*/
Expand All @@ -379,10 +397,4 @@ export class Queue {
}
return entries;
}
}

export const QueueModel = getModelForClass(Queue, {
schemaOptions: {
autoCreate: false,
},
});
}
Loading

0 comments on commit 50b0639

Please sign in to comment.