Compare commits

...

5 commits

Author SHA1 Message Date
13077b1784 remove things 2022-06-16 13:29:30 +02:00
c7922c31b0 Log commands 2022-06-16 13:29:23 +02:00
41ee5a74a6 Status page for uptime kuma 2022-06-16 13:29:07 +02:00
49b7b73938 Make the embed match the old one 2022-06-16 13:28:53 +02:00
9762f21a13 Rename to deploy-guild-commands.js 2022-06-16 13:28:31 +02:00
7 changed files with 24 additions and 9 deletions

View file

@ -1,3 +1,5 @@
token=your.token token=your.token
clientId=botClientId clientId=botClientId
guildId=DevGuildId guildId=DevGuildId
uptimeURL=uptimeKumaOrWhateverStatusThingYouUseOrJustLeaveEmpty
uptimeInterval=60

View file

@ -85,7 +85,7 @@ async function download(url, interaction) {
const Embed = new MessageEmbed() const Embed = new MessageEmbed()
.setColor(interaction.member ? interaction.member.displayHexColor : 'NAVY') .setColor(interaction.member ? interaction.member.displayHexColor : 'NAVY')
.setAuthor(`Downloaded by ${interaction.member.displayName}`, interaction.member.displayAvatarURL(), url) .setAuthor(`Downloaded by ${interaction.member.displayName}`, interaction.member.displayAvatarURL(), url)
.setDescription(url); .setFooter(`You can get the original video by clicking on the "Downloaded by ${interaction.member.displayName}" message!`);
if (interaction.customId === 'downloadQuality') { if (interaction.customId === 'downloadQuality') {
format = interaction.values[0]; format = interaction.values[0];

View file

@ -6,6 +6,8 @@ module.exports = {
const command = client.commands.get(interaction.commandName); const command = client.commands.get(interaction.commandName);
console.log(`\x1b[33m${interaction.user.tag}\x1b[0m launched command \x1b[33m${interaction.commandName}\x1b[0m`);
if (!command) return; if (!command) return;
try { try {

View file

@ -1,4 +1,7 @@
const { exec } = require('node:child_process'); const { exec } = require('node:child_process');
const https = require('node:https');
require('dotenv').config();
const { uptimeURL, uptimeInterval } = process.env;
module.exports = { module.exports = {
name: 'ready', name: 'ready',
@ -15,6 +18,7 @@ module.exports = {
resolve(stdout); resolve(stdout);
}); });
}); });
const commandSize = client.commands.size; const commandSize = client.commands.size;
const clientTag = client.user.tag; const clientTag = client.user.tag;
const guildSize = client.guilds.cache.size; const guildSize = client.guilds.cache.size;
@ -26,7 +30,19 @@ module.exports = {
console.log(`Ready to serve in \x1b[33m${channelSize}\x1b[0m channels on \x1b[33m${guildSize}\x1b[0m servers.`); console.log(`Ready to serve in \x1b[33m${channelSize}\x1b[0m channels on \x1b[33m${guildSize}\x1b[0m servers.`);
console.log(`${client.readyAt}`); console.log(`${client.readyAt}`);
console.log(`There is \x1b[33m${commandSize}\x1b[0m command loaded.`); console.log(`There is \x1b[33m${commandSize}\x1b[0m command loaded.`);
console.log(`Running yt-dlp \x1b[33m${ytdlpVersion}\x1b[0m`); console.log(`Running yt-dlp \x1b[33m${ytdlpVersion.replace('\n', '')}\x1b[0m`);
console.log('===========[ READY ]==========='); console.log('===========[ READY ]===========');
if (uptimeURL != '') {
pingStatus(client, 'Starting up');
setInterval(() => {
pingStatus(client, 'OK');
}, uptimeInterval * 1000);
}
}, },
}; };
async function pingStatus(client, msg) {
https.get(`${uptimeURL}msg=${msg}&ping=${Math.round(client.ws.ping)}`);
}

View file

@ -1,11 +1,9 @@
// Require the necessary discord.js classes
const fs = require('node:fs'); const fs = require('node:fs');
const path = require('node:path'); const path = require('node:path');
const { Client, Collection, Intents } = require('discord.js'); const { Client, Collection, Intents } = require('discord.js');
require('dotenv').config(); require('dotenv').config();
const { token } = process.env; const { token } = process.env;
// Create a new client instance
const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
// Load commands from the commands folder // Load commands from the commands folder
@ -16,8 +14,6 @@ const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('
for (const file of commandFiles) { for (const file of commandFiles) {
const filePath = path.join(commandsPath, file); const filePath = path.join(commandsPath, file);
const command = require(filePath); const command = require(filePath);
// Set a new item in the Collection
// With the key as the command name and the value as the exported module
client.commands.set(command.data.name, command); client.commands.set(command.data.name, command);
} }
@ -37,5 +33,4 @@ for (const file of eventFiles) {
} }
} }
// Login to Discord with your client's token
client.login(token); client.login(token);

View file

@ -23,7 +23,7 @@ git checkout slash
npm install npm install
``` ```
To run the bot for the first time you need to execute [deploy-commands.js](deploy-commands.js) so the commands can be registered, don't forget to set your .env accordingly. To run the bot for the first time you need to execute [deploy-guild-commands.js](deploy-guild-commands.js) so the commands can be registered, don't forget to set your .env accordingly.
``node deploy-commands.js`` ``node deploy-commands.js``
then you can just run it normally. then you can just run it normally.