Use the guild max file size

This commit is contained in:
Supositware 2023-04-11 14:44:37 +02:00
parent d926931e37
commit d4e3693be6
4 changed files with 5 additions and 5 deletions

View file

@ -41,7 +41,7 @@ export default {
const file = fs.statSync(`${os.tmpdir()}/${args.audio.name}.png`); const file = fs.statSync(`${os.tmpdir()}/${args.audio.name}.png`);
const fileSize = (file.size / 1000000.0).toFixed(2); const fileSize = (file.size / 1000000.0).toFixed(2);
if (fileSize > 8) return interaction.editReply('error'); if (fileSize > utils.getMaxFileSize(interaction.guild)) return interaction.editReply('error');
interaction.editReply({ content: `Image file is ${fileSize} MB` }); interaction.editReply({ content: `Image file is ${fileSize} MB` });
return interaction.followUp({ files: [`${os.tmpdir()}/${args.audio.name}.png`] }); return interaction.followUp({ files: [`${os.tmpdir()}/${args.audio.name}.png`] });
}, },

View file

@ -40,7 +40,7 @@ export default {
const file = fs.statSync(`${os.tmpdir()}/${args.img.name}.mp3`); const file = fs.statSync(`${os.tmpdir()}/${args.img.name}.mp3`);
const fileSize = (file.size / 1000000.0).toFixed(2); const fileSize = (file.size / 1000000.0).toFixed(2);
if (fileSize > 8) return interaction.editReply('error'); if (fileSize > utils.getMaxFileSize(interaction.guild)) return interaction.editReply('error');
interaction.editReply({ content: `Audio file is ${fileSize} MB` }); interaction.editReply({ content: `Audio file is ${fileSize} MB` });
return interaction.followUp({ files: [`${os.tmpdir()}/${args.img.name}.mp3`] }); return interaction.followUp({ files: [`${os.tmpdir()}/${args.img.name}.mp3`] });
}, },

View file

@ -182,7 +182,7 @@ async function download(url, interaction, originalInteraction) {
await interaction.deleteReply(); await interaction.deleteReply();
await interaction.followUp('Uh oh! The video you tried to download is too big!', { ephemeral: true }); await interaction.followUp('Uh oh! The video you tried to download is too big!', { ephemeral: true });
} }
else if (fileSize > 8) { else if (fileSize > utils.getMaxFileSize(interaction.guild)) {
const fileurl = await utils.upload(output) const fileurl = await utils.upload(output)
.catch(err => { .catch(err => {
console.error(err); console.error(err);
@ -212,7 +212,7 @@ async function compress(input, interaction, embed) {
const fileStat = fs.statSync(`${os.tmpdir()}/${output}`); const fileStat = fs.statSync(`${os.tmpdir()}/${output}`);
const fileSize = fileStat.size / 1000000.0; const fileSize = fileStat.size / 1000000.0;
if (fileSize > 8) { if (fileSize > utils.getMaxFileSize(interaction.guild)) {
await interaction.editReply({ content: 'File was bigger than 8 mb. but due to the compression it is not being uploaded externally.', ephemeral: true }); await interaction.editReply({ content: 'File was bigger than 8 mb. but due to the compression it is not being uploaded externally.', ephemeral: true });
} }
else { else {

View file

@ -46,7 +46,7 @@ export default {
await interaction.deleteReply(); await interaction.deleteReply();
await interaction.followUp('❌ Uh oh! The video once converted is too big!', { ephemeral: true }); await interaction.followUp('❌ Uh oh! The video once converted is too big!', { ephemeral: true });
} }
else if (fileSize > 8) { else if (fileSize > utils.getMaxFileSize(interaction.guild)) {
const fileURL = await utils.upload(gifsicleOutput) const fileURL = await utils.upload(gifsicleOutput)
.catch(err => { .catch(err => {
console.error(err); console.error(err);