Compare commits
4 commits
bd4dcd087e
...
6a9425eccc
Author | SHA1 | Date | |
---|---|---|---|
6a9425eccc | |||
1991925213 | |||
0f72e8c180 | |||
64988e340f |
6 changed files with 57 additions and 3 deletions
2
.github/ISSUE_TEMPLATE/bug.md
vendored
2
.github/ISSUE_TEMPLATE/bug.md
vendored
|
@ -33,5 +33,5 @@ labels:
|
|||
|
||||
**Did someone already report that bug?**
|
||||
|
||||
- [ ] Yes <!-- If you have to put yes you don't need to submit that feature request. -->
|
||||
- [ ] Yes <!-- If you have to put yes you don't need to submit that bug report. -->
|
||||
- [ ] No
|
||||
|
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,7 +1,8 @@
|
|||
.env
|
||||
node_modules/
|
||||
bin/
|
||||
config/config.json
|
||||
json/board/
|
||||
unloaded/
|
||||
database.sqlite3
|
||||
database.sqlite3
|
||||
bin/yt-dlp
|
||||
tmp/*.js
|
0
bin/.keep
Normal file
0
bin/.keep
Normal file
30
commands/owner/download&load.js
Normal file
30
commands/owner/download&load.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import util from 'node:util';
|
||||
import stream from 'node:stream';
|
||||
import fs from 'node:fs';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('downloadandload')
|
||||
.setDescription('Download a command and load it.')
|
||||
.addAttachmentOption(option =>
|
||||
option.setName('file')
|
||||
.setDescription('The .js file that will be loaded by the bot.')
|
||||
.setRequired(true)),
|
||||
category: 'owner',
|
||||
ownerOnly: true,
|
||||
async execute(interaction, args, client) {
|
||||
await interaction.deferReply();
|
||||
|
||||
const streamPipeline = util.promisify(stream.pipeline);
|
||||
const res = await fetch(args.file.url);
|
||||
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}`));
|
||||
|
||||
let command = await import(`../../tmp/${args.file.name}`);
|
||||
command = command.default;
|
||||
|
||||
client.commands.set(command.data.name, command);
|
||||
return await interaction.editReply(`${command.data.name} has been loaded.`);
|
||||
},
|
||||
};
|
0
tmp/.keep
Normal file
0
tmp/.keep
Normal file
|
@ -9,6 +9,7 @@ export default {
|
|||
stringIsAValidurl,
|
||||
compressVideo,
|
||||
getVideoCodec,
|
||||
getMaxFileSize,
|
||||
};
|
||||
async function downloadVideo(urlArg, output, format = 'bestvideo*+bestaudio/best') {
|
||||
await new Promise((resolve, reject) => {
|
||||
|
@ -90,4 +91,26 @@ async function getVideoCodec(input) {
|
|||
resolve(stdout.trim());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function getMaxFileSize(guild) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
const tier = guild.premiumTier;
|
||||
console.log(tier);
|
||||
switch (tier) {
|
||||
case 0:
|
||||
case 1:
|
||||
resolve(8);
|
||||
break;
|
||||
case 2:
|
||||
resolve('50');
|
||||
break;
|
||||
case 3:
|
||||
resolve('100');
|
||||
break;
|
||||
default:
|
||||
reject('An error has occured');
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue