Compare commits

..

3 commits

Author SHA1 Message Date
92c91928e7 user avatar 2022-09-14 21:31:38 +02:00
6c49cc548c fetch members 2022-09-14 21:31:31 +02:00
5a6f785c61 Automatically get the commands for deploy 2022-09-14 21:31:25 +02:00
5 changed files with 98 additions and 288 deletions

View file

@ -20,6 +20,7 @@ export default {
clientPermissions: [ PermissionFlagsBits.ManageWebhooks ], clientPermissions: [ PermissionFlagsBits.ManageWebhooks ],
async execute(interaction, args) { async execute(interaction, args) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
await interaction.guild.members.fetch();
const member = args.user; const member = args.user;
const message = args.message; const message = args.message;
const attachment = args.image; const attachment = args.image;

View file

@ -0,0 +1,49 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
export default {
data: new SlashCommandBuilder()
.setName('avatar')
.setDescription('Show user avatar')
.addMentionableOption(option =>
option.setName('member')
.setDescription('Who do you want to fake?')
.setRequired(false)),
category: 'utility',
async execute(interaction, args) {
const avatarEmbed = new EmbedBuilder()
.setColor(interaction.member ? interaction.member.displayHexColor : 'Navy')
.setTitle('Avatar');
if (!args.member) {
const format = interaction.user.displayAvatarURL({ dynamic: true }).substr(interaction.user.displayAvatarURL({ dynamic: true }).length - 3);
if (format == 'gif') {
avatarEmbed.setAuthor({ name: interaction.user.username });
avatarEmbed.setDescription(`[gif](${interaction.user.displayAvatarURL({ format: 'gif', size: 2048 })})`);
avatarEmbed.setImage(interaction.user.displayAvatarURL({ format: 'gif', size: 2048 }));
}
else {
avatarEmbed.setAuthor({ name: interaction.user.username });
avatarEmbed.setDescription(`[png](${interaction.user.displayAvatarURL({ format: 'png', size: 2048 })}) | [jpeg](${interaction.user.displayAvatarURL({ format: 'jpg', size: 2048 })}) | [webp](${interaction.user.displayAvatarURL({ format: 'webp', size: 2048 })})`);
avatarEmbed.setImage(interaction.user.displayAvatarURL({ format: 'png', size: 2048 }));
}
return interaction.reply({ embeds: [avatarEmbed] });
}
else {
await interaction.guild.members.fetch();
const format = args.member.displayAvatarURL({ dynamic: true }).substr(args.member.displayAvatarURL({ dynamic: true }).length - 3);
if (format == 'gif') {
avatarEmbed.setAuthor({ name: args.member.user.username });
avatarEmbed.setDescription(`[gif](${args.member.displayAvatarURL({ format: 'gif', size: 2048 })})`);
avatarEmbed.setImage(args.member.displayAvatarURL({ format: 'gif', size: 2048 }));
}
else {
avatarEmbed.setAuthor({ name: args.member.user.username });
avatarEmbed.setDescription(`[png](${args.member.displayAvatarURL({ format: 'png', size: 2048 })}) | [jpeg](${args.member.displayAvatarURL({ format: 'jpg', size: 2048 })}) | [webp](${args.member.displayAvatarURL({ format: 'webp', size: 2048 })})`);
avatarEmbed.setImage(args.member.displayAvatarURL({ format: 'png', size: 2048 }));
}
return interaction.reply({ embeds: [avatarEmbed] });
}
},
};

View file

@ -1,246 +0,0 @@
const { SlashCommandBuilder } = require('discord.js');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { PermissionFlagsBits } = require('discord.js');
require('dotenv').config();
const { clientId, guildId, token } = process.env;
const commands = [
new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with pong!'),
new SlashCommandBuilder()
.setName('download')
.setDescription('Download a video.')
.addStringOption(option =>
option.setName('url')
.setDescription('url of the video you want to download.')
.setRequired(true))
.addBooleanOption(option =>
option.setName('format')
.setDescription('Choose the quality of the video.')
.setRequired(false))
.addBooleanOption(option =>
option.setName('compress')
.setDescription('Compress the video?')
.setRequired(false)),
new SlashCommandBuilder()
.setName('reddit')
.setDescription('Send random images from the subreddit you choose')
.addStringOption(option =>
option.setName('subreddit')
.setDescription('The subreddit you wish to see')
.setRequired(true)),
new SlashCommandBuilder()
.setName('vid2gif')
.setDescription('Convert your video into a gif.')
.addStringOption(option =>
option.setName('url')
.setDescription('URL of the video you want to convert')
.setRequired(true)),
new SlashCommandBuilder()
.setName('feedback')
.setDescription('Send a feedback to the developer.')
.addStringOption(option =>
option.setName('feedback')
.setDescription('The message you want to send me.')
.setRequired(true))
.addAttachmentOption(option =>
option.setName('image')
.setDescription('Optional attachment.')
.setRequired(false)),
new SlashCommandBuilder()
.setName('inspirobot')
.setDescription('Get an image from inspirobot'),
new SlashCommandBuilder()
.setName('tweet')
.setDescription('Send tweet from Haha yes twitter account. Please do not use it for advertisement and keep it english')
.addStringOption(option =>
option.setName('content')
.setDescription('The content of the tweet you want to send me.')
.setRequired(false))
.addAttachmentOption(option =>
option.setName('image')
.setDescription('Optional attachment (Image only.)')
.setRequired(false)),
new SlashCommandBuilder()
.setName('4chan')
.setDescription('Send random images from a 4chan board of your choosing!')
.addStringOption(option =>
option.setName('board')
.setDescription('The board you wish to see')
.setRequired(true)),
new SlashCommandBuilder()
.setName('donator')
.setDescription('All the people who donated for this bot <3'),
new SlashCommandBuilder()
.setName('donate')
.setDescription('Show donation link for the bot.'),
new SlashCommandBuilder()
.setName('about')
.setDescription('About me (The bot)'),
new SlashCommandBuilder()
.setName('stats')
.setDescription('Show some stats about the bot'),
new SlashCommandBuilder()
.setName('fakeuser')
.setDescription('Fake a user with webhooks')
.addMentionableOption(option =>
option.setName('user')
.setDescription('Who do you want to fake?')
.setRequired(true))
.addStringOption(option =>
option.setName('message')
.setDescription('What message do you want me to send?')
.setRequired(true))
.addAttachmentOption(option =>
option.setName('image')
.setDescription('Optional attachment (Image only.)')
.setRequired(false)),
new SlashCommandBuilder()
.setName('s')
.setDescription('What could this be 🤫')
.addStringOption(option =>
option.setName('something')
.setDescription('🤫')
.setRequired(true))
.addStringOption(option =>
option.setName('somethingelse')
.setDescription('🤫')
.setRequired(false)),
new SlashCommandBuilder()
.setName('die')
.setDescription('Kill the bot'),
new SlashCommandBuilder()
.setName('ublacklist')
.setDescription('Blacklist a user from the bot')
.addStringOption(option =>
option.setName('command')
.setDescription('Which command do you want to get a user blacklisted from?')
.setRequired(true))
.addStringOption(option =>
option.setName('userid')
.setDescription('Who do you want to blacklist?')
.setRequired(true))
.addStringOption(option =>
option.setName('reason')
.setDescription('The reason of the blacklist.')
.setRequired(false)),
new SlashCommandBuilder()
.setName('deletetweet')
.setDescription('Delete a tweet')
.addStringOption(option =>
option.setName('tweetid')
.setDescription('The id of the tweet you wish to delete.')
.setRequired(true)),
new SlashCommandBuilder()
.setName('autoresponse')
.setDescription('Enable or disable autoresponse')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
new SlashCommandBuilder()
.setName('bye')
.setDescription('Set a leave message')
.addStringOption(option =>
option.setName('message')
.setDescription('The message you want the bot to say when someone leave in the current channel.')),
new SlashCommandBuilder()
.setName('quotation')
.setDescription('Enable or disable quotations')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
new SlashCommandBuilder()
.setName('welcome')
.setDescription('Set a join message')
.addStringOption(option =>
option.setName('message')
.setDescription('The message you want the bot to say when someone join in the current channel.')),
new SlashCommandBuilder()
.setName('ytp')
.setDescription('Generate a YTP')
.addBooleanOption(option =>
option.setName('force')
.setDescription('Force the generation of the video in non-nsfw channel.')
.setRequired(false)),
new SlashCommandBuilder()
.setName('addytp')
.setDescription('Add a video to the pool of ytps')
.addStringOption(option =>
option.setName('url')
.setDescription('URL of the video you want to add.')
.setRequired(true)),
new SlashCommandBuilder()
.setName('help')
.setDescription('Displays a list of commands or information about a command.')
.addStringOption(option =>
option.setName('command')
.setDescription('The command you want more details about.')),
new SlashCommandBuilder()
.setName('shameboard')
.setDescription('Set shameboard to the current channel.')
.addStringOption(option =>
option.setName('emote')
.setDescription('The emote that should be used to enter the shameboard.'))
.addStringOption(option =>
option.setName('count')
.setDescription('How many react for it to enter shameboard.'))
.addBooleanOption(option =>
option.setName('remove')
.setDescription('Remove the shameboard')
.setRequired(false)),
new SlashCommandBuilder()
.setName('starboard')
.setDescription('Set starboard to the current channel.')
.addStringOption(option =>
option.setName('emote')
.setDescription('The emote that should be used to enter the starboard.'))
.addStringOption(option =>
option.setName('count')
.setDescription('How many react for it to enter starboard.'))
.addBooleanOption(option =>
option.setName('remove')
.setDescription('Remove the starboard')
.setRequired(false)),
]
.map(command => command.toJSON());
const rest = new REST({ version: '9' }).setToken(token);
if (process.argv[2] === 'global') {
rest.put(Routes.applicationCommands(clientId), { body: commands })
.then(() => console.log('Successfully registered application commands globally.'))
.catch(console.error);
}
else if (process.argv[2] === 'delete') {
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
.then(() => console.log('Successfully deleted all guild commands.'))
.catch(console.error);
}
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
.then(() => console.log(`Successfully registered application commands for the guild ${guildId}.`))
.catch(console.error);

View file

@ -0,0 +1,48 @@
import { REST } from '@discordjs/rest';
import { Routes } from 'discord-api-types/v9';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import dotenv from 'dotenv';
dotenv.config();
const { clientId, guildId, token } = process.env;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const commands = [];
await loadCommandFromDir('fun');
await loadCommandFromDir('secret');
await loadCommandFromDir('utility');
await loadCommandFromDir('admin');
await loadCommandFromDir('owner');
commands.map(command => command.toJSON());
const rest = new REST({ version: '9' }).setToken(token);
if (process.argv[2] === 'global') {
rest.put(Routes.applicationCommands(clientId), { body: commands })
.then(() => console.log('Successfully registered application commands globally.'))
.catch(console.error);
}
else if (process.argv[2] === 'delete') {
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
.then(() => console.log('Successfully deleted all guild commands.'))
.catch(console.error);
}
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
.then(() => console.log(`Successfully registered application commands for the guild ${guildId}.`))
.catch(console.error);
async function loadCommandFromDir(dir) {
const commandsPath = path.join(`${__dirname}/../commands`, dir);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
let command = await import(filePath);
command = command.default;
commands.push(command.data);
}
}

View file

@ -1,42 +0,0 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
require('dotenv').config();
const { clientId, guildId, token } = process.env;
const commands = [
new SlashCommandBuilder()
.setName('die')
.setDescription('Kill the bot'),
new SlashCommandBuilder()
.setName('ublacklist')
.setDescription('Blacklist a user from the bot')
.addStringOption(option =>
option.setName('command')
.setDescription('Which command do you want to get a user blacklisted from?')
.setRequired(true))
.addStringOption(option =>
option.setName('userid')
.setDescription('Who do you want to blacklist?')
.setRequired(true))
.addStringOption(option =>
option.setName('reason')
.setDescription('The reason of the blacklist.')
.setRequired(false)),
new SlashCommandBuilder()
.setName('deletewteet')
.setDescription('Delete a tweet')
.addStringOption(option =>
option.setName('tweetid')
.setDescription('The id of the tweet you wish to delete.')
.setRequired(true)),
]
.map(command => command.toJSON());
const rest = new REST({ version: '9' }).setToken(token);
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
.then(() => console.log(`Successfully registered application commands for the guild ${guildId}.`))
.catch(console.error);