Compare commits
No commits in common. "591652f33ff55368e9788938b37e03a75adb76b6" and "162a91ca481106c7fc2c724cad3b069328f5bf3f" have entirely different histories.
591652f33f
...
162a91ca48
11 changed files with 38 additions and 126 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -10,7 +10,3 @@ bin/yt-dlp
|
||||||
bin/HandBrakeCLI
|
bin/HandBrakeCLI
|
||||||
bin/upload.sh
|
bin/upload.sh
|
||||||
bin/dectalk
|
bin/dectalk
|
||||||
|
|
||||||
asset/ytp/sources
|
|
||||||
asset/ytp/music
|
|
||||||
asset/ytp/sounds
|
|
|
@ -56,7 +56,7 @@ export default {
|
||||||
return interaction.editReply('successfully deleted the following tag: ' + args.trigger);
|
return interaction.editReply('successfully deleted the following tag: ' + args.trigger);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return interaction.editReply(`You are not the owner of this tag, if you think it is problematic ask a user with the 'Administrator' permission to remove it by doing ${this.client.commandHandler.prefix[0]}tag ${args.trigger} --remove`);
|
return interaction.editReply(`You are not the owner of this tag, if you think it is problematic ask an admin to remove it by doing ${this.client.commandHandler.prefix[0]}tag ${args.trigger} --remove`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -43,7 +43,7 @@ export default {
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
user.send({ embeds: [Embed] });
|
user.send({ embeds: [Embed] });
|
||||||
return interaction.reply({ content: `DM sent to ${user.username} (${user.id})` });
|
return interaction.reply({ content: `DM sent to ${user.username}` });
|
||||||
/*
|
/*
|
||||||
const Attachment = (message.attachments).array();
|
const Attachment = (message.attachments).array();
|
||||||
if (Attachment[0]) {
|
if (Attachment[0]) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ export default {
|
||||||
|
|
||||||
const streamPipeline = util.promisify(stream.pipeline);
|
const streamPipeline = util.promisify(stream.pipeline);
|
||||||
const res = await fetch(args.file.url);
|
const res = await fetch(args.file.url);
|
||||||
if (!res.ok) return interaction.editReply('An error has occured while trying to download the command.');
|
if (!res.ok) return interaction.editReply('An error has occured while trying to download your image.');
|
||||||
await streamPipeline(res.body, fs.createWriteStream(`./tmp/${args.file.name}`));
|
await streamPipeline(res.body, fs.createWriteStream(`./tmp/${args.file.name}`));
|
||||||
|
|
||||||
let command = await import(`../../tmp/${args.file.name}`);
|
let command = await import(`../../tmp/${args.file.name}`);
|
||||||
|
|
|
@ -34,10 +34,10 @@ export default {
|
||||||
Blacklists.create(body);
|
Blacklists.create(body);
|
||||||
let user = userid;
|
let user = userid;
|
||||||
await client.users.fetch(userid);
|
await client.users.fetch(userid);
|
||||||
user = client.users.resolve(userid).username;
|
user = client.users.resolve(userid).tag;
|
||||||
|
|
||||||
|
|
||||||
return interaction.editReply(`${user} (${userid}) has been blacklisted from ${command} with the following reason \`${reason}\``);
|
return interaction.editReply(`${user} has been blacklisted from ${command} with the following reason \`${reason}\``);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const row = new ActionRowBuilder()
|
const row = new ActionRowBuilder()
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default {
|
||||||
for (let i = 0; i < Donator.length; i++) {
|
for (let i = 0; i < Donator.length; i++) {
|
||||||
const user = await client.users.fetch(Donator[i].get('userID').toString());
|
const user = await client.users.fetch(Donator[i].get('userID').toString());
|
||||||
if (user !== null) {
|
if (user !== null) {
|
||||||
description += `**${user.username} (${user.id}) | ${Donator[i].get('comment')}**\n`;
|
description += `**${user.tag} (${user.id}) | ${Donator[i].get('comment')}**\n`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
description += `**A user of discord (${user.id}) | ${Donator[i].get('comment')} (This user no longer share a server with the bot)**\n`;
|
description += `**A user of discord (${user.id}) | ${Donator[i].get('comment')} (This user no longer share a server with the bot)**\n`;
|
||||||
|
@ -36,26 +36,26 @@ export default {
|
||||||
description += 'No one :(\n';
|
description += 'No one :(\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
description += `\nThanks to ${tina.username} (336492042299637771) for inspiring me for making this bot!`;
|
description += `\nThanks to ${tina.tag} (336492042299637771) for inspiring me for making this bot!`;
|
||||||
|
|
||||||
// description += '\nThanks to Jetbrains for providing their IDE!';
|
// description += '\nThanks to Jetbrains for providing their IDE!';
|
||||||
|
|
||||||
exec('git rev-parse --short HEAD', (err, stdout) => {
|
exec('git rev-parse --short HEAD', (err, stdout) => {
|
||||||
const aboutEmbed = new EmbedBuilder()
|
const aboutEmbed = new EmbedBuilder()
|
||||||
.setColor(interaction.member ? interaction.member.displayHexColor : 'Navy')
|
.setColor(interaction.member ? interaction.member.displayHexColor : 'Navy')
|
||||||
.setAuthor({ name: client.user.username, iconURL: client.user.displayAvatarURL(), url: 'https://libtar.de' })
|
.setAuthor({ name: client.user.tag, iconURL: client.user.displayAvatarURL(), url: 'https://libtar.de' })
|
||||||
.setTitle('About me')
|
.setTitle('About me')
|
||||||
.setDescription(description)
|
.setDescription(description)
|
||||||
.addFields(
|
.addFields(
|
||||||
{ name: 'Current commit', value: stdout },
|
{ name: 'Current commit', value: stdout },
|
||||||
{ name: 'Current maintainer', value: `${maintainer.username} (${ownerId})` },
|
{ name: 'Current maintainer', value: `${maintainer.tag} (${ownerId})` },
|
||||||
{ name: 'Gitea (Main)', value: 'https://git.namejeff.xyz/Supositware/Haha-Yes', inline: true },
|
{ name: 'Gitea (Main)', value: 'https://git.namejeff.xyz/Supositware/Haha-Yes', inline: true },
|
||||||
{ name: 'Github (Mirror)', value: 'https://github.com/Supositware/Haha-yes', inline: true },
|
{ name: 'Github (Mirror)', value: 'https://github.com/Supositware/Haha-yes', inline: true },
|
||||||
{ name: 'Privacy Policy', value: 'https://libtar.de/discordprivacy.txt', inline: true },
|
{ name: 'Privacy Policy', value: 'https://libtar.de/discordprivacy.txt', inline: true },
|
||||||
{ name: 'Status page', value: uptimePage.toString(), inline: true },
|
{ name: 'Status page', value: uptimePage.toString(), inline: true },
|
||||||
|
|
||||||
)
|
)
|
||||||
.setFooter({ text: `Original bot made by ${creator.username} (267065637183029248)` });
|
.setFooter({ text: `Original bot made by ${creator.tag} (267065637183029248)` });
|
||||||
|
|
||||||
interaction.reply({ embeds: [aboutEmbed] });
|
interaction.reply({ embeds: [aboutEmbed] });
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,17 +11,10 @@ export default {
|
||||||
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
||||||
|
|
||||||
const globalBlacklist = await db.Blacklists.findOne({ where: { type:'global', uid:interaction.user.id } });
|
const globalBlacklist = await db.Blacklists.findOne({ where: { type:'global', uid:interaction.user.id } });
|
||||||
// const serverBlacklist = await db.Blacklists.findOne({ where: { type:'guild', uid:interaction.guild.id } });
|
|
||||||
const commandBlacklist = await db.Blacklists.findOne({ where: { type:interaction.commandName, uid:interaction.user.id } });
|
const commandBlacklist = await db.Blacklists.findOne({ where: { type:interaction.commandName, uid:interaction.user.id } });
|
||||||
|
|
||||||
if (globalBlacklist) {
|
if (globalBlacklist) {
|
||||||
return interaction.reply({ content: `You are globally blacklisted for the following reason: \`${globalBlacklist.reason}\``, ephemeral: true });
|
return interaction.reply({ content: `You are globally blacklisted for the following reason: \`${globalBlacklist.reason}\``, ephemeral: true });
|
||||||
}
|
}
|
||||||
/* Server blacklist is untested
|
|
||||||
else if (serverBlacklist) {
|
|
||||||
return interaction.reply({ content: `This guild has been blacklisted for the following reason: \`${serverBlacklist.reason}\``, ephemeral: true });
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
else if (commandBlacklist) {
|
else if (commandBlacklist) {
|
||||||
return interaction.reply({ content: `You are blacklisted for the following reason: \`${commandBlacklist.reason}\``, ephemeral: true });
|
return interaction.reply({ content: `You are blacklisted for the following reason: \`${commandBlacklist.reason}\``, ephemeral: true });
|
||||||
}
|
}
|
||||||
|
@ -36,8 +29,12 @@ export default {
|
||||||
|
|
||||||
const isOptOut = await db.optout.findOne({ where: { userID: interaction.user.id } });
|
const isOptOut = await db.optout.findOne({ where: { userID: interaction.user.id } });
|
||||||
|
|
||||||
const timestamp = new Date();
|
if (isOptOut) {
|
||||||
console.log(`[${timestamp.toISOString()}] \x1b[33m${ isOptOut ? 'A user' : `${userTag} (${userID})`}\x1b[0m launched command \x1b[33m${commandName}\x1b[0m using slash`);
|
console.log(`A user launched command \x1b[33m${commandName}\x1b[0m using slash`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log(`\x1b[33m${userTag} (${userID})\x1b[0m launched command \x1b[33m${commandName}\x1b[0m using slash`);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Owner only check
|
// Owner only check
|
||||||
|
@ -67,18 +64,6 @@ export default {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Check if the limit of parallel execution has been reached
|
|
||||||
if (command.parallelLimit) {
|
|
||||||
console.log('Command has a parallel limit');
|
|
||||||
const doParallelLimit = ratelimiter.checkParallel(interaction.user, commandName, command);
|
|
||||||
console.log(doParallelLimit);
|
|
||||||
if (doParallelLimit) {
|
|
||||||
return await interaction.reply({ content: doParallelLimit, ephemeral: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
ratelimiter.addParallel(commandName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the ratelimit
|
// Check the ratelimit
|
||||||
const doRateLimit = ratelimiter.check(interaction.user, commandName, command);
|
const doRateLimit = ratelimiter.check(interaction.user, commandName, command);
|
||||||
if (doRateLimit) {
|
if (doRateLimit) {
|
||||||
|
@ -103,14 +88,10 @@ export default {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isOptOut) {
|
if (!isOptOut) {
|
||||||
console.log(`[${timestamp.toISOString()}] \x1b[33m⤷\x1b[0m with args ${JSON.stringify(args)}`);
|
console.log(`\x1b[33m⤷\x1b[0m with args ${JSON.stringify(args)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await command.execute(interaction, args, client)
|
await command.execute(interaction, args, client);
|
||||||
.then(() => {
|
|
||||||
const hasPrallelLimit = ratelimiter.checkParallel(interaction.user, commandName, command);
|
|
||||||
if (hasPrallelLimit) ratelimiter.removeParallel(commandName);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
|
@ -281,17 +281,11 @@ export default {
|
||||||
if (!command) return;
|
if (!command) return;
|
||||||
|
|
||||||
const globalBlacklist = await db.Blacklists.findOne({ where: { type:'global', uid:message.author.id } });
|
const globalBlacklist = await db.Blacklists.findOne({ where: { type:'global', uid:message.author.id } });
|
||||||
// const serverBlacklist = await db.Blacklists.findOne({ where: { type:'guild', uid:message.guild.id } });
|
|
||||||
const commandBlacklist = await db.Blacklists.findOne({ where: { type:commandName, uid:message.author.id } });
|
const commandBlacklist = await db.Blacklists.findOne({ where: { type:commandName, uid:message.author.id } });
|
||||||
|
|
||||||
if (globalBlacklist) {
|
if (globalBlacklist) {
|
||||||
return message.reply({ content: `You are globally blacklisted for the following reason: \`${globalBlacklist.reason}\``, ephemeral: true });
|
return message.reply({ content: `You are globally blacklisted for the following reason: \`${globalBlacklist.reason}\``, ephemeral: true });
|
||||||
}
|
}
|
||||||
/* Server blacklist is untested
|
|
||||||
else if (serverBlacklist) {
|
|
||||||
return message.reply({ content: `This guild has been blacklisted for the following reason: \`${serverBlacklist.reason}\``, ephemeral: true });
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
else if (commandBlacklist) {
|
else if (commandBlacklist) {
|
||||||
return message.reply({ content: `You are blacklisted for the following reason: \`${commandBlacklist.reason}\``, ephemeral: true });
|
return message.reply({ content: `You are blacklisted for the following reason: \`${commandBlacklist.reason}\``, ephemeral: true });
|
||||||
}
|
}
|
||||||
|
@ -301,9 +295,12 @@ export default {
|
||||||
|
|
||||||
const isOptOut = await db.optout.findOne({ where: { userID: message.author.id } });
|
const isOptOut = await db.optout.findOne({ where: { userID: message.author.id } });
|
||||||
|
|
||||||
const timestamp = new Date();
|
if (isOptOut) {
|
||||||
console.log(`[${timestamp.toISOString()}] \x1b[33m${ isOptOut ? 'A user' : `${userTag} (${userID})`}\x1b[0m launched command \x1b[33m${commandName}\x1b[0m using slash`);
|
console.log(`A user launched command \x1b[33m${commandName}\x1b[0m using prefix`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log(`\x1b[33m${userTag} (${userID})\x1b[0m launched command \x1b[33m${commandName}\x1b[0m using prefix`);
|
||||||
|
}
|
||||||
|
|
||||||
// Owner only check
|
// Owner only check
|
||||||
if (command.ownerOnly && message.author.id !== ownerId) {
|
if (command.ownerOnly && message.author.id !== ownerId) {
|
||||||
|
@ -330,18 +327,6 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the limit of parallel execution has been reached
|
|
||||||
if (command.parallelLimit) {
|
|
||||||
console.log('Command has a parallel limit');
|
|
||||||
const doParallelLimit = ratelimiter.checkParallel(message.author, commandName, command);
|
|
||||||
console.log(doParallelLimit);
|
|
||||||
if (doParallelLimit) {
|
|
||||||
return await message.reply({ content: doParallelLimit, ephemeral: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
ratelimiter.addParallel(commandName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the ratelimit
|
// Check the ratelimit
|
||||||
const doRateLimit = ratelimiter.check(message.author, commandName, command);
|
const doRateLimit = ratelimiter.check(message.author, commandName, command);
|
||||||
if (doRateLimit) {
|
if (doRateLimit) {
|
||||||
|
@ -426,14 +411,10 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isOptOut && argsLength > 0) {
|
if (!isOptOut && argsLength > 0) {
|
||||||
console.log(`[${timestamp.toISOString()}]\x1b[33m⤷\x1b[0m with args ${JSON.stringify(args)}`);
|
console.log(`\x1b[33m⤷\x1b[0m with args ${JSON.stringify(args)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await command.execute(message, args, client)
|
await command.execute(message, args, client);
|
||||||
.then(() => {
|
|
||||||
const hasPrallelLimit = ratelimiter.checkParallel(message.author, commandName, command);
|
|
||||||
if (hasPrallelLimit) ratelimiter.removeParallel(commandName);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
|
@ -23,11 +23,11 @@ async function download(url, output) {
|
||||||
fs.renameSync(tmpPath, path);
|
fs.renameSync(tmpPath, path);
|
||||||
fs.chmodSync(path, '755');
|
fs.chmodSync(path, '755');
|
||||||
console.log(`${url} download finished.`);
|
console.log(`${url} download finished.`);
|
||||||
return resolve(true);
|
resolve(true);
|
||||||
});
|
});
|
||||||
filePath.on('error', (err) => {
|
filePath.on('error', (err) => {
|
||||||
filePath.close();
|
filePath.close();
|
||||||
return reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
// This is kind of useless since you can just do `./yt-dlp --update-to nightly` which I didn't know about when I wrote that.
|
|
||||||
import utils from './downloadutils.js';
|
import utils from './downloadutils.js';
|
||||||
|
|
||||||
(async () => {
|
if (process.platform !== 'linux' && process.argv[2] !== '-f') {
|
||||||
if (process.platform !== 'linux' && process.argv[2] !== '-f') {
|
console.error('This script only download the linux version of yt-dlp. If you want to download anyway try again with -f');
|
||||||
console.error('This script only download the linux version of yt-dlp. If you want to download anyway try again with -f or execute ./bin/yt-dlp --update-to nightly');
|
process.exit(1);
|
||||||
process.exit(1);
|
}
|
||||||
}
|
else if (process.platform !== 'linux' && process.argv[2] === '-f') {
|
||||||
else if (process.platform !== 'linux' && process.argv[2] === '-f') {
|
console.log('Executed with -f. Reminder that this script only download the linux version of yt-dlp.');
|
||||||
console.log('Executed with -f. Reminder that this script only download the linux version of yt-dlp.');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const downloadUrl = 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp';
|
const downloadUrl = 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp';
|
||||||
|
|
||||||
await utils.download(downloadUrl, './bin/yt-dlp');
|
utils.download(downloadUrl, './bin/yt-dlp');
|
||||||
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
const ratelimit = {};
|
const ratelimit = {};
|
||||||
const parallelLimit = {};
|
|
||||||
const { ownerId } = process.env;
|
const { ownerId } = process.env;
|
||||||
|
|
||||||
import db from '../models/index.js';
|
import db from '../models/index.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
check,
|
check,
|
||||||
addParallel,
|
|
||||||
removeParallel,
|
|
||||||
checkParallel,
|
|
||||||
};
|
};
|
||||||
function check(user, commandName, commands) {
|
function check(user, commandName, commands) {
|
||||||
const userID = user.id;
|
const userID = user.id;
|
||||||
|
@ -57,41 +53,3 @@ function check(user, commandName, commands) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addParallel(commandName) {
|
|
||||||
// console.log(`[ADD] Adding parallel to ${commandName}`);
|
|
||||||
if (!parallelLimit[commandName]) parallelLimit[commandName] = 0;
|
|
||||||
|
|
||||||
const prevNumber = parallelLimit[commandName];
|
|
||||||
|
|
||||||
// console.log(`[ADD] Previous parallel executions: ${prevNumber}`);
|
|
||||||
// console.log(`[ADD] Current parallel executions: ${JSON.stringify(parallelLimit)}`);
|
|
||||||
parallelLimit[commandName] = prevNumber + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeParallel(commandName) {
|
|
||||||
// console.log(`[REMOVE] Removing parallel to ${commandName}`);
|
|
||||||
|
|
||||||
// This shouldn't be possible
|
|
||||||
if (!parallelLimit[commandName]) parallelLimit[commandName] = 0;
|
|
||||||
|
|
||||||
const prevNumber = parallelLimit[commandName];
|
|
||||||
|
|
||||||
// console.log(`[REMOVE] previous number: ${prevNumber}`);
|
|
||||||
// console.log(`[REMOVE] previous parallel limit: ${JSON.stringify(parallelLimit)}`);
|
|
||||||
parallelLimit[commandName] = prevNumber - 1;
|
|
||||||
// console.log(`[REMOVE] current parallel limit: ${JSON.stringify(parallelLimit)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkParallel(user, commandName, command) {
|
|
||||||
// Don't apply the rate limit to bot owner
|
|
||||||
if (user.id === ownerId) return false;
|
|
||||||
|
|
||||||
// console.log(`[CHECK] command limit: ${command.parallelLimit}`);
|
|
||||||
// console.log(`[CHECK] current parallel executions: ${parallelLimit[commandName]}`);
|
|
||||||
if (parallelLimit[commandName] >= command.parallelLimit) {
|
|
||||||
return 'There are currently too many parallel execution of this command, please wait before retrying.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
Loading…
Reference in a new issue