diff --git a/package.json b/package.json index abe9367..bd6119a 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "dependencies": { "@discordjs/builders": "^1.7.0", "@discordjs/rest": "2.2.0", - "canvas": "^2.11.2", "colorette": "^2.0.20", "discord-api-types": "^0.37.77", "discord.js": "14.14.1", diff --git a/src/assets/numismatics_icon.png b/src/assets/numismatics_icon.png deleted file mode 100644 index ad79c11..0000000 Binary files a/src/assets/numismatics_icon.png and /dev/null differ diff --git a/src/assets/railways_icon.png b/src/assets/railways_icon.png deleted file mode 100644 index ad254a5..0000000 Binary files a/src/assets/railways_icon.png and /dev/null differ diff --git a/src/handlers/dynamicIcon.handler.ts b/src/handlers/dynamicIcon.handler.ts deleted file mode 100644 index b20fa00..0000000 --- a/src/handlers/dynamicIcon.handler.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { Handler } from '..'; -import { PNGStream, createCanvas, loadImage } from 'canvas'; - -async function stream2buffer(stream: PNGStream): Promise { - return new Promise((resolve, reject) => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const _buf = Array(); - - stream.on('data', (chunk) => _buf.push(chunk)); - stream.on('end', () => resolve(Buffer.concat(_buf))); - stream.on('error', (err) => reject(`error converting stream - ${err}`)); - }); -} - -export const dynamicIconHandler: Handler = (client) => { - const startTime = 1712518661_000; - const endTime = 1712595600_000; - const totalTime = endTime - startTime; - let timeout: NodeJS.Timeout | undefined = undefined; - if (Date.now() > endTime) return; - client.on('messageCreate', async (message) => { - if (message.content != 'start numismatics icon thingy please') return; - if (!message.member?.permissions.has('Administrator')) { - await message.reply('nuh uh'); - return; - } - if (timeout) { - await message.reply('it already started silly'); - return; - } - await message.reply('ok!!'); - const updateIcon = async () => { - const currentTime = Date.now() - startTime; - const currentProgress = currentTime / totalTime; - console.log( - `Current Progress at ${new Date().toLocaleString()} is ${Math.round(currentProgress * 100)}%` - ); - message.guild?.setIcon( - await stream2buffer(await generateIcon(currentProgress / 2)) - ); - if (Date.now() > endTime) { - clearInterval(timeout); - } - }; - await updateIcon(); - timeout = setInterval(updateIcon, 3600_000); - }); -}; - -async function generateIcon(progress: number) { - const canvas = createCanvas(256, 256); - const ctx = canvas.getContext('2d'); - ctx.drawImage( - await loadImage(__dirname + '/../assets/railways_icon.png'), - 0, - 0 - ); - const x = progress * canvas.width * 2 - canvas.width; - const y = -(Math.sin(progress * Math.PI) * 256 - 256); - ctx.drawImage( - await loadImage(__dirname + '/../assets/numismatics_icon.png'), - x, - y - ); - return canvas.createPNGStream({}); -} diff --git a/src/index.ts b/src/index.ts index 73b7c6f..6646e6a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,7 +15,6 @@ import { buttonHandler } from './handlers/button.handler'; import textCommandHandler from './handlers/textCommand.handler'; import { modalHandler } from './handlers/modal.handler'; import { ChannelType } from 'discord-api-types/v10'; -import { dynamicIconHandler } from './handlers/dynamicIcon.handler'; // import { spamHandler } from './handlers/spam.handler'; export const client = new Client({ @@ -121,7 +120,6 @@ const handlers: Handler[] = [ logHandler, buttonHandler, modalHandler, - dynamicIconHandler, // spamHandler, ];