V14 update, added category and made it work with message event

This commit is contained in:
Supositware 2022-08-28 17:03:15 +02:00
parent bb49cfd490
commit ef61db520b
17 changed files with 138 additions and 95 deletions

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { MessageEmbed } from 'discord.js';
import { SlashCommandBuilder } from 'discord.js';
import { EmbedBuilder } from 'discord.js';
import TurndownService from 'turndown';
const turndown = new TurndownService();
import fetch from 'node-fetch';
@ -14,8 +14,9 @@ export default {
option.setName('board')
.setDescription('The board you wish to see')
.setRequired(true)),
async execute(interaction) {
let board = interaction.options.getString('board');
category: 'fun',
async execute(interaction, args) {
let board = args[0];
if (fourChan[board] == undefined) {
return interaction.reply({ content: 'Uh oh! The board you are looking for does not exist? You think this is a mistake? Please send a feedback telling me so!', ephemeral: true });
@ -65,7 +66,7 @@ export default {
title = 'No title';
}
const FourchanEmbed = new MessageEmbed()
const FourchanEmbed = new EmbedBuilder()
.setColor(interaction.member ? interaction.member.displayHexColor : 'NAVY')
.setTitle(turndown.turndown(title))
.setDescription(turndown.turndown(description))

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { Permissions } from 'discord.js';
import { SlashCommandBuilder } from 'discord.js';
import { PermissionFlagsBits } from 'discord.js';
export default {
data: new SlashCommandBuilder()
.setName('fakeuser')
@ -16,12 +16,14 @@ export default {
option.setName('image')
.setDescription('Optional attachment.')
.setRequired(false)),
clientPermissions: [ Permissions.FLAGS.MANAGE_WEBHOOKS ],
async execute(interaction) {
category: 'fun',
clientPermissions: [ PermissionFlagsBits.ManageWebhooks ],
async execute(interaction, args) {
await interaction.deferReply({ ephemeral: true });
const attachment = interaction.options.getAttachment('image');
const message = interaction.options.getString('message');
const member = interaction.options.getMentionable('user');
const member = args[0];
const message = args[1];
const attachment = args[2];
const webhook = await interaction.channel.createWebhook(member.user.username, {
avatar: member.user.displayAvatarURL(),

View file

@ -1,10 +1,11 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { SlashCommandBuilder } from 'discord.js';
import fetch from 'node-fetch';
export default {
data: new SlashCommandBuilder()
.setName('inspirobot')
.setDescription('Get an image from inspirobot'),
category: 'fun',
async execute(interaction) {
fetch('http://inspirobot.me/api?generate=true')
.then(res => res.text())

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { MessageEmbed } from 'discord.js';
import { SlashCommandBuilder } from 'discord.js';
import { EmbedBuilder } from 'discord.js';
import fetch from 'node-fetch';
export default {
@ -10,10 +10,11 @@ export default {
option.setName('subreddit')
.setDescription('The subreddit you wish to see')
.setRequired(true)),
async execute(interaction) {
category: 'fun',
async execute(interaction, args) {
await interaction.deferReply({ ephemeral: false });
fetch('https://www.reddit.com/r/' + interaction.options.getString('subreddit') + '.json?limit=100').then((response) => {
const subreddit = args[0];
fetch('https://www.reddit.com/r/' + subreddit + '.json?limit=100').then((response) => {
return response.json();
}).then((response) => {
if (response.error == 404) {
@ -27,7 +28,7 @@ export default {
if (response.data.children[i].data.over_18 == true && !interaction.channel.nsfw) {
return interaction.editReply('No nsfw');
}
const redditEmbed = new MessageEmbed()
const redditEmbed = new EmbedBuilder()
.setColor(interaction.member ? interaction.member.displayHexColor : 'NAVY')
.setTitle(response.data.children[i].data.title)
.setDescription(response.data.children[i].data.selftext)

View file

@ -1,4 +1,4 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { SlashCommandBuilder } from 'discord.js';
export default {
data: new SlashCommandBuilder()
@ -8,8 +8,9 @@ export default {
option.setName('something')
.setDescription('🤫')
.setRequired(true)),
async execute(interaction) {
const command = interaction.options.getString('something');
category: 'fun',
async execute(interaction, args) {
const command = args[0];
if (command === 'levertowned') {
interaction.reply('Hello buddy bro <:youngtroll:488559163832795136> <@434762632004894746>');

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { MessageEmbed } from 'discord.js';
import { SlashCommandBuilder } from 'discord.js';
import { EmbedBuilder } from 'discord.js';
import Twit from 'twit';
import fetch from 'node-fetch';
import os from 'node:os';
@ -25,16 +25,19 @@ export default {
option.setName('image')
.setDescription('Optional attachment (Image only.)')
.setRequired(false)),
category: 'fun',
ratelimit: 3,
cooldown: 3600,
async execute(interaction) {
if (!interaction.options.getString('content') && !interaction.options.getAttachment('image')) {
async execute(interaction, args, client) {
const content = args[0];
const attachment = args[1];
if (!content && !attachment) {
return interaction.reply({ content: 'Uh oh! You are missing any content for me to tweet!', ephemeral: true });
}
await interaction.deferReply({ ephemeral: false });
let tweet = interaction.options.getString('content');
const attachment = interaction.options.getAttachment('image');
let tweet = content;
const date = new Date();
// If account is less than 6 months old don't accept the tweet ( alt prevention )
if (interaction.user.createdAt > date.setMonth(date.getMonth() - 6)) {
@ -170,30 +173,34 @@ export default {
const TweetLink = `https://twitter.com/${FunnyWords[Math.floor((Math.random() * FunnyWords.length))]}/status/${tweetid}`;
// Im too lazy for now to make an entry in config.json
let channel = interaction.client.channels.resolve(twiChannel);
let channel = client.channels.resolve(twiChannel);
channel.send(TweetLink);
const Embed = new MessageEmbed()
const Embed = new EmbedBuilder()
.setAuthor({ name: interaction.user.username, iconURL: interaction.user.displayAvatarURL() })
.setDescription(tweet)
.addField('Link', TweetLink, true)
.addField('Tweet ID', tweetid, true)
.addField('Channel ID', interaction.channel.id, true)
.addField('Messsage ID', interaction.id, true)
.addField('Author', `${interaction.user.username} (${interaction.user.id})`, true)
.addFields(
{ name: 'Link', value: TweetLink, inline: true },
{ name: 'Tweet ID', value: tweetid, inline: true },
{ name: 'Channel ID', value: interaction.channel.id, inline: true },
{ name: 'Message ID', value: interaction.id, inline: true },
{ name: 'Author', value: `${interaction.user.username} (${interaction.user.id})`, inline: true },
)
.setTimestamp();
if (interaction.guild) {
Embed.addField('Guild', `${interaction.guild.name} (${interaction.guild.id})`, true);
Embed.addField('message link', `https://discord.com/channels/${interaction.guild.id}/${interaction.channel.id}/${interaction.id}`);
Embed.addFields(
{ name: 'Guild', value: `${interaction.guild.name} (${interaction.guild.id})`, inline: true },
{ name: 'message link', value: `https://discord.com/channels/${interaction.guild.id}/${interaction.channel.id}/${interaction.id}`, inline: true },
);
}
else {
Embed.addField('message link', `https://discord.com/channels/@me/${interaction.channel.id}/${interaction.id}`);
Embed.addFields({ name: 'message link', value: `https://discord.com/channels/@me/${interaction.channel.id}/${interaction.id}` });
}
if (attachment) Embed.setImage(attachment.url);
channel = interaction.client.channels.resolve(twiLogChannel);
channel = client.channels.resolve(twiLogChannel);
channel.send({ embeds: [Embed] });
return interaction.editReply({ content: `Go see ur epic tweet ${TweetLink}` });
});

View file

@ -1,4 +1,4 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { SlashCommandBuilder } from 'discord.js';
import Twit from 'twit';
import dotenv from 'dotenv';
@ -13,6 +13,7 @@ export default {
option.setName('tweetid')
.setDescription('The id of the tweet you wish to delete.')
.setRequired(true)),
category: 'owner',
ownerOnly: true,
async execute(interaction) {
await interaction.deferReply();

View file

@ -1,9 +1,10 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { SlashCommandBuilder } from 'discord.js';
export default {
data: new SlashCommandBuilder()
.setName('die')
.setDescription('Kill the bot'),
category: 'owner',
ownerOnly: true,
async execute(interaction) {
console.log('\x1b[31m\x1b[47m\x1b[5mSHUTING DOWN!!!!!\x1b[0m');

View file

@ -1,5 +1,4 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { MessageButton, MessageActionRow } from 'discord.js';
import { ButtonStyle, SlashCommandBuilder, ButtonBuilder, ActionRowBuilder } from 'discord.js';
import db from '../../models/index.js';
const Blacklists = db.Blacklists;
@ -19,6 +18,7 @@ export default {
option.setName('reason')
.setDescription('The reason of the blacklist.')
.setRequired(false)),
category: 'owner',
ownerOnly: true,
async execute(interaction) {
await interaction.deferReply({ ephemeral: true });
@ -38,18 +38,18 @@ export default {
return interaction.editReply(`${user} has been blacklisted from ${command} with the following reason ${reason}`);
}
else {
const row = new MessageActionRow()
const row = new ActionRowBuilder()
.addComponents(
new MessageButton()
new ButtonBuilder()
.setCustomId('yes')
.setLabel('Yes')
.setStyle('PRIMARY'),
.setStyle(ButtonStyle.Primary),
)
.addComponents(
new MessageButton()
new ButtonBuilder()
.setCustomId('no')
.setLabel('No')
.setStyle('DANGER'),
.setStyle(ButtonStyle.Danger),
);
await interaction.editReply({ content: 'This user is already blacklisted, do you want to unblacklist him?', ephemeral: true, components: [row] });

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { MessageEmbed } from 'discord.js';
import { SlashCommandBuilder } from 'discord.js';
import { EmbedBuilder } from 'discord.js';
import { exec } from 'node:child_process';
import db from '../../models/index.js';
const donator = db.donator;
@ -12,6 +12,7 @@ export default {
data: new SlashCommandBuilder()
.setName('about')
.setDescription('About me (The bot)'),
category: 'utility',
async execute(interaction) {
const Donator = await donator.findAll({ order: ['id'] });
const client = interaction.client;
@ -39,16 +40,19 @@ export default {
// description += '\nThanks to Jetbrains for providing their IDE!';
exec('git rev-parse --short HEAD', (err, stdout) => {
const aboutEmbed = new MessageEmbed()
const aboutEmbed = new EmbedBuilder()
.setColor(interaction.member ? interaction.member.displayHexColor : 'NAVY')
.setAuthor({ name: client.user.tag, iconURL: client.user.displayAvatarURL(), url: 'https://libtar.de' })
.setTitle('About me')
.setDescription(description)
.addField('Current commit', stdout)
.addField('Current maintainer: ', `${maintainer.tag} (${ownerId})`)
.addField('Gitea (Main)', 'https://git.namejeff.xyz/Supositware/Haha-Yes', true)
.addField('Github (Mirror)', 'https://github.com/Supositware/Haha-yes', true)
.addField('Privacy Policy', 'https://libtar.de/discordprivacy.txt')
.addFields(
{ name: 'Current commit', value: stdout },
{ name: 'Current maintainer', value: `${maintainer.tag} (${ownerId})` },
{ 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: 'Privacy Policy', value: 'https://libtar.de/discordprivacy.txt' },
)
.setFooter({ text: `Original bot made by ${owner.tag} (267065637183029248)` });
interaction.reply({ embeds: [aboutEmbed] });

View file

@ -1,18 +1,19 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { MessageEmbed } from 'discord.js';
import { SlashCommandBuilder } from 'discord.js';
import { EmbedBuilder } from 'discord.js';
import donations from '../../json/donations.json' assert {type: 'json'};
export default {
data: new SlashCommandBuilder()
.setName('donate')
.setDescription('Show donation link for the bot.'),
category: 'utility',
async execute(interaction) {
let desc = 'If you decide to donate, please do /feedback to let the owner know about it so he can put you in the about and donator command.';
donations.forEach(m => {
desc += `\n${m}`;
});
const Embed = new MessageEmbed()
const Embed = new EmbedBuilder()
.setColor(interaction.member ? interaction.member.displayHexColor : 'NAVY')
.setTitle('Donation link')
.setDescription(desc);

View file

@ -1,4 +1,4 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { SlashCommandBuilder } from 'discord.js';
import db from '../../models/index.js';
const donator = db.donator;
@ -6,6 +6,7 @@ export default {
data: new SlashCommandBuilder()
.setName('donator')
.setDescription('All the people who donated for this bot <3'),
category: 'utility',
async execute(interaction) {
await interaction.deferReply();
const client = interaction.client;

View file

@ -1,10 +1,12 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { MessageEmbed, MessageActionRow, MessageSelectMenu } from 'discord.js';
import { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, SelectMenuBuilder } from 'discord.js';
import { exec } from 'node:child_process';
import fs from 'node:fs';
import os from 'node:os';
import utils from '../../utils/videos.js';
let client;
let cleanUp;
export default {
data: new SlashCommandBuilder()
.setName('download')
@ -21,17 +23,29 @@ export default {
option.setName('compress')
.setDescription('Compress the video?')
.setRequired(false)),
category: 'utility',
async execute(interaction, args, c) {
client = c;
const url = args[0];
const format = args[1];
interaction.doCompress = args[2];
if (interaction.cleanUp) {
cleanUp = interaction.cleanUp;
}
async execute(interaction) {
await interaction.deferReply({ ephemeral: false });
const url = interaction.options.getString('url');
if (interaction.isMessage) {
interaction.delete();
}
if (!await utils.stringIsAValidurl(url)) {
console.error(`Not a url!!! ${url}`);
return interaction.editReply({ content: '❌ This does not look like a valid url!', ephemeral: true });
}
if (interaction.options.getBoolean('format')) {
if (format) {
let qualitys = await new Promise((resolve, reject) => {
exec(`./bin/yt-dlp "${url}" --print "%()j"`, (err, stdout, stderr) => {
if (err) {
@ -71,9 +85,9 @@ export default {
options.reverse();
}
const row = new MessageActionRow()
const row = new ActionRowBuilder()
.addComponents(
new MessageSelectMenu()
new SelectMenuBuilder()
.setCustomId('downloadQuality')
.setPlaceholder('Nothing selected')
.setMinValues(1)
@ -84,7 +98,7 @@ export default {
await interaction.deleteReply();
await interaction.followUp({ content: 'Which quality do you want?', ephemeral: true, components: [row] });
interaction.client.once('interactionCreate', async (interactionMenu) => {
client.once('interactionCreate', async (interactionMenu) => {
if (!interactionMenu.isSelectMenu()) return;
if (interactionMenu.customId === 'downloadQuality') {
await interactionMenu.deferReply({ ephemeral: false });
@ -99,7 +113,7 @@ export default {
async function download(url, interaction, originalInteraction) {
let format = 'bestvideo*+bestaudio/best';
const Embed = new MessageEmbed()
const Embed = new EmbedBuilder()
.setColor(interaction.member ? interaction.member.displayHexColor : 'NAVY')
.setAuthor({ name: `Downloaded by ${interaction.user.tag}`, iconURL: interaction.user.displayAvatarURL(), url: url })
.setFooter({ text: `You can get the original video by clicking on the "Downloaded by ${interaction.user.tag}" message!` });
@ -117,7 +131,7 @@ async function download(url, interaction, originalInteraction) {
const fileStat = fs.statSync(output);
const fileSize = fileStat.size / 1000000.0;
const compressInteraction = originalInteraction ? originalInteraction : interaction;
if (compressInteraction.options.getBoolean('compress')) {
if (compressInteraction.doCompress) {
const presets = [ 'Discord Tiny 5 Minutes 240p30', 'Discord Small 2 Minutes 360p30', 'Discord Nitro Small 10-20 Minutes 480p30', 'Discord Nitro Medium 5-10 Minutes 720p30', 'Discord Nitro Large 3-6 Minutes 1080p30' ];
const options = [];
@ -128,9 +142,9 @@ async function download(url, interaction, originalInteraction) {
});
});
const row = new MessageActionRow()
const row = new ActionRowBuilder()
.addComponents(
new MessageSelectMenu()
new SelectMenuBuilder()
.setCustomId('preset')
.setPlaceholder('Nothing selected')
.addOptions(options),
@ -138,11 +152,12 @@ async function download(url, interaction, originalInteraction) {
await interaction.deleteReply();
await interaction.followUp({ content: 'Which compression preset do you want?', ephemeral: true, components: [row] });
interaction.client.once('interactionCreate', async (interactionMenu) => {
client.once('interactionCreate', async (interactionMenu) => {
if (!interactionMenu.isSelectMenu()) return;
if (interactionMenu.customId === 'preset') {
await interactionMenu.deferReply({ ephemeral: false });
compress(file, interactionMenu, Embed);
cleanUp();
}
});
return;
@ -163,6 +178,7 @@ async function download(url, interaction, originalInteraction) {
else {
await interaction.editReply({ embeds: [Embed], files: [output], ephemeral: false });
}
cleanUp();
})
.catch(async err => {
console.error(err);

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { MessageEmbed } from 'discord.js';
import { SlashCommandBuilder } from 'discord.js';
import { EmbedBuilder } from 'discord.js';
const { feedbackChannelId } = process.env;
@ -11,13 +11,14 @@ export default {
option.setName('feedback')
.setDescription('The message you want to send me.')
.setRequired(true)),
async execute(interaction) {
const Embed = new MessageEmbed()
category: 'utility',
async execute(interaction, args) {
const Embed = new EmbedBuilder()
.setAuthor({ name: `${interaction.user.tag} (${interaction.user.id})`, iconURL: interaction.user.avatarURL() })
.setTimestamp();
if (interaction.guild) Embed.addField('Guild', `${interaction.guild.name} (${interaction.guild.id})`, true);
Embed.addField('Feedback', interaction.options.getString('feedback'));
if (interaction.guild) Embed.addFields({ name: 'Guild', value: `${interaction.guild.name} (${interaction.guild.id})`, inline: true });
Embed.addFields({ name: 'Feedback', value: args[0], inline: true });
// Don't let new account use this command to prevent spam
const date = new Date();

View file

@ -1,9 +1,10 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { SlashCommandBuilder } from 'discord.js';
export default {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
category: 'utility',
async execute(interaction) {
await interaction.reply(`Pong! \`${Math.round(interaction.client.ws.ping)} ms\``);
},

View file

@ -1,11 +1,12 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { MessageEmbed, version } from 'discord.js';
import { SlashCommandBuilder } from 'discord.js';
import { EmbedBuilder, version } from 'discord.js';
import os from 'node:os';
export default {
data: new SlashCommandBuilder()
.setName('stats')
.setDescription('Show some stats about the bot'),
category: 'utility',
async execute(interaction) {
const client = interaction.client;
const uptime = process.uptime();
@ -32,19 +33,21 @@ export default {
return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
};
const statsEmbed = new MessageEmbed()
const statsEmbed = new EmbedBuilder()
.setColor(interaction.member ? interaction.member.displayHexColor : 'NAVY')
.setTitle('Bot stats')
.setAuthor({ name: client.user.tag, iconURL: client.user.displayAvatarURL(), url: 'https://libtar.de' })
.addField('Servers', client.guilds.cache.size.toString(), true)
.addField('Channels', client.channels.cache.size.toString(), true)
.addField('Users', client.users.cache.size.toString(), true)
.addField('Ram usage', `${bytesToSize(process.memoryUsage().heapUsed)}/${bytesToSize(os.totalmem)}`, true)
.addField('CPU', `${os.cpus()[0].model} (${os.cpus().length} core)`, true)
.addField('OS', `${os.platform()} ${os.release()}`, true)
.addField('Nodejs version', process.version, true)
.addField('Discord.js version', version, true)
.addField('Uptime', dateString, true)
.addFields(
{ name: 'Servers', value: client.guilds.cache.size.toString(), inline: true },
{ name: 'Channels', value: client.channels.cache.size.toString(), inline: true },
{ name: 'Users', value: client.users.cache.size.toString(), inline: true },
{ name: 'Ram usage', value: `${bytesToSize(process.memoryUsage().heapUsed)}/${bytesToSize(os.totalmem)}`, inline: true },
{ name: 'CPU', value: `${os.cpus()[0].model} (${os.cpus().length} core)`, inline: true },
{ name: 'OS', value: `${os.platform()} ${os.release()}`, inline: true },
{ name: 'Nodejs version', value: process.version, inline: true },
{ name: 'Discord.js version', value: version, inline: true },
{ name: 'Uptime', value: dateString, inline: true },
)
.setTimestamp();
return interaction.reply({ embeds: [statsEmbed] });

View file

@ -1,4 +1,4 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { SlashCommandBuilder } from 'discord.js';
import utils from '../../utils/videos.js';
import fs from 'node:fs';
import os from 'node:os';
@ -14,9 +14,10 @@ export default {
option.setName('url')
.setDescription('URL of the video you want to convert')
.setRequired(true)),
async execute(interaction) {
category: 'utility',
async execute(interaction, args) {
await interaction.deferReply({ ephemeral: false });
const url = interaction.options.getString('url');
const url = args[0];
if (!await utils.stringIsAValidurl(url)) {
console.error(`Not a url!!! ${url}`);