diff --git a/Indo.md b/Indo.md index dc60b8f..c9e0003 100644 --- a/Indo.md +++ b/Indo.md @@ -1,6 +1,6 @@
-![PteroStats Banner](https://cdn.discordapp.com/attachments/626755594526916629/978478722489393153/20220524_090325.png) +PteroStats Banner ## Bahasa / Language [[Indonesia]](https://github.com/HirziDevs/PteroStats/blob/dev/Indo.md) | [[Inggris]](https://github.com/HirziDevs/PteroStats/blob/dev/README.md) @@ -10,91 +10,109 @@ ## Pengenalan PteroStats adalah bot yang dirancang untuk memeriksa status panel pterodactyl dan dikirim ke server discord +## Contoh +Example + ## Instalasi - - [Mendapatkan apikey dari pterodactyl](#mendapatkan-apikey-dari-pterodactyl) - - [Membuat Discord Bot](#membuat-discord-bot) - - [Menginvite Discord Bot](#menginvite-discord-bot) - - [Mendapatkan Channel ID](#mendapatkan-channel-id) - - [Memulai Bot](#memulai-bot) + 1. [Mendapatkan apikey dari pterodactyl](#mendapatkan-apikey-dari-pterodactyl) + 2. [Membuat Discord Bot](#membuat-discord-bot) + 3. [Menginvite Discord Bot](#menginvite-discord-bot) + 4. [Mendapatkan Channel ID](#mendapatkan-channel-id) + 5. [Memulai Bot](#memulai-bot) + - [Mengunakan custom emoji](#mengunakan-custom-emoji) - [Blacklist Nodes](#blacklist-nodes) ### Mendapatkan apikey dari pterodactyl -- Pergi ke `panel admin pterodactyl` dan pergi ke `Application API` +1. Pergi ke `panel admin pterodactyl` dan pergi ke `Application API` - ![Admin Panel](https://usercontent.catto.pictures/hirzi/aabafe57-cbfe-4d7f-9d6d-4a63a7f23d4c.png) + Admin Panel -- Klik tombol `Create New` +2. Klik tombol `Create New` - ![Application API Page](https://usercontent.catto.pictures/hirzi/f916f0c6-0968-4125-8226-ba4daa1de902.png) + Application API Page -- Set semua permission ke `read` dan untuk description kamu bisa mengisi apa saja +3. Set semua permission ke `read` dan untuk description kamu bisa mengisi apa saja - ![Create Application API](https://usercontent.catto.pictures/hirzi/3e4575cb-4f52-4bd9-9091-36fda20bedad.png) + Create Application API -- Copy apikey-nya. +4. Copy apikey-nya. - ![Application API List](https://usercontent.catto.pictures/hirzi/9142b0b3-0556-4741-840c-6976c3fe3ad4.png) + Application API List + +5. Paste panel apikeynya dan panel urlnya di config + + Panel Config ### Membuat Discord Bot Kalian bisa cek [website ini](https://discordjs.guide/preparations/setting-up-a-bot-application.html) +Paste bot tokennya di config + +Bot Config + ### Menginvite Discord Bot Kalian bisa cek [website ini](https://discordjs.guide/preparations/adding-your-bot-to-servers.html) ### Mendapatkan Channel ID 1. Aktifkan `Developer Mode` di settings discord kamu - ![Discord User Settings](https://usercontent.catto.pictures/hirzi/c5e825d1-c323-4b19-a11b-e2f004d4906e.png) + Discord User Settings 2. Klik kanan teks channel dan pilih `Copy ID` - ![Klik Kanan Channel](https://usercontent.catto.pictures/hirzi/e5fa4f62-b28f-45fd-a544-429f23899edb.png) + Right Click Channel + +3. Paste id channelnya di config + + Channel Config ### Memulai Bot -- Masukan `token` bot discord di `line token` yang terdapat di file `config.yml` -- Copy `id channel` diserver discord kamu dan masukan ke line `channel` di file `config.yml` -- Masukan `apikey` dan `url` pterodactyl di `line panel` di file `config.yml` -- Jalankan command `npm install` di folder yang berisi file bot -- Jalankan command `node index` dan kamu selesai! +1. Pastikan kamu telah melakukan semua yang ada diatas +2. Jalankan command `npm install` di folder yang berisi file bot +3. Jalankan command `node index` dan kamu selesai! Jika kamu mendapat masalah bisa dm `Hirzi#8701` didiscord atau join [server support kami](https://discord.gg/zv6maQRah3) ### Mengunakan custom emoji 1. ketik `\` di server yang ada custom emojinya - ![Type \ on the chat](https://usercontent.catto.pictures/hirzi/1f59b255-7c5d-48f2-ab93-5358429cec83.png) + Type \ on the chat 2. Pilih custom emoji yang kamu mau - ![Select Custom Emoji](https://usercontent.catto.pictures/hirzi/38098261-7257-4e4d-8945-4ac5c252c952.png) + Select Custom Emoji 3. Copy textnya! - ![Copy Emoji ID](https://usercontent.catto.pictures/hirzi/33800ccf-9ed5-4d54-9747-2983b23e1755.png) + Copy Emoji ID + +4. Paste id emojinya di config + + Status Config ### Blacklist Nodes 1. Pilih node yang ada di node list admin page - - ![Nodes List](https://usercontent.catto.pictures/hirzi/5699fdbd-7c3c-4fa5-ae2c-d0ccb39cb69e.png) + + Nodes List 2. Cek urlnya dan copy id nodenya - ![Node Id](https://usercontent.catto.pictures/hirzi/45f855fc-6d96-4b23-a96e-892071189d01.png) + Node Id 3. Masukan ke blacklist di config - ![Blacklist Config](https://usercontent.catto.pictures/hirzi/9c40da3d-fa01-447e-aa86-7871da9da282.png) + Blacklist Config Kamu bisa memasukan lebih dari 1 node untuk di blacklist -![Blacklist Config](https://usercontent.catto.pictures/hirzi/f2a34ca9-accf-4d31-a246-f9dcc6a2fd75.png) +Blacklist Config ## Permission apikey -Pilih Aktifkan `read` di semua opsi permission, jika tetap error pilih `read & write` di semua opsi permission +Jika kamu mengalami error 403 coba aktifkan `read & write` di semua opsi permission -![Application API Permission](https://media.discordapp.net/attachments/819757140155564062/876320084992331816/Screenshot_2021-08-15-11-20-05-56.jpg) +Application API Permission ## Links diff --git a/README.md b/README.md index 88d5880..2a46ba9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@
-![PteroStats Banner](https://cdn.discordapp.com/attachments/626755594526916629/978478722489393153/20220524_090325.png) +PteroStats Banner ## Language / Bahasa [[English]](https://github.com/HirziDevs/PteroStats/blob/dev/README.md) | [[Indonesia]](https://github.com/HirziDevs/PteroStats/blob/dev/Indo.md) @@ -10,91 +10,109 @@ ## Introduction PteroStats is a bot designed to check Pterodactyl Panel and Nodes status and post it to your discord server +## Example +Example + ## Installation -- [Getting apikey from pterodactyl](#getting-apikey-from-pterodactyl) -- [Creating Discord Bot](#creating-discord-bot) -- [Inviting Discord Bot](#inviting-discord-bot) -- [Getting Channel ID](#getting-channel-id) -- [Starting bot](#starting-bot) +1. [Getting apikey from pterodactyl](#getting-apikey-from-pterodactyl) +2. [Creating Discord Bot](#creating-discord-bot) +3. [Inviting Discord Bot](#inviting-discord-bot) +4. [Getting Channel ID](#getting-channel-id) +5. [Starting bot](#starting-bot) + - [Using Custom Emoji](#using-custom-emoji) - [Blacklist Nodes](#blacklist-nodes) ### Getting apikey from pterodactyl -- Go to your `pterodactyl admin page` and go to `Application API`. +1. Go to your `pterodactyl admin page` and go to `Application API`. - ![Admin Panel](https://usercontent.catto.pictures/hirzi/aabafe57-cbfe-4d7f-9d6d-4a63a7f23d4c.png) + Admin Panel -- Click on the `Create New` button +2. Click on the `Create New` button - ![Application API Page](https://usercontent.catto.pictures/hirzi/f916f0c6-0968-4125-8226-ba4daa1de902.png) + Application API Page -- Set all options permission to `read` and for description you can put whatever you want +3. Set all options permission to `read` and for description you can put whatever you want - ![Create Application API](https://usercontent.catto.pictures/hirzi/3e4575cb-4f52-4bd9-9091-36fda20bedad.png) + Create Application API -- Copy the apikey. +4. Copy the apikey. - ![Application API List](https://usercontent.catto.pictures/hirzi/9142b0b3-0556-4741-840c-6976c3fe3ad4.png) + Application API List + +5. Paste the panel apikey and panel url at the config + + Panel Config ### Creating Discord Bot Please refer to [this website](https://discordjs.guide/preparations/setting-up-a-bot-application.html) +Paste the bot token at the config + +Bot Config + ### Inviting Discord Bot Please refer to [this website](https://discordjs.guide/preparations/adding-your-bot-to-servers.html) ### Getting Channel ID 1. Enable Developer Feature at your discord settings - ![Discord User Settings](https://usercontent.catto.pictures/hirzi/c5e825d1-c323-4b19-a11b-e2f004d4906e.png) + Discord User Settings 2. Right Click text channel and select `Copy ID` - ![Right Click Channel](https://usercontent.catto.pictures/hirzi/e5fa4f62-b28f-45fd-a544-429f23899edb.png) + Right Click Channel + +3. Paste the channel id at the config + + Channel Config ### Starting bot -- Put discord bot token in `config.yml` at `token line`. -- Put your pterodactyl `apikey` and `url` in `config.yml` at `panel line`. -- Copy `channel id` from your discord server and put it in `config.yml` file at `channel line`. -- Run `npm install` in the root directory of the bot files. -- Run `node index` and you are done. +1. Make sure you have done the things above +2. Run `npm install` in the root directory of the bot files. +3. Run `node index` and you are done. if you need help contact me on discord `Hirzi#8701` or join [our discord support server](https://discord.gg/zv6maQRah3) ### Using Custom Emoji 1. type `\` in guild that has custom emoji you want - ![Type \ on the chat](https://usercontent.catto.pictures/hirzi/1f59b255-7c5d-48f2-ab93-5358429cec83.png) + Type \ on the chat 2. Select custom emoji you want - ![Select Custom Emoji](https://usercontent.catto.pictures/hirzi/38098261-7257-4e4d-8945-4ac5c252c952.png) + Select Custom Emoji 3. Copy the text! - ![Copy Emoji ID](https://usercontent.catto.pictures/hirzi/33800ccf-9ed5-4d54-9747-2983b23e1755.png) + Copy Emoji ID + +4. Paste the emoji id at the config + + Status Config ### Blacklist Nodes 1. Select node from node list on admin page - - ![Nodes List](https://usercontent.catto.pictures/hirzi/5699fdbd-7c3c-4fa5-ae2c-d0ccb39cb69e.png) + + Nodes List 2. Check the url and copy the node id - ![Node Id](https://usercontent.catto.pictures/hirzi/45f855fc-6d96-4b23-a96e-892071189d01.png) + Node Id -3. Add the id to the blacklist on config +3. Paste the id to the blacklist on config - ![Blacklist Config](https://usercontent.catto.pictures/hirzi/9c40da3d-fa01-447e-aa86-7871da9da282.png) + Blacklist Config You can add more than one node in the blacklist -![Blacklist Config](https://usercontent.catto.pictures/hirzi/f2a34ca9-accf-4d31-a246-f9dcc6a2fd75.png) +Blacklist Config -## Admin Apikey Permission +## Apikey permission -enable `read` on all options, if still didn't work enable `read & write` on all options +If you having issue with 403 error try to enable `read & write` on all options -![Application API Permission](https://media.discordapp.net/attachments/819757140155564062/876320084992331816/Screenshot_2021-08-15-11-20-05-56.jpg) +Application API Permission ## Links diff --git a/events/ready.js b/events/ready.js index 234338e..fd993af 100644 --- a/events/ready.js +++ b/events/ready.js @@ -5,14 +5,14 @@ module.exports = { name: 'ready', once: true, execute(client) { - console.log(chalk.cyan('[PteroStats]') + chalk.green(' Bot is up!')) - console.log(chalk.cyan('[PteroStats]') + chalk.green(' If you need support you can join our discord server https://discord.gg/zv6maQRah3')) + console.log(chalk.cyan('[PteroStats] ') + chalk.green('Bot is up!')) + console.log(chalk.cyan('[PteroStats] ') + chalk.green('If you need support you can join our discord server https://discord.gg/zv6maQRah3')) - if (client.guilds.cache.size < 1) return console.log(chalk.cyan('[PteroStats]') + chalk.red(' There is bot is not in servers, please invite the bot first!')) + if (client.guilds.cache.size < 1) return console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! This bot is not on any discord servers')) if (client.config.bot_status.enable) { if (!['PLAYING', 'WATCHING', 'LISTENING', 'COMPETING'].includes(client.config.bot_status.type)) { - console.log('Invalid Status Type!, Can be "WATCHING", "PLAYING", "LISTENING", or "COMPETING"') + console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! Invalid Status Type!, Can be "WATCHING", "PLAYING", "LISTENING", or "COMPETING"')) } else { client.user.setActivity(client.config.bot_status.text, { type: client.config.bot_status.type }) } diff --git a/handlers/checkStatus.js b/handlers/checkStatus.js index 2f2f53e..06f5b08 100644 --- a/handlers/checkStatus.js +++ b/handlers/checkStatus.js @@ -6,17 +6,17 @@ const postStatus = require('./postStatus') module.exports = function checkStatus(client) { if (client.config.channel.startsWith('Put')) { - console.log(chalk.cyan('[PteroStats]') + chalk.red(' Err! Invalid Channel ID')) + console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! Invalid Channel ID')) process.exit() } else if (client.config.panel.url.startsWith('Put')) { - console.log(chalk.cyan('[PteroStats]') + chalk.red(' Err! Invalid Panel URL')) + console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! Invalid Panel URL')) process.exit() } else if (client.config.panel.key.startsWith('Put')) { - console.log(chalk.cyan('[PteroStats]') + chalk.red(' Err! Invalid Apikey')) + console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! Invalid Apikey')) process.exit() } else if (!client.config.panel.url.startsWith('http')) { - console.log(chalk.cyan('[PteroStats]') + chalk.red(' Err! Invalid Panel URL')) - console.log(chalk.cyan('[PteroStats]') + chalk.red(' 1. Make sure the panel url is starts with "https://" or "http://"')) + console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! Invalid Panel URL')) + console.log(chalk.cyan('[PteroStats] ') + chalk.red('1. Make sure the panel url is starts with "https://" or "http://"')) process.exit() } @@ -30,7 +30,7 @@ module.exports = function checkStatus(client) { total_users: -1, } - console.log(chalk.cyan('[PteroStats]') + chalk.green(' Getting nodes stats')) + console.log(chalk.cyan('[PteroStats] ') + chalk.green('Getting nodes stats')) const panelStats = new Promise((resolve, reject) => { axios(client.config.panel.url + '/api/application/users', { @@ -58,15 +58,15 @@ module.exports = function checkStatus(client) { }).catch((err) => { if (err.response) { if (err.response.status === 403) { - console.log(chalk.cyan('[PteroStats]') + chalk.red(' Err! Invalid apikey')) - console.log(chalk.cyan('[PteroStats]') + chalk.red(' 1. Make sure the apikey is from admin page not account page')) - console.log(chalk.cyan('[PteroStats]') + chalk.red(' 2. Make sure the apikey has read permission on all options')) - console.log(chalk.cyan('[PteroStats]') + chalk.red(' 3. Make sure the apikey is exist')) + console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! Invalid apikey')) + console.log(chalk.cyan('[PteroStats] ') + chalk.red('1. Make sure the apikey is from admin page not account page')) + console.log(chalk.cyan('[PteroStats] ') + chalk.red('2. Make sure the apikey has read permission on all options')) + console.log(chalk.cyan('[PteroStats] ') + chalk.red('3. Make sure the apikey is exist')) } else if (err.response.status === 404) { - console.log(chalk.cyan('[PteroStats]') + chalk.red(' Err! Invalid Panel URL')) - console.log(chalk.cyan('[PteroStats]') + chalk.red(' 1. Make sure the panel url is like "https://panel.example.com"')) - } else console.log(chalk.cyan('[PteroStats] ') + err) - } else console.log(chalk.cyan('[PteroStats] ') + err) + console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! Invalid Panel URL')) + console.log(chalk.cyan('[PteroStats] ') + chalk.red('1. Make sure the panel url is like "https://panel.example.com"')) + } else console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! ' + err)) + } else console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! ' + err)) resolve() }) }) diff --git a/handlers/postStatus.js b/handlers/postStatus.js index c738889..8483e95 100644 --- a/handlers/postStatus.js +++ b/handlers/postStatus.js @@ -7,11 +7,11 @@ module.exports = async function postStatus(client, panel, nodes) { if (!client.config.nodes_resource.blacklist) client.config.nodes_resource.blacklist = [] if (!Array.isArray(client.config.nodes_resource.blacklist) && Number.isInteger(client.config.nodes_resource.blacklist)) client.config.nodes_resource.blacklist = [client.config.nodes_resource.blacklist] - if (client.guilds.cache.size < 1) return console.log(chalk.cyan('[PteroStats]') + chalk.red(' This bot is not on any discord servers')) + if (client.guilds.cache.size < 1) return console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! This bot is not on any discord servers')) const channel = await client.channels.cache.get(client.config.channel) - if (!channel) return console.log(chalk.cyan('[PteroStats]') + chalk.red(' Invalid Channel ID')) + if (!channel) return console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! Invalid Channel ID')) let messages = await channel.messages.fetch({ limit: 10 }) messages = messages.filter(m => m.author.id === client.user.id).last(); @@ -162,6 +162,6 @@ module.exports = async function postStatus(client, panel, nodes) { if (!messages) channel.send({ embeds: [embed], components: row }) else messages.edit({ embeds: [embed], components: row }) - console.log(chalk.cyan('[PteroStats]') + chalk.green(' Stats posted!')) + console.log(chalk.cyan('[PteroStats] ') + chalk.green('Stats posted!')) }) } \ No newline at end of file