diff options
author | TymanWasTaken <32660892+tymanwastaken@users.noreply.github.com> | 2021-05-28 21:51:02 -0600 |
---|---|---|
committer | TymanWasTaken <32660892+tymanwastaken@users.noreply.github.com> | 2021-05-28 21:51:02 -0600 |
commit | 1e9e334097702c68d871365fc016aa096d03c491 (patch) | |
tree | 65b22d1d529cda850e5c30e9fe19a2504fca2645 /src/lib/extensions/Util.ts | |
parent | 53d8d5e551e9a239fd4c48c7dca4e1f6fb8d81e9 (diff) | |
download | tanzanite-1e9e334097702c68d871365fc016aa096d03c491.tar.gz tanzanite-1e9e334097702c68d871365fc016aa096d03c491.tar.bz2 tanzanite-1e9e334097702c68d871365fc016aa096d03c491.zip |
Remove references - caused some issues, comment out some image gen code
Diffstat (limited to 'src/lib/extensions/Util.ts')
-rw-r--r-- | src/lib/extensions/Util.ts | 139 |
1 files changed, 129 insertions, 10 deletions
diff --git a/src/lib/extensions/Util.ts b/src/lib/extensions/Util.ts index bd6823f..5e9d5e7 100644 --- a/src/lib/extensions/Util.ts +++ b/src/lib/extensions/Util.ts @@ -246,10 +246,13 @@ export class Util extends ClientUtil { } public async syncSlashCommands(force = false, guild?: string): Promise<void> { - let fetchedGuild: Guild + let fetchedGuild: Guild; if (guild) fetchedGuild = this.client.guilds.cache.get(guild); try { - const registered = guild === undefined ? await this.client.application.commands.fetch() : await fetchedGuild.commands.fetch(); + const registered = + guild === undefined + ? await this.client.application.commands.fetch() + : await fetchedGuild.commands.fetch(); for (const [, registeredCommand] of registered) { if ( !this.client.commandHandler.modules.find( @@ -257,9 +260,15 @@ export class Util extends ClientUtil { )?.execSlash || force ) { - guild === undefined ? await this.client.application.commands.delete(registeredCommand.id) : await fetchedGuild.commands.delete(registeredCommand.id); + guild === undefined + ? await this.client.application.commands.delete( + registeredCommand.id + ) + : await fetchedGuild.commands.delete(registeredCommand.id); this.client.logger.verbose( - chalk`{red Deleted slash command ${registeredCommand.name}${guild !== undefined ? ` in guild ${fetchedGuild.name}`:''}}` + chalk`{red Deleted slash command ${registeredCommand.name}${ + guild !== undefined ? ` in guild ${fetchedGuild.name}` : '' + }}` ); } } @@ -276,25 +285,44 @@ export class Util extends ClientUtil { if (found?.id && !force) { if (slashdata.description !== found.description) { - guild === undefined ? await this.client.application.commands.edit(found.id, slashdata) : fetchedGuild.commands.edit(found.id, slashdata); + guild === undefined + ? await this.client.application.commands.edit( + found.id, + slashdata + ) + : fetchedGuild.commands.edit(found.id, slashdata); this.client.logger.verbose( - chalk`{yellow Edited slash command ${botCommand.id}${guild !== undefined ? ` in guild ${fetchedGuild.name}`:''}}` + chalk`{yellow Edited slash command ${botCommand.id}${ + guild !== undefined ? ` in guild ${fetchedGuild.name}` : '' + }}` ); } } else { - guild === undefined ? await this.client.application.commands.create(slashdata) : fetchedGuild.commands.create(slashdata); + guild === undefined + ? await this.client.application.commands.create(slashdata) + : fetchedGuild.commands.create(slashdata); this.client.logger.verbose( - chalk`{green Created slash command ${botCommand.id}${guild !== undefined ? ` in guild ${fetchedGuild.name}`:''}}` + chalk`{green Created slash command ${botCommand.id}${ + guild !== undefined ? ` in guild ${fetchedGuild.name}` : '' + }}` ); } } } - return this.client.logger.log(chalk.green(`Slash commands registered${guild !== undefined ? ` in guild ${fetchedGuild.name}`:''}`)); + return this.client.logger.log( + chalk.green( + `Slash commands registered${ + guild !== undefined ? ` in guild ${fetchedGuild.name}` : '' + }` + ) + ); } catch (e) { console.log(chalk.red(e.stack)); return this.client.logger.error( - chalk`{red Slash commands not registered${guild !== undefined ? ` in guild ${fetchedGuild.name}`:''}, see above error.}` + chalk`{red Slash commands not registered${ + guild !== undefined ? ` in guild ${fetchedGuild.name}` : '' + }, see above error.}` ); } } @@ -327,3 +355,94 @@ export class Util extends ClientUtil { { name: 'No Support', id: '790247359824396319' } ]; } + +// I just copy pasted this code from stackoverflow don't yell at me if there is issues for it +export class CanvasProgressBar { + private x: number; + private y: number; + private w: number; + private h: number; + private color: string; + private percentage: number; + private p: number; + private ctx: CanvasRenderingContext2D; + + constructor( + ctx: CanvasRenderingContext2D, + dimension: { x: number; y: number; width: number; height: number }, + color: string, + percentage: number + ) { + ({ x: this.x, y: this.y, width: this.w, height: this.h } = dimension); + this.color = color; + this.percentage = percentage; + this.p; + this.ctx = ctx; + } + + draw() { + // ----------------- + this.p = this.percentage * this.w; + if (this.p <= this.h) { + this.ctx.beginPath(); + this.ctx.arc( + this.h / 2 + this.x, + this.h / 2 + this.y, + this.h / 2, + Math.PI - Math.acos((this.h - this.p) / this.h), + Math.PI + Math.acos((this.h - this.p) / this.h) + ); + this.ctx.save(); + this.ctx.scale(-1, 1); + this.ctx.arc( + this.h / 2 - this.p - this.x, + this.h / 2 + this.y, + this.h / 2, + Math.PI - Math.acos((this.h - this.p) / this.h), + Math.PI + Math.acos((this.h - this.p) / this.h) + ); + this.ctx.restore(); + this.ctx.closePath(); + } else { + this.ctx.beginPath(); + this.ctx.arc( + this.h / 2 + this.x, + this.h / 2 + this.y, + this.h / 2, + Math.PI / 2, + (3 / 2) * Math.PI + ); + this.ctx.lineTo(this.p - this.h + this.x, 0 + this.y); + this.ctx.arc( + this.p - this.h / 2 + this.x, + this.h / 2 + this.y, + this.h / 2, + (3 / 2) * Math.PI, + Math.PI / 2 + ); + this.ctx.lineTo(this.h / 2 + this.x, this.h + this.y); + this.ctx.closePath(); + } + this.ctx.fillStyle = this.color; + this.ctx.fill(); + } + + // showWholeProgressBar(){ + // this.ctx.beginPath(); + // this.ctx.arc(this.h / 2 + this.x, this.h / 2 + this.y, this.h / 2, Math.PI / 2, 3 / 2 * Math.PI); + // this.ctx.lineTo(this.w - this.h + this.x, 0 + this.y); + // this.ctx.arc(this.w - this.h / 2 + this.x, this.h / 2 + this.y, this.h / 2, 3 / 2 *Math.PI, Math.PI / 2); + // this.ctx.lineTo(this.h / 2 + this.x, this.h + this.y); + // this.ctx.strokeStyle = '#000000'; + // this.ctx.stroke(); + // this.ctx.closePath(); + // } + + get PPercentage() { + return this.percentage * 100; + } + + set PPercentage(x) { + this.percentage = x / 100; + } +} |