From ef5ce677d134f37682099499133cbdcc022f1878 Mon Sep 17 00:00:00 2001 From: MotiCAT Date: Wed, 20 Dec 2023 21:25:47 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20ignore=20build=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- build/Events/onPresenceUpdate.js | 51 -------------------------------- build/Events/onReady.js | 22 -------------- build/index.js | 30 ------------------- 4 files changed, 2 insertions(+), 104 deletions(-) delete mode 100644 build/Events/onPresenceUpdate.js delete mode 100644 build/Events/onReady.js delete mode 100644 build/index.js diff --git a/.gitignore b/.gitignore index 0f9dd58..b1ec95b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ .env -image.png \ No newline at end of file +image.png +build/ \ No newline at end of file diff --git a/build/Events/onPresenceUpdate.js b/build/Events/onPresenceUpdate.js deleted file mode 100644 index b4d3a3b..0000000 --- a/build/Events/onPresenceUpdate.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.onPresenceUpdate = void 0; -const index_1 = require("../index"); -const axios_1 = __importDefault(require("axios")); -const fs_1 = require("fs"); -const sharp_1 = __importDefault(require("sharp")); -async function onPresenceUpdate(oldPresence, newPresence) { - if (newPresence.userId !== process.env.USER_ID) - return; - const spotifyActivity = newPresence.activities.find((activity) => activity.name === 'Spotify'); - if (!spotifyActivity) - return; - const oldActivity = oldPresence?.activities.find((activity) => activity.name === 'Spotify'); - const { details: oldSongName, state: oldArtistName } = oldActivity || { details: '', state: '' }; - const { details: songName, state: artistName } = spotifyActivity; - if (oldSongName === songName && oldArtistName === artistName) - return; - const imageUrl = spotifyActivity?.assets?.largeImageURL(); - try { - const response = await axios_1.default.get(imageUrl, { responseType: 'arraybuffer' }); - const compressedImageBuffer = await (0, sharp_1.default)(response.data) - .png({ quality: 80 }) - .toBuffer(); - (0, fs_1.writeFile)('image.png', compressedImageBuffer, (err) => { - if (err) - throw err; - }); - } - catch (err) { - console.error(err); - return; - } - try { - const media_Id = await index_1.twiClient.v1.uploadMedia('./image.png'); - await index_1.twiClient.v2.tweet(`Now playing on Spotify: ${songName} by ${artistName}`, { - media: { media_ids: [media_Id] } - }); - (0, fs_1.unlink)('./image.png', (err) => { - if (err) - throw err; - }); - } - catch (err) { - console.error(err); - } -} -exports.onPresenceUpdate = onPresenceUpdate; diff --git a/build/Events/onReady.js b/build/Events/onReady.js deleted file mode 100644 index d6e8f47..0000000 --- a/build/Events/onReady.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.onReady = void 0; -const discord_js_1 = require("discord.js"); -function onReady(client) { - console.log(`Logged in as ${client.user?.tag}`); - client.user?.setActivity('CatHouse Products'); - console.table({ - 'Bot User': client.user?.tag, - 'Guild(s)': client.guilds.cache.size + ' Servers', - Watching: client.guilds.cache.reduce((a, b) => a + b.memberCount, 0) + ' Members', - 'Discord.js': discord_js_1.version, - 'Node.js': process.version, - Plattform: process.platform + ' | ' + process.arch, - Memory: (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2) + - 'MB | ' + - (process.memoryUsage().rss / 1024 / 1024).toFixed(2) + - 'MB' - // Quote from: https://github.com/Nich87/Faith - }); -} -exports.onReady = onReady; diff --git a/build/index.js b/build/index.js deleted file mode 100644 index 9649c43..0000000 --- a/build/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.twiClient = void 0; -const onPresenceUpdate_1 = require("./Events/onPresenceUpdate"); -const onReady_1 = require("./Events/onReady"); -const discord_js_1 = require("discord.js"); -const dotenv_1 = require("dotenv"); -const twitter_api_v2_1 = require("twitter-api-v2"); -(0, dotenv_1.config)(); -if (!process.env.API_KEY || !process.env.API_SECRET || !process.env.ACCESS_TOKEN || !process.env.ACCESS_TOKEN_SECRET) { - console.error('APIキーのいずれかが設定されていません。.envファイルを確認してください。'); - process.exit(1); -} -if (!process.env.USER_ID || !process.env.DISCORD_TOKEN) { - console.error('DiscordのユーザーIDまたはボットのトークンが設定されていません。.envファイルを確認してください。'); - process.exit(1); -} -const client = new discord_js_1.Client({ - intents: [discord_js_1.GatewayIntentBits.Guilds, discord_js_1.GatewayIntentBits.GuildPresences] -}); -exports.twiClient = new twitter_api_v2_1.TwitterApi({ - appKey: process.env.API_KEY, - appSecret: process.env.API_SECRET, - accessToken: process.env.ACCESS_TOKEN, - accessSecret: process.env.ACCESS_TOKEN_SECRET -}); -client - .on('ready', () => (0, onReady_1.onReady)(client)) - .on('presenceUpdate', async (oldPresence, newPresence) => (0, onPresenceUpdate_1.onPresenceUpdate)(oldPresence, newPresence)) - .login(process.env.DISCORD_TOKEN);