Compare commits
No commits in common. 'Slash-V14' and 'Commando' have entirely different histories.
@ -1,19 +0,0 @@
|
||||
token=YourToken
|
||||
clientId=BotClientId
|
||||
guildId=DevGuildId
|
||||
ownerId=OwnerUserId
|
||||
statusChannel=CHannelIdForStatus
|
||||
uptimeURL=UptimeKumaOrWhateverStatusThingYouUseOrJustLeaveEmpty
|
||||
uptimeInterval=60
|
||||
twiConsumer=TwitterConsumerToken
|
||||
twiConsumerSecret=TwitterConsumerSecretToken
|
||||
twiToken=TwitterToken
|
||||
twiTokenSecret=TwitterSecretToken
|
||||
twiChannel=ChannelWhereJustTheTwitterLinkAreSent
|
||||
twiLogChannel=ChannelWhereTheDetailedInfoOfTheCommandIsSent
|
||||
botsggToken=APITokenForBots.gg
|
||||
botsggEndpoint=https://discord.bots.gg/api/v1
|
||||
stableHordeApi=0000000000
|
||||
stableHordeID=0000
|
||||
NODE_ENV=development
|
||||
ytdlpMaxResolution=720
|
@ -1,57 +0,0 @@
|
||||
{
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"parser": "@babel/eslint-parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2022,
|
||||
"sourceType": "module",
|
||||
"requireConfigFile": false,
|
||||
"babelOptions": {
|
||||
"plugins": [
|
||||
"@babel/plugin-syntax-import-assertions"
|
||||
]
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"arrow-spacing": ["warn", { "before": true, "after": true }],
|
||||
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
|
||||
"comma-dangle": ["error", "always-multiline"],
|
||||
"comma-spacing": "error",
|
||||
"comma-style": "error",
|
||||
"curly": ["error", "multi-line", "consistent"],
|
||||
"dot-location": ["error", "property"],
|
||||
"handle-callback-err": "off",
|
||||
"indent": ["error", "tab"],
|
||||
"keyword-spacing": "error",
|
||||
"max-nested-callbacks": ["error", { "max": 4 }],
|
||||
"max-statements-per-line": ["error", { "max": 2 }],
|
||||
"no-console": "off",
|
||||
"no-empty-function": "error",
|
||||
"no-floating-decimal": "error",
|
||||
"no-inline-comments": "error",
|
||||
"no-lonely-if": "error",
|
||||
"no-multi-spaces": "error",
|
||||
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
|
||||
"no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
|
||||
"no-trailing-spaces": ["error"],
|
||||
"no-var": "error",
|
||||
"object-curly-spacing": ["error", "always"],
|
||||
"prefer-const": "error",
|
||||
"quotes": ["error", "single"],
|
||||
"semi": ["error", "always"],
|
||||
"space-before-blocks": "error",
|
||||
"space-before-function-paren": ["error", {
|
||||
"anonymous": "never",
|
||||
"named": "never",
|
||||
"asyncArrow": "always"
|
||||
}],
|
||||
"space-in-parens": "error",
|
||||
"space-infix-ops": "error",
|
||||
"space-unary-ops": "error",
|
||||
"spaced-comment": "error",
|
||||
"yoda": "error"
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
---
|
||||
|
||||
name: "Bug"
|
||||
about: "Use this if you found a bug in the bot."
|
||||
title: "[BUG] "
|
||||
ref: "main"
|
||||
labels:
|
||||
|
||||
- bug
|
||||
|
||||
---
|
||||
|
||||
<!-- Please provide the commit of the bot at the time of the report. You can find it by doing /about or haha about. -->
|
||||
**Commit number**
|
||||
|
||||
**Bot varient**
|
||||
<!-- Put a x between the brackets to signify the version you used. -->
|
||||
- [ ] Slash <!-- The current and latest version that use the slash commands. -->
|
||||
- [ ] Legacy <!-- The old version of the bot with the "haha" prefix. -->
|
||||
|
||||
**Describe the issue**
|
||||
|
||||
**Intended result**
|
||||
|
||||
**Screenshots**
|
||||
|
||||
**Steps to reproduce the issue**
|
||||
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
|
||||
**Did someone already report that bug?**
|
||||
|
||||
- [ ] Yes <!-- If you have to put yes you don't need to submit that bug report. -->
|
||||
- [ ] No
|
@ -1,19 +0,0 @@
|
||||
---
|
||||
|
||||
name: "Feature request"
|
||||
about: "Use this if you want a new feature in the bot."
|
||||
title: "[Feature request] "
|
||||
ref: "main"
|
||||
labels:
|
||||
|
||||
- Feature request
|
||||
|
||||
---
|
||||
|
||||
**Describe the feature you want**
|
||||
|
||||
|
||||
**Did someone already request that feature?**
|
||||
|
||||
- [ ] Yes <!-- If you have to put yes you don't need to submit that feature request. -->
|
||||
- [ ] No
|
@ -1,16 +1,13 @@
|
||||
.env
|
||||
node_modules/
|
||||
config/config.json
|
||||
json/board/
|
||||
unloaded/
|
||||
database.sqlite3
|
||||
tmp/*.js
|
||||
|
||||
bin/yt-dlp
|
||||
bin/HandBrakeCLI
|
||||
bin/upload.sh
|
||||
bin/dectalk
|
||||
|
||||
asset/ytp/sources
|
||||
asset/ytp/music
|
||||
asset/ytp/sounds
|
||||
config.json
|
||||
package-lock.json
|
||||
.DS_Store
|
||||
node_modules
|
||||
node_modules\
|
||||
.vscode
|
||||
video.mp4
|
||||
json/autoresponse.json
|
||||
json/blacklist.json
|
||||
json/customresponse.json
|
||||
tag/*
|
||||
tts.mp3
|
||||
ttsvc.mp3
|
||||
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "pwa-node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}/index.js"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,4 @@
|
||||
module.exports = function blacklist(reasons, message){
|
||||
return message.channel.send(`You have been blacklisted for the following reasons: **${reasons}**`)
|
||||
}
|
||||
|
@ -1,171 +0,0 @@
|
||||
/* TODO
|
||||
*
|
||||
* To be merged with commands/AI/txt2img.js
|
||||
*
|
||||
*/
|
||||
import { SlashCommandBuilder, EmbedBuilder, AttachmentBuilder, ButtonBuilder, ActionRowBuilder, ButtonStyle } from 'discord.js';
|
||||
import fetch from 'node-fetch';
|
||||
import os from 'node:os';
|
||||
import fs from 'node:fs';
|
||||
import stream from 'node:stream';
|
||||
import util from 'node:util';
|
||||
|
||||
import db from '../../models/index.js';
|
||||
|
||||
const { stableHordeApi, stableHordeID } = process.env;
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('img2img')
|
||||
.setDescription('AI generated image with stable diffusion (If credit are low it may be slow)')
|
||||
.addAttachmentOption(option =>
|
||||
option.setName('image')
|
||||
.setDescription('Image you want to modify')
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option.setName('prompt')
|
||||
.setDescription('What do you want the AI to generate?')
|
||||
.setRequired(true)),
|
||||
category: 'AI',
|
||||
alias: ['i2i'],
|
||||
async execute(interaction, args, client) {
|
||||
await interaction.deferReply();
|
||||
|
||||
const streamPipeline = util.promisify(stream.pipeline);
|
||||
const res = await fetch(args.image.url);
|
||||
if (!res.ok) return interaction.editReply('An error has occured while trying to download your image.');
|
||||
await streamPipeline(res.body, fs.createWriteStream(`${os.tmpdir()}/${args.image.name}.webp`));
|
||||
|
||||
const b64Image = fs.readFileSync(`${os.tmpdir()}/${args.image.name}.webp`, { encoding: 'base64' });
|
||||
generate(interaction, args.prompt, client, b64Image);
|
||||
},
|
||||
};
|
||||
|
||||
async function generate(i, prompt, client, b64Img) {
|
||||
console.log('Generating image');
|
||||
const body = {
|
||||
prompt: prompt,
|
||||
params: {
|
||||
n: 1,
|
||||
width: 512,
|
||||
height: 512,
|
||||
},
|
||||
cfg_scale: 9,
|
||||
use_gfpgan: true,
|
||||
use_real_esrgan: true,
|
||||
use_ldsr: true,
|
||||
use_upscaling: true,
|
||||
steps: 50,
|
||||
nsfw: i.channel.nsfw ? true : false,
|
||||
censor_nsfw: i.channel.nsfw ? true : false,
|
||||
source_image: b64Img,
|
||||
source_processing: 'img2img',
|
||||
shared: true,
|
||||
};
|
||||
|
||||
const isOptOut = await db.optout.findOne({ where: { userID: i.user.id } });
|
||||
|
||||
if (isOptOut) {
|
||||
body.shared = false;
|
||||
}
|
||||
|
||||
const fetchParameters = {
|
||||
method: 'post',
|
||||
body: JSON.stringify(body),
|
||||
headers: { 'Content-Type': 'application/json', 'apikey': stableHordeApi },
|
||||
};
|
||||
|
||||
let response = await fetch('https://stablehorde.net/api/v2/generate/async', fetchParameters);
|
||||
|
||||
response = await response.json();
|
||||
|
||||
if (!response.id) {
|
||||
console.log(response);
|
||||
return i.editReply({ content: `An error has occured, please try again later. \`${response.message}\`` });
|
||||
}
|
||||
|
||||
let wait_time = 5000;
|
||||
let checkURL = `https://stablehorde.net/api/v2/generate/check/${response.id}`;
|
||||
const checking = setInterval(async () => {
|
||||
const checkResult = await checkGeneration(checkURL);
|
||||
|
||||
if (checkResult === undefined) return;
|
||||
if (!checkResult.done) {
|
||||
if (checkResult.wait_time === -1) {
|
||||
console.log(checkResult.raw);
|
||||
return i.editReply({ content: `An error has occured, please try again later. \`${checkResult.raw.message}\`` });
|
||||
}
|
||||
|
||||
if (checkResult.wait_time < 0) {
|
||||
console.log(checkResult.raw);
|
||||
clearInterval(checking);
|
||||
return i.editReply({ content: 'No servers are currently available to fulfill your request, please try again later.' });
|
||||
}
|
||||
if (checkResult.wait_time === 0) {
|
||||
checkURL = `https://stablehorde.net/api/v2/generate/status/${response.id}`;
|
||||
}
|
||||
wait_time = checkResult.wait_time;
|
||||
}
|
||||
else if (checkResult.done && checkResult.image) {
|
||||
clearInterval(checking);
|
||||
let creditResponse = await fetch(`https://stablehorde.net/api/v2/users/${stableHordeID}`);
|
||||
creditResponse = await creditResponse.json();
|
||||
|
||||
const streamPipeline = util.promisify(stream.pipeline);
|
||||
const res = await fetch(checkResult.image);
|
||||
if (!res.ok) return i.editReply('An error has occured while trying to download your image.');
|
||||
await streamPipeline(res.body, fs.createWriteStream(`${os.tmpdir()}/${i.id}.webp`));
|
||||
|
||||
const generatedImg = new AttachmentBuilder(`${os.tmpdir()}/${i.id}.webp`);
|
||||
|
||||
const stableEmbed = new EmbedBuilder()
|
||||
.setColor(i.member ? i.member.displayHexColor : 'Navy')
|
||||
.setTitle(prompt)
|
||||
.setURL('https://aqualxx.github.io/stable-ui/')
|
||||
.setImage(`attachment://${i.id}.webp`)
|
||||
.setFooter({ text: `**Credit left: ${creditResponse.kudos}** Seed: ${checkResult.seed} worker ID: ${checkResult.worker_id} worker name: ${checkResult.worker_name}` });
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`regenerate${i.user.id}${i.id}`)
|
||||
.setLabel('🔄 Regenerate')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
);
|
||||
|
||||
await i.editReply({ embeds: [stableEmbed], components: [row], files: [generatedImg] });
|
||||
|
||||
listenButton(client, i, prompt);
|
||||
}
|
||||
}, wait_time);
|
||||
}
|
||||
|
||||
async function checkGeneration(url) {
|
||||
let check = await fetch(url);
|
||||
check = await check.json();
|
||||
|
||||
if (!check.is_possible) {
|
||||
return { done: false, wait_time: -1, raw: check };
|
||||
}
|
||||
|
||||
if (check.done) {
|
||||
if (!check.generations) {
|
||||
return { done: false, wait_time: check.wait_time * 1000, raw: check };
|
||||
}
|
||||
|
||||
return { done: true, image: check.generations[0].img, seed: check.generations[0].seed, worker_id: check.generations[0].worker_id, worker_name: check.generations[0].worker_name, raw: check };
|
||||
}
|
||||
}
|
||||
|
||||
async function listenButton(client, interaction, prompt) {
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (!interactionMenu.isButton()) return;
|
||||
|
||||
await interactionMenu.update({ components: [] });
|
||||
|
||||
if (interactionMenu.customId === `regenerate${interactionMenu.user.id}${interaction.id}`) {
|
||||
await interactionMenu.deferReply();
|
||||
await generate(interactionMenu, prompt, client);
|
||||
}
|
||||
});
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
/* TODO
|
||||
*
|
||||
* To be merged with commands/AI/img2img.js
|
||||
*
|
||||
*/
|
||||
import { SlashCommandBuilder, EmbedBuilder, AttachmentBuilder, ButtonBuilder, ActionRowBuilder, ButtonStyle } from 'discord.js';
|
||||
import fetch from 'node-fetch';
|
||||
import os from 'node:os';
|
||||
import fs from 'node:fs';
|
||||
import stream from 'node:stream';
|
||||
import util from 'node:util';
|
||||
|
||||
import db from '../../models/index.js';
|
||||
|
||||
const { stableHordeApi, stableHordeID } = process.env;
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('txt2img')
|
||||
.setDescription('AI generated image with stable diffusion (If credit are low it may be slow)')
|
||||
.addStringOption(option =>
|
||||
option.setName('prompt')
|
||||
.setDescription('What do you want the AI to generate?')
|
||||
.setRequired(true)),
|
||||
category: 'AI',
|
||||
alias: ['t2i'],
|
||||
async execute(interaction, args, client) {
|
||||
await interaction.deferReply();
|
||||
generate(interaction, args.prompt, client);
|
||||
},
|
||||
};
|
||||
|
||||
async function generate(i, prompt, client) {
|
||||
const body = {
|
||||
prompt: prompt,
|
||||
params: {
|
||||
n: 1,
|
||||
width: 512,
|
||||
height: 512,
|
||||
},
|
||||
cfg_scale: 9,
|
||||
use_gfpgan: true,
|
||||
use_real_esrgan: true,
|
||||
use_ldsr: true,
|
||||
use_upscaling: true,
|
||||
steps: 50,
|
||||
nsfw: i.channel.nsfw ? true : false,
|
||||
censor_nsfw: i.channel.nsfw ? true : false,
|
||||
shared: true,
|
||||
};
|
||||
|
||||
const isOptOut = await db.optout.findOne({ where: { userID: i.user.id } });
|
||||
|
||||
if (isOptOut) {
|
||||
body.shared = false;
|
||||
}
|
||||
|
||||
const fetchParameters = {
|
||||
method: 'post',
|
||||
body: JSON.stringify(body),
|
||||
headers: { 'Content-Type': 'application/json', 'apikey': stableHordeApi },
|
||||
};
|
||||
|
||||
let response = await fetch('https://stablehorde.net/api/v2/generate/async', fetchParameters);
|
||||
|
||||
response = await response.json();
|
||||
let wait_time = 5000;
|
||||
let checkURL = `https://stablehorde.net/api/v2/generate/check/${response.id}`;
|
||||
const checking = setInterval(async () => {
|
||||
const checkResult = await checkGeneration(checkURL);
|
||||
|
||||
if (checkResult === undefined) return;
|
||||
if (!checkResult.done) {
|
||||
if (checkResult.wait_time < 0) {
|
||||
clearInterval(checking);
|
||||
return i.editReply({ content: 'No servers are currently available to fulfill your request, please try again later.' });
|
||||
}
|
||||
if (checkResult.wait_time === 0) {
|
||||
checkURL = `https://stablehorde.net/api/v2/generate/status/${response.id}`;
|
||||
}
|
||||
wait_time = checkResult.wait_time;
|
||||
}
|
||||
else if (checkResult.done && checkResult.image) {
|
||||
clearInterval(checking);
|
||||
let creditResponse = await fetch(`https://stablehorde.net/api/v2/users/${stableHordeID}`);
|
||||
creditResponse = await creditResponse.json();
|
||||
|
||||
const streamPipeline = util.promisify(stream.pipeline);
|
||||
const res = await fetch(checkResult.image);
|
||||
if (!res.ok) return i.editReply('An error has occured while trying to download your image.');
|
||||
await streamPipeline(res.body, fs.createWriteStream(`${os.tmpdir()}/${i.id}.webp`));
|
||||
|
||||
const generatedImg = new AttachmentBuilder(`${os.tmpdir()}/${i.id}.webp`);
|
||||
|
||||
const stableEmbed = new EmbedBuilder()
|
||||
.setColor(i.member ? i.member.displayHexColor : 'Navy')
|
||||
.setTitle(prompt)
|
||||
.setURL('https://aqualxx.github.io/stable-ui/')
|
||||
.setImage(`attachment://${i.id}.webp`)
|
||||
.setFooter({ text: `**Credit left: ${creditResponse.kudos}** Seed: ${checkResult.seed} worker ID: ${checkResult.worker_id} worker name: ${checkResult.worker_name}` });
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`regenerate${i.user.id}${i.id}`)
|
||||
.setLabel('🔄 Regenerate')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
);
|
||||
|
||||
await i.editReply({ embeds: [stableEmbed], components: [row], files: [generatedImg] });
|
||||
|
||||
listenButton(client, i, prompt);
|
||||
}
|
||||
}, wait_time);
|
||||
}
|
||||
|
||||
async function checkGeneration(url) {
|
||||
let check = await fetch(url);
|
||||
check = await check.json();
|
||||
|
||||
if (!check.is_possible) {
|
||||
return { done: false, wait_time: -1 };
|
||||
}
|
||||
|
||||
if (check.done) {
|
||||
if (!check.generations) {
|
||||
return { done: false, wait_time: check.wait_time * 1000 };
|
||||
}
|
||||
|
||||
return { done: true, image: check.generations[0].img, seed: check.generations[0].seed, worker_id: check.generations[0].worker_id, worker_name: check.generations[0].worker_name };
|
||||
}
|
||||
}
|
||||
|
||||
async function listenButton(client, interaction, prompt) {
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (!interactionMenu.isButton()) return;
|
||||
|
||||
await interactionMenu.update({ components: [] });
|
||||
|
||||
if (interactionMenu.customId === `regenerate${interactionMenu.user.id}${interaction.id}`) {
|
||||
await interactionMenu.deferReply();
|
||||
await generate(interactionMenu, prompt, client);
|
||||
}
|
||||
});
|
||||
}
|
@ -1,62 +1,72 @@
|
||||
import { SlashCommandBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder, PermissionFlagsBits } from 'discord.js';
|
||||
import db from '../../models/index.js';
|
||||
const { Command } = require('discord.js-commando');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
const fs = require('fs');
|
||||
const { prefix } = require('../../config.json')
|
||||
module.exports = class AutoresponseCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'autoresponse',
|
||||
group: 'admin',
|
||||
memberName: 'autoresponse',
|
||||
userPermissions: ['ADMINISTRATOR'],
|
||||
description: `Can disable autoresponse in the channel (you can add "ALL" like this "${prefix} enable/disable all" to enable/disable in every channel (EXPERIMENTAL))`,
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'Disable or enable?',
|
||||
type: 'string',
|
||||
oneOf: ['disable', 'enable','disable all', 'enable all'],
|
||||
},
|
||||
{
|
||||
key: 'all',
|
||||
prompt: 'Disable or enable in every channel? (EXPERIMENTAL)',
|
||||
type: 'string',
|
||||
oneOf: ['all', ''],
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('autoresponse')
|
||||
.setDescription('Enable or disable autoresponse')
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
|
||||
category: 'admin',
|
||||
async execute(interaction, args, client) {
|
||||
const autoresponseStat = await db.autoresponseStat.findOne({ where: { serverID: interaction.guild.id } });
|
||||
if (!autoresponseStat) {
|
||||
const body = { serverID: interaction.guild.id, stat: 'enable' };
|
||||
await db.autoresponseStat.create(body);
|
||||
return await interaction.reply({ content: 'Autoresponse has been enabled.', ephemeral: true });
|
||||
}
|
||||
async run(message, { text, all }) {
|
||||
if(blacklist[message.author.id])
|
||||
return message.channel.send("You are blacklisted")
|
||||
|
||||
let autoresponse = {}
|
||||
let json = JSON.stringify(autoresponse)
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`yes${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Yes')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`no${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('No')
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
);
|
||||
if (all == 'all') {
|
||||
const guild = this.client.guilds.get(message.guild.id);
|
||||
fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data){
|
||||
if (err){
|
||||
console.log(err);
|
||||
} else {
|
||||
autoresponse = JSON.parse(data); //now it an object
|
||||
guild.channels.forEach(channel => autoresponse [channel] = text)
|
||||
json = JSON.stringify(autoresponse); //convert it back to json
|
||||
json = json.replace(/[<#>]/g, '')
|
||||
fs.writeFile('./json/autoresponse.json', json, 'utf8', function(err) {
|
||||
if(err) {
|
||||
return console.log(err);
|
||||
}
|
||||
})}});
|
||||
|
||||
if (autoresponseStat.stat === 'enable') {
|
||||
await interaction.reply({ content: 'Autoresponse is already enabled, do you wish to disable it?', components: [row], ephemeral: true });
|
||||
}
|
||||
else {
|
||||
const body = { serverID: interaction.guild.id, stat: 'enable' };
|
||||
await db.autoresponseStat.update(body, { where: { serverID: interaction.guild.id } });
|
||||
return interaction.editReply({ content: 'Auto response has been enabled.', ephemeral: true });
|
||||
}
|
||||
|
||||
return listenButton(client, interaction, interaction.user);
|
||||
},
|
||||
};
|
||||
|
||||
async function listenButton(client, interaction, user = interaction.user, originalId = interaction.id) {
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (user !== interactionMenu.user) return listenButton(client, interaction, user, originalId);
|
||||
if (!interactionMenu.isButton()) return;
|
||||
|
||||
await interactionMenu.update({ components: [] });
|
||||
|
||||
if (interactionMenu.customId === `yes${interaction.user.id}${originalId}`) {
|
||||
const body = { serverID: interaction.guild.id, stat: 'disable' };
|
||||
await db.autoresponseStat.update(body, { where: { serverID: interaction.guild.id } });
|
||||
return interaction.editReply({ content: 'Auto response has been disabled.', ephemeral: true });
|
||||
}
|
||||
else {
|
||||
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
return message.say('Auto response have been disable/enable on every channel')
|
||||
} else if(text == 'disable' || 'enable') {
|
||||
fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data){
|
||||
if (err){
|
||||
console.log(err);
|
||||
} else {
|
||||
autoresponse = JSON.parse(data); //now it an object
|
||||
autoresponse [message.channel.id] = text
|
||||
json = JSON.stringify(autoresponse); //convert it back to json
|
||||
fs.writeFile('./json/autoresponse.json', json, 'utf8', function(err) {
|
||||
if(err) {
|
||||
return console.log(err);
|
||||
}
|
||||
})}});
|
||||
|
||||
return message.say(`Autoresponse have been ${text}d`);
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1,48 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class BanCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'ban',
|
||||
group: 'admin',
|
||||
memberName: 'ban',
|
||||
description: 'ban the mentionned user',
|
||||
guildOnly: true,
|
||||
clientPermissions: ['BAN_MEMBERS'],
|
||||
userPermissions: ['BAN_MEMBERS'],
|
||||
args: [
|
||||
{
|
||||
key: 'member',
|
||||
prompt: 'Wich member would you like to ban?',
|
||||
type: 'member',
|
||||
},
|
||||
{
|
||||
key: 'reasons',
|
||||
prompt: 'What is the reasons of the kick',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { member, reasons }) {
|
||||
if(member == this.client)
|
||||
return message.say('Cant kick me fool')
|
||||
if(!reasons)
|
||||
reasons = 'Nothing have been specified'
|
||||
if(member.id === message.author.id)
|
||||
return message.say("Why would you ban yourself ?")
|
||||
|
||||
try {
|
||||
await member.send(`https://youtu.be/55-mHgUjZfY\nYou have been banned for the following reasons: "${reasons}"`)
|
||||
} catch(err) {
|
||||
console.error(`Could not dm the user, probably disabled\n${err}`)
|
||||
}
|
||||
|
||||
member.ban(`Banned by : ${message.author.username} for the following reasons : ${reasons}`)
|
||||
.then(() => message.reply(`${member.user.username} was succesfully banned with the following reasons "${reasons}".`))
|
||||
|
||||
};
|
||||
};
|
@ -1,74 +0,0 @@
|
||||
import { SlashCommandBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder, PermissionFlagsBits } from 'discord.js';
|
||||
import db from '../../models/index.js';
|
||||
|
||||
export default {
|
||||
data: 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.')),
|
||||
category: 'admin',
|
||||
userPermissions: [PermissionFlagsBits.ManageChannels],
|
||||
async execute(interaction, args, client) {
|
||||
const leave = await db.leaveChannel.findOne({ where: { guildID: interaction.guild.id } });
|
||||
|
||||
if (!leave && !args.message) {
|
||||
return interaction.reply({ content: 'You need a message for me to say anything!', ephemeral: true });
|
||||
}
|
||||
else if (!leave) {
|
||||
const body = { guildID: interaction.guild.id, channelID: interaction.channel.id, message: args.message };
|
||||
await db.leaveChannel.create(body);
|
||||
return interaction.reply({ content: `The leave message have been set with ${args.message}`, ephemeral: true });
|
||||
}
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`edit${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Edit')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`remove${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Remove')
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`nothing${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Do nothing')
|
||||
.setStyle(ButtonStyle.Secondary),
|
||||
);
|
||||
|
||||
await interaction.reply({ content: 'The server already has a message set, do you want to edit it or remove it?', components: [row], ephemeral: true });
|
||||
|
||||
return listenButton(client, interaction, args, interaction.user);
|
||||
},
|
||||
};
|
||||
|
||||
async function listenButton(client, interaction, args, user = interaction.user, originalId = interaction.id) {
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (user !== interactionMenu.user) return listenButton(client, interaction, args, user, originalId);
|
||||
if (!interactionMenu.isButton()) return;
|
||||
|
||||
await interactionMenu.update({ components: [] });
|
||||
|
||||
if (interactionMenu.customId === `edit${interaction.user.id}${originalId}`) {
|
||||
if (!args.message) {
|
||||
return interaction.reply({ content: 'You need to input a message for me to edit!', ephemeral: true });
|
||||
}
|
||||
const body = { guildID: interaction.guild.id, channelID: interaction.channel.id, message: args.message };
|
||||
await db.leaveChannel.update(body, { where: { guildID: interaction.guild.id } });
|
||||
return interaction.editReply({ content: `The leave message has been set to ${args.message}`, ephemeral: true });
|
||||
}
|
||||
else if (interactionMenu.customId === `remove${interaction.user.id}${originalId}`) {
|
||||
db.leaveChannel.destroy({ where: { guildID: interaction.guild.id, channelID: interaction.channel.id } });
|
||||
return interaction.editReply({ content: 'The leave message has been deleted.', ephemeral: true });
|
||||
}
|
||||
else {
|
||||
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
|
||||
}
|
||||
});
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class cbCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'cb',
|
||||
group: 'admin',
|
||||
memberName: 'cb',
|
||||
description: 'spam a bunch of dot to quickly make something disspear',
|
||||
userPermissions: ['MANAGE_MESSAGES'],
|
||||
guildOnly: true,
|
||||
});
|
||||
}
|
||||
|
||||
run(message) {
|
||||
message.say('.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.')
|
||||
}
|
||||
};
|
||||
|
@ -0,0 +1,42 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class KickCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'kick',
|
||||
group: 'admin',
|
||||
memberName: 'kick',
|
||||
description: 'Kick the mentionned user',
|
||||
guildOnly: true,
|
||||
clientPermissions: ['KICK_MEMBERS'],
|
||||
userPermissions: ['KICK_MEMBERS'],
|
||||
args: [
|
||||
{
|
||||
key: 'member',
|
||||
prompt: 'Wich member would you like to kick?',
|
||||
type: 'member',
|
||||
},
|
||||
{
|
||||
key: 'reasons',
|
||||
prompt: 'What is the reasons of the kick',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { member, reasons }) {
|
||||
if(member == this.client)
|
||||
message.say('Cant kick me fool')
|
||||
if(!reasons)
|
||||
reasons = 'Nothing have been specified.'
|
||||
if(member.id === message.author.id)
|
||||
return message.say("Why would you kick yourself ?")
|
||||
await member.send(`You have been kicked for the following reasons: "${reasons}"`)
|
||||
.error(err => console.error(`Could not dm the user, probably disabled\n${err}`))
|
||||
member.kick(`Kicked by : ${message.author.username} for the following reasons : ${reasons}`)
|
||||
.then(() => message.reply(`${member.user.username} was succesfully kicked with the following reasons "${reasons}".`))
|
||||
};
|
||||
};
|
@ -0,0 +1,32 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class PruneCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'prune',
|
||||
aliases: ['purge', 'clear', 'clean'],
|
||||
group: 'admin',
|
||||
memberName: 'prune',
|
||||
description: 'Bulk delete messages.',
|
||||
clientPermissions: ['READ_MESSAGE_HISTORY', 'MANAGE_MESSAGES'],
|
||||
userPermissions: ['MANAGE_MESSAGES'],
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'amount',
|
||||
prompt: 'How many messages would you like to delete? ( choose a number between 1 & 99 )',
|
||||
type: 'integer',
|
||||
min: '1',
|
||||
max: '99'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(message, { amount }) {
|
||||
amount = amount+1
|
||||
message.channel.bulkDelete(amount, true);
|
||||
}
|
||||
};
|
||||
|
@ -1,62 +0,0 @@
|
||||
import { SlashCommandBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder, PermissionFlagsBits } from 'discord.js';
|
||||
import db from '../../models/index.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('quotation')
|
||||
.setDescription('Enable or disable quotations')
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
|
||||
category: 'admin',
|
||||
async execute(interaction, args, client) {
|
||||
const quotationstat = await db.quotationStat.findOne({ where: { serverID: interaction.guild.id } });
|
||||
|
||||
if (!quotationstat) {
|
||||
const body = { serverID: interaction.guild.id, stat: 'enable' };
|
||||
await db.quotationStat.create(body);
|
||||
return await interaction.reply({ content: 'Quotation has been enabled.', ephemeral: true });
|
||||
}
|
||||
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`yes${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Yes')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`no${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('No')
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
);
|
||||
|
||||
if (quotationstat.stat === 'enable') {
|
||||
await interaction.reply({ content: 'Quotation is already enabled, do you wish to disable it?', components: [row], ephemeral: true });
|
||||
}
|
||||
else {
|
||||
const body = { serverID: interaction.guild.id, stat: 'enable' };
|
||||
await db.autoresponseStat.update(body, { where: { serverID: interaction.guild.id } });
|
||||
return interaction.editReply({ content: 'Quotation has been enabled.', ephemeral: true });
|
||||
}
|
||||
|
||||
return listenButton(client, interaction, interaction.user);
|
||||
},
|
||||
};
|
||||
|
||||
async function listenButton(client, interaction, user = interaction.user, originalId = interaction.id) {
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (user !== interactionMenu.user) return listenButton(client, interaction, user, originalId);
|
||||
if (!interactionMenu.isButton()) return;
|
||||
|
||||
interactionMenu.update({ components: [] });
|
||||
|
||||
if (interactionMenu.customId === `yes${interaction.user.id}${originalId}`) {
|
||||
await db.quotationStat.destroy({ where: { serverID: interaction.guild.id } });
|
||||
return interaction.editReply({ content: 'Quotation has been disabled.', ephemeral: true });
|
||||
}
|
||||
else {
|
||||
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
|
||||
}
|
||||
});
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
import { SlashCommandBuilder, PermissionFlagsBits } from 'discord.js';
|
||||
import fs from 'node:fs';
|
||||
|
||||
export default {
|
||||
data: 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)),
|
||||
category: 'admin',
|
||||
userPermissions: [PermissionFlagsBits.ManageChannels],
|
||||
async execute(interaction, args) {
|
||||
if (args.remove) {
|
||||
fs.unlink(`./json/board/shame${interaction.guild.id}.json`, (err) => {
|
||||
if (err) {return interaction.reply('There is no shameboard');}
|
||||
return interaction.reply('Deleted the shameboard');
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (!args.emote || !args.count) return interaction.reply('You are missing the emote or the count arg!');
|
||||
fs.writeFile(`./json/board/shame${interaction.guild.id}.json`, `{"shameboard": "${interaction.channel.id}", "emote": "${args.emote}", "count": "${args.count}"}`, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
|
||||
return interaction.reply(`This channel have been set as the shameboard with ${args.emote} with the minimum of ${args.count}`);
|
||||
}
|
||||
},
|
||||
};
|
@ -0,0 +1,51 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class CustomResponseCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'slowmode',
|
||||
aliases: ['slow'],
|
||||
group: 'admin',
|
||||
memberName: 'slowmode',
|
||||
description: `Custom auto response`,
|
||||
userPermissions: ['MANAGE_CHANNELS'],
|
||||
clientPermissions: ['MANAGE_CHANNELS'],
|
||||
args: [
|
||||
{
|
||||
key: 'slowmodeNumber',
|
||||
prompt: 'How many seconds should the slowmode be? ( 0 to remove it )',
|
||||
type: 'integer',
|
||||
},
|
||||
{
|
||||
key: 'realtime',
|
||||
prompt: 'How long shoud it remain',
|
||||
default: '',
|
||||
type: 'integer',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { slowmodeNumber, realtime }) {
|
||||
if (slowmodeNumber > 120)
|
||||
return message.say("Slowmode can only be set to 120 seconds or lower!");
|
||||
|
||||
message.channel.setRateLimitPerUser(slowmodeNumber);
|
||||
|
||||
if (realtime) {
|
||||
let time = 60000 * realtime;
|
||||
message.say(`Slowmode have been set to ${slowmodeNumber} seconds and will end in ${realtime} minutes!`);
|
||||
setTimeout (function (){
|
||||
message.channel.setRateLimitPerUser(0);
|
||||
return message.say("Slowmode is now disabled!")
|
||||
}, time);
|
||||
} else {
|
||||
if (slowmodeNumber == 0)
|
||||
return message.say("Slowmode have been disabled!")
|
||||
return message.say(`Slowmode have been set to ${slowmodeNumber} seconds!`);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
};
|
@ -1,38 +0,0 @@
|
||||
import { SlashCommandBuilder, PermissionFlagsBits } from 'discord.js';
|
||||
import fs from 'node:fs';
|
||||
|
||||
export default {
|
||||
data: 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)),
|
||||
category: 'admin',
|
||||
userPermissions: [PermissionFlagsBits.ManageChannels],
|
||||
async execute(interaction, args) {
|
||||
if (args.remove) {
|
||||
fs.unlink(`./json/board/star${interaction.guild.id}.json`, (err) => {
|
||||
if (err) {return interaction.reply('There is no starboard');}
|
||||
return interaction.reply('Deleted the starboard');
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (!args.emote || !args.count) return interaction.reply('You are missing the emote or the count arg!');
|
||||
fs.writeFile(`./json/board/star${interaction.guild.id}.json`, `{"starboard": "${interaction.channel.id}", "emote": "${args.emote}", "count": "${args.count}"}`, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
|
||||
return interaction.reply(`This channel have been set as the starboard with ${args.emote} with the minimum of ${args.count}`);
|
||||
}
|
||||
},
|
||||
};
|
@ -1,127 +1,63 @@
|
||||
import { SlashCommandBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder, PermissionFlagsBits, PermissionsBitField } from 'discord.js';
|
||||
import os from 'node:os';
|
||||
import fs from 'node:fs';
|
||||
|
||||
import db from '../../models/index.js';
|
||||
|
||||
const { ownerId } = process.env;
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('tag')
|
||||
.setDescription('Create custom autoresponse')
|
||||
.addStringOption(option =>
|
||||
option.setName('trigger')
|
||||
.setDescription('The strings that will trigger the tag')
|
||||
.setRequired(false))
|
||||
.addStringOption(option =>
|
||||
option.setName('response')
|
||||
.setDescription('What it will answer back')
|
||||
.setRequired(false))
|
||||
.addBooleanOption(option =>
|
||||
option.setName('remove')
|
||||
.setDescription('(ADMIN ONLY!) Remove the tag')
|
||||
.setRequired(false))
|
||||
.addBooleanOption(option =>
|
||||
option.setName('list')
|
||||
.setDescription('List all the tags for the server')
|
||||
.setRequired(false)),
|
||||
category: 'admin',
|
||||
userPermissions: [PermissionFlagsBits.ManageChannels],
|
||||
async execute(interaction, args, client) {
|
||||
await interaction.deferReply();
|
||||
|
||||
if (args.list) {
|
||||
let tagList = await db.Tag.findAll({ attributes: ['trigger', 'response', 'ownerID'], where: { serverID: interaction.guild.id } });
|
||||
|
||||
if (args.trigger) {
|
||||
tagList = await db.Tag.findOne({ attributes: ['trigger', 'response', 'ownerID'], where: { trigger: args.trigger, serverID: interaction.guild.id } });
|
||||
}
|
||||
|
||||
if (!tagList) return interaction.editReply('It looks like the server has no tags.');
|
||||
|
||||
const path = `${os.tmpdir()}/${interaction.guild.id}.json`;
|
||||
fs.writeFile(path, JSON.stringify(tagList, null, 2), function(err) {
|
||||
if (err) return console.error(err);
|
||||
});
|
||||
return interaction.editReply({ files: [path] });
|
||||
}
|
||||
|
||||
const tag = await db.Tag.findOne({ where: { trigger: args.trigger, serverID: interaction.guild.id } });
|
||||
|
||||
if (args.remove) {
|
||||
if (tag) {
|
||||
if (tag.get('ownerID') == interaction.user.id || interaction.member.permissionsIn(interaction.channel).has(PermissionsBitField.Flags.Administrator) || interaction.user.id == ownerId) {
|
||||
db.Tag.destroy({ where: { trigger: args.trigger, serverID: interaction.guild.id } });
|
||||
return interaction.editReply('successfully deleted the following tag: ' + args.trigger);
|
||||
}
|
||||
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`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return interaction.editReply('Did not find the specified tag, are you sure it exist?');
|
||||
}
|
||||
}
|
||||
|
||||
if (!args.trigger) return interaction.editReply('You need to specify what you want me to respond to.');
|
||||
if (!args.response) return interaction.editReply('You need to specify what you want me to answer with.');
|
||||
|
||||
if (!tag) {
|
||||
const body = { trigger: args.trigger, response: args.response, ownerID: interaction.user.id, serverID: interaction.guild.id };
|
||||
await db.Tag.create(body);
|
||||
return interaction.editReply(`tag have been set to ${args.trigger} : ${args.response}`);
|
||||
}
|
||||
else if (tag.get('ownerID') == interaction.user.id || interaction.member.permissionsIn(interaction.channel).has('ADMINISTRATOR') || interaction.user.id == ownerId) {
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`edit${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Edit')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`remove${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Remove')
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`nothing${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Do nothing')
|
||||
.setStyle(ButtonStyle.Secondary),
|
||||
);
|
||||
|
||||
await interaction.editReply({ content: 'This tag already exist, do you want to update it, remove it or do nothing?', components: [row], ephemeral: true });
|
||||
|
||||
return listenButton(client, interaction, args, interaction.user);
|
||||
}
|
||||
else {
|
||||
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`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
async function listenButton(client, interaction, args, user = interaction.user, originalId = interaction.id) {
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (user !== interactionMenu.user) return listenButton(client, interaction, args, user, originalId);
|
||||
if (!interactionMenu.isButton()) return;
|
||||
|
||||
await interactionMenu.update({ components: [] });
|
||||
|
||||
if (interactionMenu.customId === `edit${interaction.user.id}${originalId}`) {
|
||||
const body = { trigger: args.trigger, response: args.response, ownerID: interaction.user.id, serverID: interaction.guild.id };
|
||||
db.Tag.update(body, { where: { serverID: interaction.guild.id } });
|
||||
return interaction.editReply({ content: `The tag ${args.trigger} has been set to ${args.response}`, ephemeral: true });
|
||||
}
|
||||
else if (interactionMenu.customId === `remove${interaction.user.id}${originalId}`) {
|
||||
db.Tag.destroy({ where: { trigger: args.trigger, serverID: interaction.guild.id } });
|
||||
return interaction.editReply({ content: `The tag ${args.trigger} has been deleted`, ephemeral: true });
|
||||
}
|
||||
else {
|
||||
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
const { Command } = require('discord.js-commando');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = class CustomResponseCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'tag',
|
||||
aliases: ['customresponse'],
|
||||
group: 'admin',
|
||||
memberName: 'tag',
|
||||
description: `Custom auto response`,
|
||||
userPermissions: ['MANAGE_MESSAGES'],
|
||||
args: [
|
||||
{
|
||||
key: 'trigger',
|
||||
prompt: 'The word that will trigger the autoresponse (use "--" instead of spaces)',
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
key: 'response',
|
||||
prompt: 'The response to the word ( you can use spaces here )',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { trigger, response }) {
|
||||
if(blacklist[message.author.id])
|
||||
return message.channel.send("You are blacklisted")
|
||||
|
||||
trigger = trigger.toLowerCase();
|
||||
do {
|
||||
trigger = trigger.replace('--', ' ')
|
||||
} while (trigger.includes('--'))
|
||||
|
||||
let customresponse = {}
|
||||
let json = JSON.stringify(customresponse)
|
||||
|
||||
|
||||
|
||||
|
||||
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
||||
if (err){
|
||||
fs.writeFile(`./tag/${message.guild.id}.json`, `{"${trigger}":"${response}"}`, function (err) {
|
||||
if (err){
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
customresponse = JSON.parse(data); //now it an object
|
||||
customresponse [trigger] = response
|
||||
json = JSON.stringify(customresponse); //convert it back to json
|
||||
fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function(err) {
|
||||
if(err) {
|
||||
return console.log(err);
|
||||
}
|
||||
})}});
|
||||
|
||||
return message.say(`autoresponse have been set to ${trigger} : ${response}`);
|
||||
}
|
||||
};
|
@ -0,0 +1,28 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class UnbanCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'unban',
|
||||
group: 'admin',
|
||||
memberName: 'unban',
|
||||
description: 'unban the provided id',
|
||||
guildOnly: true,
|
||||
clientPermissions: ['BAN_MEMBERS'],
|
||||
userPermissions: ['BAN_MEMBERS'],
|
||||
args: [
|
||||
{
|
||||
key: 'member',
|
||||
prompt: 'Wich member would you like to unban?',
|
||||
type: 'user',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { member }) {
|
||||
message.guild.unban(member)
|
||||
.then(() => message.reply(`user was succesfully unbanned.`));
|
||||
};
|
||||
};
|
@ -0,0 +1,48 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
const fs = require('fs');
|
||||
module.exports = class CustomResponseCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'untag',
|
||||
aliases: ['rmcustomresponse'],
|
||||
group: 'admin',
|
||||
memberName: 'untag',
|
||||
description: `remove custom autoresponse`,
|
||||
userPermissions: ['MANAGE_MESSAGES'],
|
||||
args: [
|
||||
{
|
||||
key: 'trigger',
|
||||
prompt: 'What is the word to remove',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { trigger }) {
|
||||
if(blacklist[message.author.id])
|
||||
return message.channel.send("You are blacklisted")
|
||||
|
||||
trigger = trigger.toLowerCase();
|
||||
|
||||
let customresponse = {}
|
||||
let json = JSON.stringify(customresponse)
|
||||
|
||||
|
||||
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
||||
if (err){
|
||||
console.log(err);
|
||||
} else {
|
||||
customresponse = JSON.parse(data); //now it an object
|
||||
delete customresponse[trigger]
|
||||
json = JSON.stringify(customresponse); //convert it back to json
|
||||
fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function(err) {
|
||||
if(err) {
|
||||
return console.log(err);
|
||||
}
|
||||
})}});
|
||||
|
||||
return message.say(`The following autoresponse have been deleted: ${trigger}`);
|
||||
}
|
||||
};
|
@ -1,75 +0,0 @@
|
||||
import { SlashCommandBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder, PermissionFlagsBits } from 'discord.js';
|
||||
import db from '../../models/index.js';
|
||||
|
||||
export default {
|
||||
data: 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.')),
|
||||
category: 'admin',
|
||||
userPermissions: [PermissionFlagsBits.ManageChannels],
|
||||
async execute(interaction, args, client) {
|
||||
const join = await db.joinChannel.findOne({ where: { guildID: interaction.guild.id } });
|
||||
|
||||
if (!join && !args.message) {
|
||||
return interaction.reply({ content: 'You need a message for me to say anything!', ephemeral: true });
|
||||
}
|
||||
else if (!join) {
|
||||
const body = { guildID: interaction.guild.id, channelID: interaction.channel.id, message: args.message };
|
||||
await db.joinChannel.create(body);
|
||||
return interaction.reply({ content: `The join message have been set with ${args.message}`, ephemeral: true });
|
||||
}
|
||||
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`edit${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Edit')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`remove${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Remove')
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`nothing${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Do nothing')
|
||||
.setStyle(ButtonStyle.Secondary),
|
||||
);
|
||||
|
||||
await interaction.reply({ content: 'The server already has a message set, do you want to edit it or remove it?', components: [row], ephemeral: true });
|
||||
|
||||
return listenButton(client, interaction, args, interaction.user);
|
||||
},
|
||||
};
|
||||
|
||||
async function listenButton(client, interaction, args, user = interaction.user, originalId = interaction.id) {
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (user !== interactionMenu.user) return listenButton(client, interaction, args, user, originalId);
|
||||
if (!interactionMenu.isButton()) return;
|
||||
|
||||
await interactionMenu.update({ components: [] });
|
||||
|
||||
if (interactionMenu.customId === `edit${interaction.user.id}${originalId}`) {
|
||||
if (!args.message) {
|
||||
return interaction.reply({ content: 'You need to input a message for me to edit!', ephemeral: true });
|
||||
}
|
||||
const body = { guildID: interaction.guild.id, channelID: interaction.channel.id, message: args.message };
|
||||
await db.joinChannel.update(body, { where: { guildID: interaction.guild.id } });
|
||||
return interaction.editReply({ content: `The join message has been set to ${args.message}`, ephemeral: true });
|
||||
}
|
||||
else if (interactionMenu.customId === `remove${interaction.user.id}${originalId}`) {
|
||||
db.joinChannel.destroy({ where: { guildID: interaction.guild.id, channelID: interaction.channel.id } });
|
||||
return interaction.editReply({ content: 'The join message has been deleted.', ephemeral: true });
|
||||
}
|
||||
else {
|
||||
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
|
||||
}
|
||||
});
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import TurndownService from 'turndown';
|
||||
const turndown = new TurndownService();
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
import fourChan from '../../json/4chan.json' assert {type: 'json'};
|
||||
|
||||
export default {
|
||||
data: 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)),
|
||||
category: 'fun',
|
||||
async execute(interaction, args) {
|
||||
let board = args.board;
|
||||
|
||||
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 });
|
||||
}
|
||||
|
||||
if (fourChan[board].nsfw && !interaction.channel.nsfw) {
|
||||
return interaction.reply({ content: 'Uh oh! This is a NSFW board! Try again in a NSFW channel!', ephemeral: true });
|
||||
}
|
||||
await interaction.deferReply({ ephemeral: false });
|
||||
|
||||
board = board.replace(/\//g, '');
|
||||
let i = Math.floor((Math.random() * 5) + 1);
|
||||
|
||||
|
||||
fetch(`https://a.4cdn.org/${board}/${i}.json`).then((response) => {
|
||||
return response.json();
|
||||
}).then((response) => {
|
||||
if (!response.threads) {
|
||||
return interaction.editReply('Not a valid board! Try again!');
|
||||
}
|
||||
|
||||
i = Math.floor((Math.random() * response.threads.length) + 1);
|
||||
|
||||
// Loop until it found a threads
|
||||
while (!response.threads[i]) {
|
||||
i = Math.floor((Math.random() * response.threads.length) + 1);
|
||||
}
|
||||
|
||||
// If post is sticky search again
|
||||
while (response.threads[i].posts[0].sticky == 1 || !response.threads[i].posts) {
|
||||
i = Math.floor((Math.random() * response.threads.length));
|
||||
}
|
||||
|
||||
let title = response.threads[i].posts[0].sub;
|
||||
let description = response.threads[i].posts[0].com;
|
||||
let boardName = fourChan[board].title;
|
||||
if (boardName == undefined) {
|
||||
boardName = board;
|
||||
}
|
||||
|
||||
// If title or description is undefined, change it to "no title/description"
|
||||
if (!description) {
|
||||
description = 'No description';
|
||||
}
|
||||
|
||||
if (!title) {
|
||||
title = 'No title';
|
||||
}
|
||||
|
||||
const FourchanEmbed = new EmbedBuilder()
|
||||
.setColor(interaction.member ? interaction.member.displayHexColor : 'Navy')
|
||||
.setTitle(turndown.turndown(title))
|
||||
.setDescription(turndown.turndown(description))
|
||||
.setImage(`https://i.4cdn.org/${board}/${response.threads[i].posts[0].tim}${response.threads[i].posts[0].ext}`)
|
||||
.setURL(`https://boards.4chan.org/${board}/thread/${response.threads[i].posts[0].no}/${response.threads[i].posts[0].semantic_url}`)
|
||||
.setFooter({ text: `${boardName} | ${response.threads[i].posts[0].name} | ${response.threads[i].posts[0].no} | ${response.threads[i].posts[0].now}` });
|
||||
|
||||
// If file type dosen't work on embed, send it as a link
|
||||
if (response.threads[i].posts[0].ext == '.webm' || response.threads[i].posts[0].ext == '.pdf' || response.threads[i].posts[0].ext == '.swf') {
|
||||
interaction.editReply({ embeds: [FourchanEmbed] });
|
||||
interaction.followUp(`https://i.4cdn.org/${board}/${response.threads[i].posts[0].tim}${response.threads[i].posts[0].ext}`);
|
||||
|
||||
}
|
||||
else {
|
||||
interaction.editReply({ embeds: [FourchanEmbed] });
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err.type == 'invalid-json') return interaction.editReply('Could not find the board! Try again!');
|
||||
console.error(err);
|
||||
return interaction.editReply('Uh-oh, an error has occurred! Try again! If this keeps happening, tell the developers!');
|
||||
});
|
||||
},
|
||||
};
|
@ -0,0 +1,34 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const fetch = require('node-fetch')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
module.exports = class AdviceCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'advice',
|
||||
group: 'fun',
|
||||
memberName: 'advice',
|
||||
description: `Show some random advice`,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
fetch("http://api.adviceslip.com/advice").then((response) => {
|
||||
return response.json();
|
||||
}).then((response) => {
|
||||
const adviceEmbed = new Discord.RichEmbed()
|
||||
.setColor("#ff9900")
|
||||
.setTitle(response.slip.slip_id)
|
||||
.setDescription(response.slip.advice)
|
||||
|
||||
|
||||
message.say(adviceEmbed);
|
||||
});
|
||||
}};
|
@ -1,60 +0,0 @@
|
||||
/* TODO
|
||||
*
|
||||
* Merge with commands/fun/image2audio.js
|
||||
*
|
||||
*/
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import fetch from 'node-fetch';
|
||||
import util from 'node:util';
|
||||
import stream from 'node:stream';
|
||||
import utils from '../../utils/videos.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('audio2image')
|
||||
.setDescription('Transform an audio file into an image.')
|
||||
.addAttachmentOption(option =>
|
||||
option.setName('audio')
|
||||
.setDescription('The audio that will become image.')
|
||||
.setRequired(true)),
|
||||
category: 'fun',
|
||||
alias: ['a2i'],
|
||||
async execute(interaction, args) {
|
||||
if (!args.audio) return interaction.reply('Please attach an image with your message.');
|
||||
|
||||
await interaction.deferReply();
|
||||
|
||||
ifExistDelete(`${os.tmpdir()}/${args.audio.name}`);
|
||||
ifExistDelete(`${os.tmpdir()}/${args.audio.name}.png`);
|
||||
ifExistDelete(`${os.tmpdir()}/${args.audio.name}.sw`);
|
||||
ifExistDelete(`${os.tmpdir()}/${args.audio.name}.mp3`);
|
||||
|
||||
const streamPipeline = util.promisify(stream.pipeline);
|
||||
const res = await fetch(args.audio.url);
|
||||
if (!res.ok) return interaction.editReply('An error has occured while trying to download your image.');
|
||||
await streamPipeline(res.body, fs.createWriteStream(`${os.tmpdir()}/${args.audio.name}`));
|
||||
|
||||
await utils.ffmpeg(['-i', `${os.tmpdir()}/${args.audio.name}`, '-sample_rate', '44100', '-ac', '1', '-f', 's16le', '-acodec', 'pcm_s16le', `${os.tmpdir()}/${args.audio.name}.sw`]);
|
||||
await utils.ffmpeg(['-pixel_format', 'rgb24', '-video_size', '128x128', '-f', 'rawvideo', '-i', `${os.tmpdir()}/${args.audio.name}.sw`, '-frames:v', '1', `${os.tmpdir()}/${args.audio.name}.png`]);
|
||||
|
||||
const file = fs.statSync(`${os.tmpdir()}/${args.audio.name}.png`);
|
||||
const fileSize = (file.size / 1000000.0).toFixed(2);
|
||||
|
||||
if (fileSize > await utils.getMaxFileSize(interaction.guild)) return interaction.editReply('error');
|
||||
interaction.editReply({ content: `Image file is ${fileSize} MB` });
|
||||
return interaction.followUp({ files: [`${os.tmpdir()}/${args.audio.name}.png`] });
|
||||
},
|
||||
};
|
||||
|
||||
async function ifExistDelete(path) {
|
||||
if (fs.existsSync(path)) {
|
||||
fs.rm(path, (err) => {
|
||||
console.log('deleted');
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const fetch = require('node-fetch')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
module.exports = class BadMemeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'badmeme',
|
||||
group: 'fun',
|
||||
memberName: 'badmeme',
|
||||
description: `Take random images from imgur`,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
fetch("https://api.imgur.com/3/gallery/hot/day?showViral=true&mature=false&perPage=100&album_previews=true", {
|
||||
headers: { "Authorization": "Client-ID e4cb6948f80f295" },
|
||||
}).then((response) => {
|
||||
return response.json();
|
||||
}).then((response) => {
|
||||
if (response.success == 'false')
|
||||
return message.say('An error has occured')
|
||||
|
||||
const i = Math.floor((Math.random() * response.data.length));
|
||||
|
||||
message.say(`**${response.data[i].title}**`)
|
||||
message.say(response.data[i].link);
|
||||
});
|
||||
}};
|
@ -0,0 +1,30 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class clapCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'clap',
|
||||
group: 'fun',
|
||||
memberName: 'clap',
|
||||
description: `Repeat the text you send with clap`,
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you want me to say',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { text }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let clap = text.replace(/ /g, ' 👏 ');
|
||||
message.delete();
|
||||
message.say(`${clap} 👏`);
|
||||
}};
|
@ -0,0 +1,25 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const responseObject = require("../../json/randVid.json");
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class dankCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'dank',
|
||||
group: 'fun',
|
||||
memberName: 'dank',
|
||||
description: `send some random dank vid (yea sorry for that name). There is currently **${Object.keys(responseObject).length}** vid`,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
const number = Object.keys(responseObject).length;
|
||||
const vidNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1;
|
||||
message.channel.send(`${vidNumber}: ${responseObject[vidNumber]}`);
|
||||
}
|
||||
};
|
@ -0,0 +1,59 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const responseObject = require("../../json/despacito.json");
|
||||
const { createCanvas, loadImage, getContext } = require('canvas')
|
||||
const superagent = require('superagent')
|
||||
const Discord = require('discord.js');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class DespacitoCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'despacito',
|
||||
group: 'fun',
|
||||
memberName: 'despacito',
|
||||
description: `despacito`,
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'What do you want me to say',
|
||||
type: 'user',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { user }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
if (!user) {
|
||||
const number = Object.keys(responseObject).length;
|
||||
const despacitoNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1;
|
||||
return message.channel.send({files: [responseObject[despacitoNumber]]}).catch(error => {
|
||||
message.say('an error as occured')
|
||||
})
|
||||
|
||||
} else if (user.id === this.client.user.id) {
|
||||
return message.say('Nice try but you wont get me :^)');
|
||||
} else {
|
||||
const canvas = createCanvas(660, 660);
|
||||
const ctx = canvas.getContext('2d');
|
||||
const background = await loadImage(user.avatarURL);
|
||||
ctx.drawImage(background, 5, 12, canvas.width, canvas.height);
|
||||
const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/6/1539381851-untitled.png');
|
||||
const bg = await loadImage(buffer);
|
||||
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
|
||||
const attachment = new Discord.Attachment(canvas.toBuffer(), 'despacito.png');
|
||||
|
||||
message.delete();
|
||||
message.say(`${user.username}, you have been despacito'd`, attachment).catch(error => {
|
||||
message.say('an error as occured')
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
@ -0,0 +1,36 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const emojiCharacters = require('../../emojiCharacters');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class emoteSayCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'emotesay',
|
||||
group: 'fun',
|
||||
memberName: 'emotesay',
|
||||
description: `repeat the text in dancing letters`,
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you want me to say',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { text }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
message.delete();
|
||||
let emojiArray = [];
|
||||
for (let i = 0; i < text.length; i++)
|
||||
emojiArray[i] = emojiCharacters[text.toLowerCase().split('')[i]];
|
||||
message.say(emojiArray.join(""))
|
||||
|
||||
|
||||
}
|
||||
};
|
@ -1,49 +0,0 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { PermissionFlagsBits } from 'discord.js';
|
||||
export default {
|
||||
data: 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.')
|
||||
.setRequired(false)),
|
||||
category: 'fun',
|
||||
clientPermissions: [ PermissionFlagsBits.ManageWebhooks ],
|
||||
async execute(interaction, args) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
await interaction.guild.members.fetch();
|
||||
const member = args.user;
|
||||
const message = args.message;
|
||||
const attachment = args.image;
|
||||
const username = member.nickname ? member.nickname : member.user.username;
|
||||
|
||||
const webhook = await interaction.channel.createWebhook({
|
||||
name: username,
|
||||
avatar: member.user.displayAvatarURL(),
|
||||
reason: `Fakebot/user command triggered by: ${interaction.user.username}`,
|
||||
});
|
||||
if (attachment) {
|
||||
await webhook.send({ content: message, files: [attachment] });
|
||||
}
|
||||
else {
|
||||
await webhook.send({ content: message });
|
||||
}
|
||||
await webhook.delete(`Fakebot/user command triggered by: ${interaction.user.username}`);
|
||||
if (interaction.isMessage) {
|
||||
await interaction.delete();
|
||||
await interaction.deleteReply();
|
||||
}
|
||||
else {
|
||||
await interaction.editReply({ content: `Faked the user ${member}` });
|
||||
}
|
||||
},
|
||||
};
|
@ -0,0 +1,25 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const responseObject = require("../../json/funfact.json");
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class FunFactCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'funfact',
|
||||
group: 'fun',
|
||||
memberName: 'funfact',
|
||||
description: `Send some fun fact. If you would like to see some of yours fun fact you can send them to @Supositware | Baguette#8211. There is currently **${Object.keys(responseObject).length}** fun fact.`,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
const number = Object.keys(responseObject).length;
|
||||
const funFactNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1;
|
||||
message.channel.send(`Fun fact: ${responseObject[funFactNumber]}`);
|
||||
}
|
||||
};
|
@ -1,93 +0,0 @@
|
||||
// Tried something to make it work purely with slash commands but it did not work.
|
||||
// The interaction created from a modal lack the showModal function so I can't just call another modal on top
|
||||
// A "solution" for this that I could see is creating a button between each response asking the player to continue or stop which would create a new interaction and (maybe) allow to display a new modal
|
||||
import { SlashCommandBuilder, ActionRowBuilder, TextInputBuilder, SelectMenuBuilder, ModalBuilder, TextInputStyle, InteractionType } from 'discord.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('guess')
|
||||
.setDescription('Guess the number'),
|
||||
category: 'fun',
|
||||
async execute(interaction, args, client) {
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new SelectMenuBuilder()
|
||||
.setCustomId('difficulty')
|
||||
.setPlaceholder('Nothing selected')
|
||||
.addOptions([
|
||||
{ label: 'Easy', value: '100' },
|
||||
{ label: 'Normal', value: '1000' },
|
||||
{ label: 'Hard', value: '10000' },
|
||||
]),
|
||||
);
|
||||
await interaction.reply({ content: 'Which difficulty do you want to play?', ephemeral: true, components: [row] });
|
||||
|
||||
let numberTry = 0;
|
||||
let secretnumber = 0;
|
||||
|
||||
client.on('interactionCreate', async (interactionMenu) => {
|
||||
if (interaction.user !== interactionMenu.user) return;
|
||||
|
||||
const modal = new ModalBuilder()
|
||||
.setCustomId('guessModal')
|
||||
.setTitle('Your guess');
|
||||
|
||||
|
||||
const textRow = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new TextInputBuilder()
|
||||
.setCustomId('input')
|
||||
.setLabel('What is the number?')
|
||||
.setStyle(TextInputStyle.Short),
|
||||
);
|
||||
|
||||
modal.addComponents(textRow);
|
||||
|
||||
async function tryAgain(input) {
|
||||
if (input != secretnumber) {
|
||||
if (input > secretnumber) {
|
||||
modal.setTitle('Its less!\nWhat is the number?');
|
||||
}
|
||||
else if (input < secretnumber) {
|
||||
modal.setTitle('Its more!\nWhat is the number?');
|
||||
}
|
||||
}
|
||||
await interactionMenu.showModal(modal);
|
||||
}
|
||||
|
||||
async function checkNumber(input) {
|
||||
numberTry++;
|
||||
if (input.toLowerCase() === 'stop') {
|
||||
return interaction.reply('Ok, let\'s stop playing :(');
|
||||
}
|
||||
else if (input != secretnumber) {
|
||||
console.log('trying again');
|
||||
tryAgain(input);
|
||||
}
|
||||
else if (numberTry > 1) {
|
||||
return interaction.reply(`Congratulations! You won! It took you ${numberTry} turns!`);
|
||||
}
|
||||
else {
|
||||
return interaction.reply('Congratulations! You won! It took you 1 Turn!');
|
||||
}
|
||||
}
|
||||
|
||||
if (interactionMenu.type === InteractionType.ModalSubmit) {
|
||||
if (interactionMenu.customId === 'guessModal') {
|
||||
const input = interactionMenu.fields.getTextInputValue('input');
|
||||
checkNumber(input);
|
||||
}
|
||||
|
||||
}
|
||||
else if (interactionMenu.isSelectMenu()) {
|
||||
if (interactionMenu.customId === 'difficulty') {
|
||||
secretnumber = Math.floor((Math.random() * parseInt(interactionMenu.values[0])) + 1);
|
||||
console.log(secretnumber);
|
||||
|
||||
// await interaction.followUp({ content: 'What is the number?', ephemeral: true });
|
||||
await interactionMenu.showModal(modal);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
@ -0,0 +1,26 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const fetch = require('node-fetch')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
module.exports = class BadMemeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'ib',
|
||||
aliases: ['inspirobot'],
|
||||
group: 'fun',
|
||||
memberName: 'ib',
|
||||
description: `Return a random inspiration from inspirobot`,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
fetch('http://inspirobot.me/api?generate=true')
|
||||
.then(res => res.text())
|
||||
.then(body => message.channel.send({files: [body]}))
|
||||
}}
|
@ -1,59 +0,0 @@
|
||||
/* TODO
|
||||
*
|
||||
* Merge with commands/fun/audio2image.js
|
||||
*
|
||||
*/
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import fetch from 'node-fetch';
|
||||
import util from 'node:util';
|
||||
import stream from 'node:stream';
|
||||
import utils from '../../utils/videos.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('image2audio')
|
||||
.setDescription('Transform an image binary data into audio ( MIGHT BE VERY LOUD )')
|
||||
.addAttachmentOption(option =>
|
||||
option.setName('img')
|
||||
.setDescription('The image that will become audio. Only tested with png and jpg.')
|
||||
.setRequired(true)),
|
||||
category: 'fun',
|
||||
alias: ['i2a'],
|
||||
async execute(interaction, args) {
|
||||
if (!args.img) return interaction.reply('Please attach an image with your message.');
|
||||
|
||||
await interaction.deferReply();
|
||||
|
||||
ifExistDelete(`${os.tmpdir()}/${args.img.name}`);
|
||||
ifExistDelete(`${os.tmpdir()}/1${args.img.name}`);
|
||||
ifExistDelete(`${os.tmpdir()}/${args.img.name}.mp3`);
|
||||
|
||||
const streamPipeline = util.promisify(stream.pipeline);
|
||||
const res = await fetch(args.img.url);
|
||||
if (!res.ok) return interaction.editReply('An error has occured while trying to download your image.');
|
||||
await streamPipeline(res.body, fs.createWriteStream(`${os.tmpdir()}/${args.img.name}`));
|
||||
|
||||
await utils.ffmpeg(['-i', `${os.tmpdir()}/${args.img.name}`, '-f', 'rawvideo', `${os.tmpdir()}/1${args.img.name}`]);
|
||||
await utils.ffmpeg(['-sample_rate', '44100', '-ac', '1', '-f', 's16le', '-i', `${os.tmpdir()}/1${args.img.name}`, `${os.tmpdir()}/${args.img.name}.mp3`]);
|
||||
|
||||
const file = fs.statSync(`${os.tmpdir()}/${args.img.name}.mp3`);
|
||||
const fileSize = (file.size / 1000000.0).toFixed(2);
|
||||
|
||||
if (fileSize > await utils.getMaxFileSize(interaction.guild)) return interaction.editReply('error');
|
||||
interaction.editReply({ content: `Audio file is ${fileSize} MB` });
|
||||
return interaction.followUp({ files: [`${os.tmpdir()}/${args.img.name}.mp3`] });
|
||||
},
|
||||
};
|
||||
|
||||
async function ifExistDelete(path) {
|
||||
if (fs.existsSync(path)) {
|
||||
fs.rm(path, (err) => {
|
||||
console.log('deleted');
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
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',
|
||||
alias: ['ib'],
|
||||
async execute(interaction) {
|
||||
fetch('http://inspirobot.me/api?generate=true')
|
||||
.then(res => res.text())
|
||||
.then(body => interaction.reply({ files: [body] }));
|
||||
},
|
||||
};
|
@ -0,0 +1,45 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const printer = require('printer');
|
||||
const { printChannel } = require('../../config.json');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class printCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'print',
|
||||
aliases: ['dundermifflin', 'wastedevinkandmoney'],
|
||||
group: 'fun',
|
||||
memberName: 'print',
|
||||
description: 'print whatever you want using the dev printer ! ( yea really, send a feedback requesting the image and i\'il send it to you. )',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 86400,
|
||||
},
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you want to print? ( text only )',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { text }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
const channel = this.client.channels.get(printChannel);
|
||||
printer.printDirect({data:`Printed by: ${message.author.username}\n\n${text}`
|
||||
, type: 'TEXT' // type: RAW, TEXT, PDF, JPEG, .. depends on platform
|
||||
, success:function(jobID){
|
||||
console.log("sent to printer with ID: "+jobID);
|
||||
message.say("Printing now! ( You will receive your print shortly ( if the dev isint sleeping that is ))");
|
||||
channel.send(`${message.author.username} (${message.author.id}) Asked for a print with the following text: ${text}`);
|
||||
}
|
||||
, error:function(err){console.log(err); message.say("An error has occured, the printer is most likely disconnected, try again later")}
|
||||
});
|
||||
}
|
||||
};
|
@ -1,46 +1,56 @@
|
||||
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
|
||||
import fetch from 'node-fetch';
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const fetch = require('node-fetch');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const { prefix } = require('../../config.json')
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
export default {
|
||||
data: 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)),
|
||||
category: 'fun',
|
||||
async execute(interaction, args) {
|
||||
await interaction.deferReply({ ephemeral: false });
|
||||
const subreddit = args.subreddit;
|
||||
fetch('https://www.reddit.com/r/' + subreddit + '.json?limit=100').then((response) => {
|
||||
return response.json();
|
||||
}).then((response) => {
|
||||
if (response.error == 404) {
|
||||
return interaction.editReply('Not a valid subreddit');
|
||||
}
|
||||
if (response.data.dist == 0) {
|
||||
return interaction.editReply('Not a valid subreddit');
|
||||
module.exports = class redditCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'reddit',
|
||||
group: 'fun',
|
||||
memberName: 'reddit',
|
||||
description: `Show a random images from the subreddit you choose`,
|
||||
args: [
|
||||
{
|
||||
key: 'sub',
|
||||
prompt: 'Wich subreddit would you like to see?',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
const i = Math.floor((Math.random() * response.data.children.length));
|
||||
if (response.data.children[i].data.over_18 == true && !interaction.channel.nsfw) {
|
||||
return interaction.editReply('No nsfw');
|
||||
}
|
||||
async run(message, { sub }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let /* the bodies hit the */ i = Math.floor((Math.random() * 10) + 1);
|
||||
let a = 0
|
||||
fetch('https://www.reddit.com/r/' + sub + '.json?limit=100').then((response) => {
|
||||
return response.json();
|
||||
}).then((response) => {
|
||||
if (!response.data)
|
||||
return message.say('Not a valid subreddit')
|
||||
while (response.data.children[i].data.post_hint !== 'image') {
|
||||
i = Math.floor((Math.random() * response.data.children.length));
|
||||
|
||||
let description = response.data.children[i].data.selftext;
|
||||
if (description === '') {
|
||||
description = 'No description.';
|
||||
}
|
||||
const redditEmbed = new EmbedBuilder()
|
||||
.setColor(interaction.member ? interaction.member.displayHexColor : 'Navy')
|
||||
.setTitle(response.data.children[i].data.title)
|
||||
.setDescription(description)
|
||||
.setURL('https://reddit.com' + response.data.children[i].data.permalink)
|
||||
.setFooter({ text: `/r/${response.data.children[i].data.subreddit} | ⬆ ${response.data.children[i].data.ups} 🗨 ${response.data.children[i].data.num_comments}` });
|
||||
|
||||
interaction.followUp({ embeds: [redditEmbed] });
|
||||
interaction.followUp(response.data.children[i].data.url);
|
||||
});
|
||||
},
|
||||
};
|
||||
a++
|
||||
if (a == 5)
|
||||
return message.say("Could not find any images")
|
||||
}
|
||||
if (response.data.children[i].data.over_18 == true)
|
||||
return message.say(`No nsfw ( if you want a nsfw version of this commands use the feedback commands "${prefix} feedback <your feedback>")`)
|
||||
const redditEmbed = new Discord.RichEmbed()
|
||||
.setColor("#ff9900")
|
||||
.setTitle(response.data.children[i].data.title)
|
||||
.setImage(response.data.children[i].data.url)
|
||||
.setURL('https://reddit.com' + response.data.children[i].data.permalink)
|
||||
.setFooter(`⬆ ${response.data.children[i].data.ups} 💬 ${response.data.children[i].data.num_comments}`)
|
||||
|
||||
message.say(redditEmbed);
|
||||
}
|
||||
|
||||
)}}
|
@ -0,0 +1,80 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class sayCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'say',
|
||||
aliases: ['repeat'],
|
||||
group: 'fun',
|
||||
memberName: 'say',
|
||||
description: `Repeat the text you send ( can also use [verb] [noun] [adverbs] [adjective] [activities] [celebrities] [countries] [diseases] [elements] [hobbies] [music] [prefixes] [pronoun] [state] [title] [unit] [member] [number] to replace it with something else )`,
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you want me to say',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { text }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
|
||||
// Load all the different files
|
||||
const verb = require('../../dictionary/verbs.json')
|
||||
const noun = require('../../dictionary/noun.json')
|
||||
const adverbs = require('../../dictionary/adjectives.json')
|
||||
const adjective = require('../../dictionary/adverbs.json')
|
||||
const activities = require('../../dictionary/activities.json')
|
||||
const celebreties = require('../../dictionary/celebreties.json')
|
||||
const countries = require('../../dictionary/countries.json')
|
||||
const diseases = require('../../dictionary/diseases.json')
|
||||
const elements = require('../../dictionary/elements.json')
|
||||
const hobbies = require('../../dictionary/hobbies.json')
|
||||
const music = require('../../dictionary/music.json')
|
||||
const prefixes = require('../../dictionary/prefixes.json')
|
||||
const pronouns = require('../../dictionary/pronouns.json')
|
||||
const states = require('../../dictionary/states.json')
|
||||
const titles = require('../../dictionary/titles.json')
|
||||
const units = require('../../dictionary/units.json')
|
||||
|
||||
|
||||
|
||||
// Generate a random number
|
||||
function randNumber(file) {
|
||||
let Rand = Math.floor((Math.random() * file.length) + 1);
|
||||
return Rand;
|
||||
}
|
||||
// Replace with a random word from the json
|
||||
do {
|
||||
text = text.replace(/\[verb\]/, verb[randNumber(verb)])
|
||||
text = text.replace(/\[adverbs\]/, adverbs[randNumber(adverbs)])
|
||||
text = text.replace(/\[noun\]/, noun[randNumber(noun)])
|
||||
text = text.replace(/\[adjective\]/, adjective[randNumber(adjective)])
|
||||
text = text.replace(/\[activities\]/, activities[randNumber(activities)])
|
||||
text = text.replace(/\[celebrities\]/, celebreties[randNumber(celebreties)])
|
||||
text = text.replace(/\[countries\]/, countries[randNumber(countries)])
|
||||
text = text.replace(/\[diseases\]/, diseases[randNumber(diseases)])
|
||||
text = text.replace(/\[elements\]/, elements[randNumber(elements)])
|
||||
text = text.replace(/\[hobbies\]/, hobbies[randNumber(hobbies)])
|
||||
text = text.replace(/\[music\]/, music[randNumber(music)])
|
||||
text = text.replace(/\[prefixes\]/, prefixes[randNumber(prefixes)])
|
||||
text = text.replace(/\[pronoun\]/, pronouns[randNumber(pronouns)])
|
||||
text = text.replace(/\[state\]/, states[randNumber(states)])
|
||||
text = text.replace(/\[title\]/, titles[randNumber(titles)])
|
||||
text = text.replace(/\[unit\]/, units[randNumber(units)])
|
||||
text = text.replace(/\[member\]/, message.guild.members.random().user.username)
|
||||
text = text.replace(/\[number\]/, Math.floor((Math.random() * 9) + 1))
|
||||
// Verify if it replaced everything
|
||||
} while( text.includes('[verb]') || text.includes('[adverbs]') || text.includes('[noun]') || text.includes('[adjective]') || text.includes('[member]') || text.includes('[number]') || text.includes('[activities]') || text.includes('[celebrities]') || text.includes('[countries]') || text.includes('[diseases]') || text.includes('[elements]') || text.includes('[hobbies]') || text.includes('[music]') || text.includes('[prefixes]') || text.includes('[pronoun]') || text.includes('[state]') || text.includes('[title]') || text.includes('[unit]'))
|
||||
|
||||
// Send the final text
|
||||
message.say(text);
|
||||
}
|
||||
};
|
@ -0,0 +1,82 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
module.exports = class saydCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'sayd',
|
||||
aliases: ['repeatd'],
|
||||
group: 'fun',
|
||||
memberName: 'sayd',
|
||||
description: `Repeat the text you send and delete it after ward( can also use [verb] [noun] [adverbs] [adjective] [activities] [celebrities] [countries] [diseases] [elements] [hobbies] [music] [prefixes] [pronoun] [state] [title] [unit] [member] [number] to replace it with something else )`,
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you want me to say',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { text }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
|
||||
// Load all the different files
|
||||
const verb = require('../../dictionary/verbs.json')
|
||||
const noun = require('../../dictionary/noun.json')
|
||||
const adverbs = require('../../dictionary/adjectives.json')
|
||||
const adjective = require('../../dictionary/adverbs.json')
|
||||
const activities = require('../../dictionary/activities.json')
|
||||
const celebreties = require('../../dictionary/celebreties.json')
|
||||
const countries = require('../../dictionary/countries.json')
|
||||
const diseases = require('../../dictionary/diseases.json')
|
||||
const elements = require('../../dictionary/elements.json')
|
||||
const hobbies = require('../../dictionary/hobbies.json')
|
||||
const music = require('../../dictionary/music.json')
|
||||
const prefixes = require('../../dictionary/prefixes.json')
|
||||
const pronouns = require('../../dictionary/pronouns.json')
|
||||
const states = require('../../dictionary/states.json')
|
||||
const titles = require('../../dictionary/titles.json')
|
||||
const units = require('../../dictionary/units.json')
|
||||
|
||||
|
||||
|
||||
// Generate a random number
|
||||
function randNumber(file) {
|
||||
let Rand = Math.floor((Math.random() * file.length) + 1);
|
||||
return Rand;
|
||||
}
|
||||
// Replace with a random word from the json
|
||||
do {
|
||||
text = text.replace(/\[verb\]/, verb[randNumber(verb)])
|
||||
text = text.replace(/\[adverbs\]/, adverbs[randNumber(adverbs)])
|
||||
text = text.replace(/\[noun\]/, noun[randNumber(noun)])
|
||||
text = text.replace(/\[adjective\]/, adjective[randNumber(adjective)])
|
||||
text = text.replace(/\[activities\]/, activities[randNumber(activities)])
|
||||
text = text.replace(/\[celebrities\]/, celebreties[randNumber(celebreties)])
|
||||
text = text.replace(/\[countries\]/, countries[randNumber(countries)])
|
||||
text = text.replace(/\[diseases\]/, diseases[randNumber(diseases)])
|
||||
text = text.replace(/\[elements\]/, elements[randNumber(elements)])
|
||||
text = text.replace(/\[hobbies\]/, hobbies[randNumber(hobbies)])
|
||||
text = text.replace(/\[music\]/, music[randNumber(music)])
|
||||
text = text.replace(/\[prefixes\]/, prefixes[randNumber(prefixes)])
|
||||
text = text.replace(/\[pronoun\]/, pronouns[randNumber(pronouns)])
|
||||
text = text.replace(/\[state\]/, states[randNumber(states)])
|
||||
text = text.replace(/\[title\]/, titles[randNumber(titles)])
|
||||
text = text.replace(/\[unit\]/, units[randNumber(units)])
|
||||
text = text.replace(/\[member\]/, message.guild.members.random().user.username)
|
||||
text = text.replace(/\[number\]/, Math.floor((Math.random() * 9) + 1))
|
||||
// Verify if it replaced everything
|
||||
} while( text.includes('[verb]') || text.includes('[adverbs]') || text.includes('[noun]') || text.includes('[adjective]') || text.includes('[member]') || text.includes('[number]') || text.includes('[activities]') || text.includes('[celebrities]') || text.includes('[countries]') || text.includes('[diseases]') || text.includes('[elements]') || text.includes('[hobbies]') || text.includes('[music]') || text.includes('[prefixes]') || text.includes('[pronoun]') || text.includes('[state]') || text.includes('[title]') || text.includes('[unit]'))
|
||||
|
||||
|
||||
// Send the final text
|
||||
message.delete();
|
||||
message.say(text);
|
||||
}
|
||||
};
|
@ -0,0 +1,58 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const textToSpeech = require('@google-cloud/text-to-speech');
|
||||
const gclient = new textToSpeech.TextToSpeechClient();
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const fs = require('fs');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
module.exports = class BadMemeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'tts',
|
||||
group: 'fun',
|
||||
memberName: 'tts',
|
||||
description: `Return what you type in a tts file`,
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you want to be said',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { text }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
// Construct the request
|
||||
const request = {
|
||||
input: {text: text},
|
||||
// Select the language and SSML Voice Gender (optional)
|
||||
voice: {languageCode: 'en-US', ssmlGender: 'NEUTRAL'},
|
||||
// Select the type of audio encoding
|
||||
audioConfig: {audioEncoding: 'MP3'},
|
||||
};
|
||||
|
||||
// Performs the Text-to-Speech request
|
||||
gclient.synthesizeSpeech(request, (err, response) => {
|
||||
if (err) {
|
||||
console.error('ERROR:', err);
|
||||
return;
|
||||
}
|
||||
|
||||
// Write the binary audio content to a local file
|
||||
fs.writeFile('tts.mp3', response.audioContent, 'binary', err => {
|
||||
if (err) {
|
||||
console.error('ERROR:', err);
|
||||
message.say('An error has occured, the message is probably too long')
|
||||
return;
|
||||
}
|
||||
console.log('Audio content written to file: tts.mp3');
|
||||
message.say({files: ['./tts.mp3']})
|
||||
});
|
||||
});
|
||||
}}
|
@ -0,0 +1,76 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const textToSpeech = require('@google-cloud/text-to-speech');
|
||||
const gclient = new textToSpeech.TextToSpeechClient();
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const fs = require('fs');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
module.exports = class ttsvcCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'ttsvc',
|
||||
group: 'fun',
|
||||
memberName: 'ttsvc',
|
||||
description: `Play what you write in tts in vc`,
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you want to be said',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { text }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
// Construct the request
|
||||
const request = {
|
||||
input: {text: text},
|
||||
// Select the language and SSML Voice Gender (optional)
|
||||
voice: {languageCode: 'en-US', ssmlGender: 'NEUTRAL'},
|
||||
// Select the type of audio encoding
|
||||
audioConfig: {audioEncoding: 'MP3'},
|
||||
};
|
||||
|
||||
// Performs the Text-to-Speech request
|
||||
gclient.synthesizeSpeech(request, (err, response) => {
|
||||
if (err) {
|
||||
console.error('ERROR:', err);
|
||||
return;
|
||||
}
|
||||
|
||||
// Write the binary audio content to a local file
|
||||
fs.writeFile('ttsvc.mp3', response.audioContent, 'binary', err => {
|
||||
if (err) {
|
||||
console.error('ERROR:', err);
|
||||
message.say('An error has occured, the message is probably too long')
|
||||
return;
|
||||
}
|
||||
console.log('Audio content written to file: ttsvc.mp3');
|
||||
const { voiceChannel } = message.member;
|
||||
|
||||
// If not in voice channel ask user to join
|
||||
if (!voiceChannel) {
|
||||
return message.reply('please join a voice channel first!');
|
||||
|
||||
} else
|
||||
// If user say "stop" make the bot leave voice channel
|
||||
if (text == 'stop') {
|
||||
voiceChannel.leave();
|
||||
message.say('I leaved the channel');
|
||||
} else
|
||||
voiceChannel.join().then(connection => {
|
||||
const dispatcher = connection.playStream('./ttsvc.mp3');
|
||||
// End at then end of the audio stream
|
||||
dispatcher.on('end', () => setTimeout(function(){
|
||||
voiceChannel.leave();
|
||||
}, 2000));
|
||||
});
|
||||
});
|
||||
});
|
||||
}}
|
@ -1,90 +0,0 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import YTPGenerator from 'ytpplus-node';
|
||||
|
||||
export default {
|
||||
data: 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)),
|
||||
category: 'fun',
|
||||
ratelimit: 2,
|
||||
cooldown: 60,
|
||||
parallelLimit: 30,
|
||||
async execute(interaction, args) {
|
||||
if (!interaction.channel.nsfw && !args.force) return interaction.reply(`Please execute this command in an NSFW channel ( Content might not be NSFW but since the video are user submitted better safe than sorry ) OR do \`\`${interaction.prefix}ytp --force\`\` to make the command work outside of nsfw channel BE AWARE THAT IT WON'T CHANGE THE FINAL RESULT SO NSFW CAN STILL HAPPEN`);
|
||||
|
||||
// Read userVid folder and select random vid and only take .mp4
|
||||
const mp4 = [];
|
||||
const asset = [];
|
||||
// Count number of total vid
|
||||
fs.readdirSync('./asset/ytp/userVid/').forEach(file => {
|
||||
if (file.endsWith('mp4')) {
|
||||
mp4.push(file);
|
||||
}
|
||||
});
|
||||
const MAX_CLIPS = 20;
|
||||
// Select random vid depending on the amount of MAX_CLIPS
|
||||
for (let i = 0; i < MAX_CLIPS; i++) {
|
||||
const random = Math.floor(Math.random() * mp4.length);
|
||||
const vid = `./asset/ytp/userVid/${mp4[random]}`;
|
||||
if (mp4[random].endsWith('mp4')) {
|
||||
if (!asset.includes(vid)) {
|
||||
asset.push(vid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const loadingmsg = await interaction.reply(`Processing, this can take a ***long*** time, i'll ping you when I finished <a:loadingmin:527579785212329984>\nSome info: There are currently ${mp4.length} videos, why not add yours? You can do so with the \`\`addytp\`\` command.\nLike ytp? Why not check out https://ytp.namejeff.xyz/`);
|
||||
|
||||
const options = {
|
||||
debug: false,
|
||||
MAX_STREAM_DURATION: Math.floor((Math.random() * 3) + 1),
|
||||
sources: './asset/ytp/sources/',
|
||||
sounds: './asset/ytp/sounds/',
|
||||
music: './asset/ytp/music/',
|
||||
resources: './asset/ytp/resources/',
|
||||
temp: os.tmpdir(),
|
||||
sourceList: asset,
|
||||
intro: args.force ? './asset/ytp/intro.mp4' : null,
|
||||
outro: './asset/ytp/outro.mp4',
|
||||
OUTPUT_FILE: `${os.tmpdir()}/${interaction.id}_YTP.mp4`,
|
||||
MAX_CLIPS: MAX_CLIPS,
|
||||
transitions: true,
|
||||
showFileNames: true,
|
||||
effects: {
|
||||
effect_RandomSound: true,
|
||||
effect_RandomSoundMute: true,
|
||||
effect_Reverse: true,
|
||||
effect_Chorus: true,
|
||||
effect_Vibrato: true,
|
||||
effect_HighPitch: true,
|
||||
effect_LowPitch: true,
|
||||
effect_SpeedUp: true,
|
||||
effect_SlowDown: true,
|
||||
effect_Dance: true,
|
||||
effect_Squidward: true,
|
||||
effect_How: true,
|
||||
},
|
||||
};
|
||||
|
||||
await new YTPGenerator().configurateAndGo(options)
|
||||
.then(() => {
|
||||
loadingmsg.delete();
|
||||
return interaction.followUp({ content: 'Here is your YTP! Remember, it might contain nsfw, so be careful!', files: [`${os.tmpdir()}/${interaction.id}_YTP.mp4`] })
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
return interaction.followUp({ files: [`./asset/ytp/error${Math.floor(Math.random() * 2) + 1}.mp4`] });
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
loadingmsg.delete();
|
||||
return interaction.followUp({ files: [`./asset/ytp/error${Math.floor(Math.random() * 2) + 1}.mp4`] });
|
||||
});
|
||||
},
|
||||
};
|
@ -0,0 +1,52 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const { createCanvas, loadImage, getContext } = require('canvas')
|
||||
const superagent = require('superagent')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = class fetishCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'fetish',
|
||||
group: 'images',
|
||||
memberName: 'fetish',
|
||||
description: `My fetish`,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let Attachment = (message.attachments).array();
|
||||
let image = null
|
||||
if (!Attachment[0])
|
||||
image = message.author.displayAvatarURL
|
||||
else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
|
||||
return message.say('Gif dosent work, sorry')
|
||||
else
|
||||
image = Attachment[0].url
|
||||
|
||||
const canvas = createCanvas(528, 559)
|
||||
const ctx = canvas.getContext('2d')
|
||||
const background = await loadImage('https://image.noelshack.com/fichiers/2018/42/2/1539644291-my-fetish-5910119d988512.png').catch(error => {
|
||||
return message.say('An error as occured, please try again')
|
||||
})
|
||||
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
|
||||
const { body: buffer } = await superagent.get(image);
|
||||
const bg = await loadImage(buffer);
|
||||
ctx.drawImage(bg, 50, 50, 450, 450);
|
||||
|
||||
const attachment = new Discord.Attachment(canvas.toBuffer(), 'myfetish.png');
|
||||
|
||||
message.say(attachment).catch(error => {
|
||||
message.say('an error as occured. Check the bot/channel permissions')
|
||||
})
|
||||
|
||||
}
|
||||
};
|
@ -0,0 +1,52 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const { createCanvas, loadImage, getContext } = require('canvas')
|
||||
const superagent = require('superagent')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = class godCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'god',
|
||||
group: 'images',
|
||||
memberName: 'god',
|
||||
description: `Retweet if you aren't afraid to have a picture of god on your timeline`,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let Attachment = (message.attachments).array();
|
||||
let image = null
|
||||
if (!Attachment[0])
|
||||
image = message.author.displayAvatarURL
|
||||
else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
|
||||
return message.say('Gif dosent work, sorry')
|
||||
else
|
||||
image = Attachment[0].url
|
||||
|
||||
const canvas = createCanvas(310, 400)
|
||||
const ctx = canvas.getContext('2d')
|
||||
const background = await loadImage(image);
|
||||
ctx.drawImage(background, 20, 80, 275, 250);
|
||||
const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/42/1/1539555260-untitled.png').catch(error => {
|
||||
return message.say('An error as occured, please try again')
|
||||
})
|
||||
const bg = await loadImage(buffer);
|
||||
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
|
||||
|
||||
const attachment = new Discord.Attachment(canvas.toBuffer(), 'god.png');
|
||||
|
||||
message.say(attachment).catch(error => {
|
||||
message.say('an error as occured. Check the bot/channel permissions')
|
||||
})
|
||||
|
||||
}
|
||||
};
|
@ -0,0 +1,52 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const { createCanvas, loadImage, getContext } = require('canvas')
|
||||
const superagent = require('superagent')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = class humanCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'human',
|
||||
group: 'images',
|
||||
memberName: 'human',
|
||||
description: `HUMAN ?! YOU DARE CALL THAT THING HUMAN?!?!`,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let Attachment = (message.attachments).array();
|
||||
let image = null
|
||||
if (!Attachment[0])
|
||||
image = message.author.displayAvatarURL
|
||||
else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
|
||||
return message.say('Gif dosent work, sorry')
|
||||
else
|
||||
image = Attachment[0].url
|
||||
|
||||
const canvas = createCanvas(578, 400)
|
||||
const ctx = canvas.getContext('2d')
|
||||
const background = await loadImage('https://image.noelshack.com/fichiers/2018/42/1/1539594726-untitled.png').catch(error => {
|
||||
return message.say('An error as occured, please try again')
|
||||
})
|
||||
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
|
||||
const { body: buffer } = await superagent.get(image);
|
||||
const bg = await loadImage(buffer);
|
||||
ctx.drawImage(bg, 420, 120, 150, 150);
|
||||
|
||||
const attachment = new Discord.Attachment(canvas.toBuffer(), 'human.png');
|
||||
|
||||
message.say(attachment).catch(error => {
|
||||
message.say('an error as occured. Check the bot/channel permissions')
|
||||
})
|
||||
|
||||
}
|
||||
};
|
@ -0,0 +1,79 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const { createCanvas, loadImage, getContext } = require('canvas')
|
||||
const superagent = require('superagent')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = class idubbbzCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'idubbbz',
|
||||
aliases: ['idubbz', 'edups'],
|
||||
group: 'images',
|
||||
memberName: 'idubbbz',
|
||||
description: `Put the text you send in idubbbz piece of paper`,
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you the paper to say?',
|
||||
type: 'string',
|
||||
default: 'Nigger Faggot'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { text }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let Attachment = (message.attachments).array();
|
||||
let image = null
|
||||
if (!Attachment[0])
|
||||
image = message.author.displayAvatarURL
|
||||
else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
|
||||
return message.say('Gif dosent work, sorry')
|
||||
else
|
||||
image = Attachment[0].url
|
||||
|
||||
const canvas = createCanvas(1281, 627)
|
||||
const applyText = (canvas, text) => {
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// Declare a base size of the font
|
||||
let fontSize = 50;
|
||||
|
||||
do {
|
||||
// Assign the font to the context and decrement it so it can be measured again
|
||||
ctx.font = `${fontSize -= 10}px ubuntu`;
|
||||
} while (ctx.measureText(text).width > 700 - 300);
|
||||
|
||||
// Return the result to use in the actual canvas
|
||||
return ctx.font;
|
||||
};
|
||||
|
||||
const ctx = canvas.getContext('2d')
|
||||
const background = await loadImage(image);
|
||||
ctx.drawImage(background, 620, 100, 200, 200);
|
||||
const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/7/1539510207-untitled.png').catch(error => {
|
||||
return message.say('An error as occured, please try again')
|
||||
})
|
||||
const bg = await loadImage(buffer);
|
||||
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
|
||||
ctx.font = applyText(canvas, text)
|
||||
ctx.fillStyle = '#000000';
|
||||
ctx.fillText(text, canvas.width / 2.1, canvas.height / 1.5);
|
||||
|
||||
const attachment = new Discord.Attachment(canvas.toBuffer(), 'edups.png');
|
||||
|
||||
message.say(attachment).catch(error => {
|
||||
message.say('an error as occured. Check the bot/channel permissions')
|
||||
})
|
||||
|
||||
}
|
||||
};
|
@ -0,0 +1,79 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const { createCanvas, loadImage, getContext } = require('canvas')
|
||||
const superagent = require('superagent')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = class idubbbzpaintCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'idubbbzpaint',
|
||||
aliases: ['idubbzpaint', 'edupspaint'],
|
||||
group: 'images',
|
||||
memberName: 'painting',
|
||||
description: `Put the image you send or you in idubbbz painting`,
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you the paper to say?',
|
||||
type: 'string',
|
||||
default: 'Perfection'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { text }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let Attachment = (message.attachments).array();
|
||||
let image = null
|
||||
if (!Attachment[0])
|
||||
image = message.author.displayAvatarURL
|
||||
else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
|
||||
return message.say('Gif dosent work, sorry')
|
||||
else
|
||||
image = Attachment[0].url
|
||||
|
||||
const canvas = createCanvas(1024, 544)
|
||||
const applyText = (canvas, text) => {
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// Declare a base size of the font
|
||||
let fontSize = 100;
|
||||
|
||||
do {
|
||||
// Assign the font to the context and decrement it so it can be measured again
|
||||
ctx.font = `${fontSize -= 10}px ubuntu`;
|
||||
} while (ctx.measureText(text).width > 800 - 300);
|
||||
|
||||
// Return the result to use in the actual canvas
|
||||
return ctx.font;
|
||||
};
|
||||
|
||||
const ctx = canvas.getContext('2d')
|
||||
const background = await loadImage(image);
|
||||
ctx.drawImage(background, 140, 40, 400, 340);
|
||||
const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/7/1539533685-untitled.png').catch(error => {
|
||||
return message.say('An error as occured, please try again')
|
||||
})
|
||||
const bg = await loadImage(buffer);
|
||||
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
|
||||
ctx.font = applyText(canvas, text)
|
||||
ctx.fillStyle = '#ffffff';
|
||||
ctx.fillText(text, canvas.width / 3, canvas.height / 1.1);
|
||||
|
||||
const attachment = new Discord.Attachment(canvas.toBuffer(), 'edupspaint.png');
|
||||
|
||||
message.say(attachment).catch(error => {
|
||||
message.say('an error as occured. Check the bot/channel permissions')
|
||||
})
|
||||
|
||||
}
|
||||
};
|
@ -0,0 +1,51 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const { createCanvas, loadImage, getContext } = require('canvas')
|
||||
const superagent = require('superagent')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
|
||||
module.exports = class likeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'like',
|
||||
group: 'images',
|
||||
memberName: 'like',
|
||||
description: `What the hell is this and why did my grandsone like it`,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let Attachment = (message.attachments).array();
|
||||
let image = null
|
||||
if (!Attachment[0])
|
||||
image = message.author.displayAvatarURL
|
||||
else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
|
||||
return message.say('Gif dosent work, sorry')
|
||||
else
|
||||
image = Attachment[0].url
|
||||
|
||||
const canvas = createCanvas(386, 399)
|
||||
const ctx = canvas.getContext('2d')
|
||||
const background = await loadImage(image);
|
||||
ctx.drawImage(background, 40, 0, 300, 255);
|
||||
const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/7/1539547403-untitled.png').catch(error => {
|
||||
return message.say('An error as occured, please try again')
|
||||
})
|
||||
const bg = await loadImage(buffer);
|
||||
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
|
||||
|
||||
const attachment = new Discord.Attachment(canvas.toBuffer(), 'like.png');
|
||||
|
||||
message.say(attachment).catch(error => {
|
||||
message.say('an error as occured. Check the bot/channel permissions')
|
||||
})
|
||||
|
||||
}
|
||||
};
|
@ -0,0 +1,51 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const { createCanvas, loadImage, getContext } = require('canvas')
|
||||
const superagent = require('superagent')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
|
||||
module.exports = class uglyCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'ugly',
|
||||
group: 'images',
|
||||
memberName: 'ugly',
|
||||
description: `You are very ugly!`,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let Attachment = (message.attachments).array();
|
||||
let image = null
|
||||
if (!Attachment[0])
|
||||
image = message.author.displayAvatarURL
|
||||
else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
|
||||
return message.say('Gif dosent work, sorry')
|
||||
else
|
||||
image = Attachment[0].url
|
||||
|
||||
const canvas = createCanvas(323, 400)
|
||||
const ctx = canvas.getContext('2d')
|
||||
const background = await loadImage('https://image.noelshack.com/fichiers/2018/42/1/1539598678-untitled.png').catch(error => {
|
||||
return message.say('An error as occured, please try again')
|
||||
})
|
||||
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
|
||||
const { body: buffer } = await superagent.get(image);
|
||||
const bg = await loadImage(buffer);
|
||||
ctx.drawImage(bg, 40, 100, 250, 250);
|
||||
|
||||
const attachment = new Discord.Attachment(canvas.toBuffer(), 'ugly.png');
|
||||
|
||||
message.say(attachment).catch(error => {
|
||||
message.say('an error as occured. Check the bot/channel permissions')
|
||||
})
|
||||
|
||||
}
|
||||
};
|
@ -0,0 +1,50 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const fs = require('fs');
|
||||
module.exports = class BlacklistCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'blacklist',
|
||||
aliases: ['niggerlist'],
|
||||
group: 'owner',
|
||||
memberName: 'blacklist',
|
||||
description: `To blacklist a user from the bot`,
|
||||
ownerOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'Who do you want to blacklist',
|
||||
type: 'user',
|
||||
},
|
||||
{
|
||||
key: 'reasons',
|
||||
prompt: 'Who do you want to blacklist',
|
||||
type: 'string',
|
||||
default: 'Didin\'t provide any reasons'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { user, reasons }) {
|
||||
let blacklist = {}
|
||||
let json = JSON.stringify(blacklist)
|
||||
|
||||
if(user) {
|
||||
fs.readFile('json/blacklist.json', 'utf8', function readFileCallback(err, data){
|
||||
if (err){
|
||||
console.log(err);
|
||||
} else {
|
||||
blacklist = JSON.parse(data); //now it an object
|
||||
blacklist [user] = reasons
|
||||
json = JSON.stringify(blacklist); //convert it back to json
|
||||
json = json.replace(/[<@!>]/g, '')
|
||||
fs.writeFile('json/blacklist.json', json, 'utf8', function(err) {
|
||||
if(err) {
|
||||
return console.log(err);
|
||||
}
|
||||
})}});
|
||||
|
||||
return message.say(`User ${user} have been blacklisted`);
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1,31 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
module.exports = class BotavatarCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'botavatar',
|
||||
group: 'owner',
|
||||
memberName: 'botavatar',
|
||||
description: 'Change the avatar of the bot',
|
||||
ownerOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'pic',
|
||||
prompt: 'Wich avatar should i have?',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { pic }) {
|
||||
let Attachment = (message.attachments).array();
|
||||
let image = null
|
||||
if (!Attachment[0])
|
||||
return message.say('You didint provide any images')
|
||||
else
|
||||
image = Attachment[0].url
|
||||
this.client.user.setAvatar(image);
|
||||
message.say('The avatar have been changed succesfully');
|
||||
}
|
||||
};
|
@ -0,0 +1,17 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
module.exports = class DedCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'ded',
|
||||
aliases: ['shutdown', 'dead', 'restart', 'reboot'],
|
||||
group: 'owner',
|
||||
memberName: 'ded',
|
||||
description: 'Reboot the bot',
|
||||
ownerOnly: true,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
await message.say('k bye thx\nhttps://i.redd.it/lw8hrvr0l4f11.jpg');
|
||||
process.exit();
|
||||
}}
|
@ -1,36 +0,0 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import Twit from 'twit';
|
||||
|
||||
const { twiConsumer, twiConsumerSecret, twiToken, twiTokenSecret } = process.env;
|
||||
|
||||
export default {
|
||||
data: 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)),
|
||||
category: 'owner',
|
||||
ownerOnly: true,
|
||||
async execute(interaction, args) {
|
||||
await interaction.deferReply();
|
||||
try {
|
||||
const T = new Twit({
|
||||
consumer_key: twiConsumer,
|
||||
consumer_secret: twiConsumerSecret,
|
||||
access_token: twiToken,
|
||||
access_token_secret: twiTokenSecret,
|
||||
});
|
||||
|
||||
T.post('statuses/destroy', {
|
||||
id: args.tweetid,
|
||||
});
|
||||
return interaction.editReply('Tweet have been deleted!');
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
return interaction.editReply('Oh no, an error has occurred :(');
|
||||
}
|
||||
},
|
||||
};
|
@ -1,17 +0,0 @@
|
||||
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');
|
||||
await interaction.reply({ content: 'Good bye', ephemeral: true })
|
||||
.then(() => {
|
||||
console.log('\x1b[31m\x1b[47m\x1b[5mSHUTING DOWN!!!!!\x1b[0m');
|
||||
process.exit(1);
|
||||
});
|
||||
},
|
||||
};
|
@ -1,69 +1,37 @@
|
||||
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
|
||||
// const feedbackID = [];
|
||||
const { Command } = require('discord.js-commando');
|
||||
module.exports = class dmCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'dm',
|
||||
group: 'owner',
|
||||
memberName: 'dm',
|
||||
aliases: ['pm'],
|
||||
description: 'Dm the user id',
|
||||
ownerOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'Wich user would you like to dm?',
|
||||
type: 'user',
|
||||
},
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you want to say to the user',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('dm')
|
||||
.setDescription('Replies with Pong!')
|
||||
.addStringOption(option =>
|
||||
option.setName('userid')
|
||||
.setDescription('The user to who you want to send the message to.')
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option.setName('message')
|
||||
.setDescription('What do you want to tell them?')
|
||||
.setRequired(true))
|
||||
.addAttachmentOption(option =>
|
||||
option.setName('image')
|
||||
.setDescription('Optional attachment.')
|
||||
.setRequired(false)),
|
||||
category: 'owner',
|
||||
ownerOnly: true,
|
||||
async execute(interaction, args, client) {
|
||||
/* Too lazy to implement that now (Watch it rest untouched for months)
|
||||
async function uuidv4() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
const r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
const uuid = uuidv4();
|
||||
feedbackID[uuid] = args.message;
|
||||
*/
|
||||
await client.users.fetch(args.userid);
|
||||
const user = client.users.resolve(args.userid);
|
||||
if (!user) return interaction.reply('Not a valid ID');
|
||||
const text = args.message;
|
||||
|
||||
const Embed = new EmbedBuilder()
|
||||
.setTitle('You received a message from the developer!')
|
||||
.setDescription(text)
|
||||
.setFooter({ text: `If you wish to respond use the following command: ${interaction.prefix}feedback <message>` })
|
||||
.setTimestamp();
|
||||
|
||||
user.send({ embeds: [Embed] });
|
||||
return interaction.reply({ content: `DM sent to ${user.username} (${user.id})` });
|
||||
/*
|
||||
const Attachment = (message.attachments).array();
|
||||
if (Attachment[0]) {
|
||||
client.users.resolve(user).send(Embed, { files: [Attachment[0].url] })
|
||||
.then(() => {
|
||||
return interaction.reply(`DM sent to ${user.username}`);
|
||||
})
|
||||
.catch(() => {
|
||||
return interaction.reply(`Could not send a DM to ${user.username}`);
|
||||
});
|
||||
}
|
||||
else {
|
||||
client.users.resolve(user).send(Embed)
|
||||
.then(() => {
|
||||
return interaction.reply(`DM sent to ${user.username}`);
|
||||
})
|
||||
.catch(() => {
|
||||
return interaction.reply(`Could not send a DM to ${user.username}`);
|
||||
});
|
||||
}
|
||||
*/
|
||||
},
|
||||
};
|
||||
async run(message, { user, text }) {
|
||||
let Attachment = (message.attachments).array();
|
||||
if (Attachment[0]) {
|
||||
user.send(`**Message from the dev:**\n${text}\n${Attachment[0].url}`)
|
||||
message.say(`DM sent to ${user.username}`)
|
||||
}
|
||||
else {
|
||||
user.send(`**Message from the dev:**\n${text}`)
|
||||
message.say(`DM sent to ${user.username}`)
|
||||
}
|
||||
}
|
||||
};
|
@ -1,30 +0,0 @@
|
||||
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 the command.');
|
||||
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,0 +1,24 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
module.exports = class dmCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'emit',
|
||||
group: 'owner',
|
||||
memberName: 'emit',
|
||||
aliases: ['event', 'emitevent'],
|
||||
description: 'Trigger an event',
|
||||
ownerOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'event',
|
||||
prompt: 'Wich event do you want to trigger?',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { event }) {
|
||||
this.client.emit(`${event}`);
|
||||
}
|
||||
};
|
@ -1,22 +0,0 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('load')
|
||||
.setDescription('load a command.')
|
||||
.addStringOption(option =>
|
||||
option.setName('file')
|
||||
.setDescription('File location of the command.')
|
||||
.setRequired(true)),
|
||||
category: 'owner',
|
||||
ownerOnly: true,
|
||||
async execute(interaction, args, client) {
|
||||
await interaction.deferReply();
|
||||
|
||||
let command = await import(`../../${args.file}`);
|
||||
command = command.default;
|
||||
|
||||
client.commands.set(command.data.name, command);
|
||||
return await interaction.editReply(`${command.data.name} has been loaded.`);
|
||||
},
|
||||
};
|
@ -0,0 +1,24 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
module.exports = class StatusCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'status',
|
||||
group: 'owner',
|
||||
memberName: 'status',
|
||||
description: 'Change the status of the bot',
|
||||
ownerOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'status',
|
||||
prompt: 'Wich status should i have?',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { status }) {
|
||||
this.client.user.setActivity(status);
|
||||
message.say(`Status have been set to ${status}`);
|
||||
}
|
||||
};
|
@ -1,79 +0,0 @@
|
||||
import { ButtonStyle, SlashCommandBuilder, ButtonBuilder, ActionRowBuilder } from 'discord.js';
|
||||
import db from '../../models/index.js';
|
||||
const Blacklists = db.Blacklists;
|
||||
|
||||
export default {
|
||||
data: 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)),
|
||||
category: 'owner',
|
||||
ownerOnly: true,
|
||||
async execute(interaction, args) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
const client = interaction.client;
|
||||
const command = args.command;
|
||||
const userid = args.userid;
|
||||
const reason = args.reason ? args.reason : 'No reason has been specified.';
|
||||
|
||||
const blacklist = await Blacklists.findOne({ where: { type:command, uid:userid } });
|
||||
|
||||
if (!blacklist) {
|
||||
const body = { type:command, uid: userid, reason: reason };
|
||||
Blacklists.create(body);
|
||||
let user = userid;
|
||||
await client.users.fetch(userid);
|
||||
user = client.users.resolve(userid).username;
|
||||
|
||||
|
||||
return interaction.editReply(`${user} (${userid}) has been blacklisted from ${command} with the following reason \`${reason}\``);
|
||||
}
|
||||
else {
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`yes${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Yes')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`no${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('No')
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
);
|
||||
|
||||
await interaction.editReply({ content: 'This user is already blacklisted, do you want to unblacklist him?', ephemeral: true, components: [row] });
|
||||
|
||||
return listenButton(client, interaction, command, userid, interaction.user);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
async function listenButton(client, interaction, command, userid, user = interaction.user, originalId = interaction.id) {
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (user !== interactionMenu.user) return listenButton(client, interaction, command, userid, user, originalId);
|
||||
if (!interactionMenu.isButton()) return;
|
||||
|
||||
await interactionMenu.update({ components: [] });
|
||||
|
||||
if (interactionMenu.customId === `yes${interaction.user.id}${originalId}`) {
|
||||
Blacklists.destroy({ where: { type:command, uid:userid } });
|
||||
return interaction.editReply(`The following ID have been unblacklisted from ${command}: ${userid}`);
|
||||
}
|
||||
else {
|
||||
return interaction.editReply('No one has been unblacklisted.');
|
||||
}
|
||||
});
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import fs from 'node:fs';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('unload')
|
||||
.setDescription('Unload a command and replace it with a placeholder')
|
||||
.addStringOption(option =>
|
||||
option.setName('commandname')
|
||||
.setDescription('The command to unload.')
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option.setName('placeholder')
|
||||
.setDescription('The placeholder message you want for the command.'))
|
||||
.addBooleanOption(option =>
|
||||
option.setName('nofile')
|
||||
.setDescription('Don\'t create the placeholder file')),
|
||||
category: 'owner',
|
||||
ownerOnly: true,
|
||||
async execute(interaction, args, client) {
|
||||
await interaction.deferReply();
|
||||
if (!client.commands.has(args.commandname)) return await interaction.editReply('Command not found.');
|
||||
if (!args.placeholder) args.placeholder = 'This command is unloaded, please check back later.';
|
||||
|
||||
if (!args.nofile) {
|
||||
fs.writeFileSync(`./unloaded/${args.commandname}.js`, `
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
export default {
|
||||
data: ${JSON.stringify(client.commands.get(args.commandname).data)},
|
||||
category: '${client.commands.get(args.commandname).category}',
|
||||
async execute(interaction) {
|
||||
return interaction.reply('${args.placeholder}');
|
||||
},
|
||||
};
|
||||
|
||||
`);
|
||||
}
|
||||
|
||||
client.commands.delete(args.commandname);
|
||||
if (!args.nofile) {
|
||||
let command = await import(`../../unloaded/${args.commandname}.js`);
|
||||
command = command.default;
|
||||
|
||||
client.commands.set(args.commandname, command);
|
||||
}
|
||||
|
||||
return await interaction.editReply(`${args.commandname} has been unloaded.`);
|
||||
},
|
||||
};
|
@ -0,0 +1,25 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
module.exports = class UsernameCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'username',
|
||||
group: 'owner',
|
||||
memberName: 'username',
|
||||
description: 'Change the username of the bot',
|
||||
ownerOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'username',
|
||||
prompt: 'Wich status should i have?',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { username }) {
|
||||
this.client.user.setUsername(username);
|
||||
message.say(`The username have been changed sucessfully to ${username}`);
|
||||
|
||||
}
|
||||
};
|
@ -0,0 +1,40 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class BSEspamCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'bsespam',
|
||||
group: 'reserved',
|
||||
memberName: 'bsespam',
|
||||
description: `FOR Big Snow Energy only\nSpam the text you send`,
|
||||
throttling: {
|
||||
usages: 2,
|
||||
duration: 3600,
|
||||
},
|
||||
args: [
|
||||
{
|
||||
key: 'number',
|
||||
prompt: 'How many times do you want to repeat it?',
|
||||
type: 'integer',
|
||||
validate: number => number < 11,
|
||||
default: '1'
|
||||
},
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you want me to say',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { number, text }) {
|
||||
if (message.author.id != "428387534842626048")
|
||||
return message.say('Command only available to **Big Snow Energy**')
|
||||
|
||||
for(let i = 0; i < number; i++) {
|
||||
message.say(text);
|
||||
}
|
||||
message.say('Finished :)');
|
||||
}
|
||||
};
|
@ -1,90 +0,0 @@
|
||||
/* eslint-disable no-case-declarations */
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
const { ownerId } = process.env;
|
||||
|
||||
export default {
|
||||
data: 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)),
|
||||
category: 'secret',
|
||||
async execute(interaction, args, client) {
|
||||
const command = args.something;
|
||||
|
||||
switch (command) {
|
||||
case 'levertowned':
|
||||
return interaction.reply('Hello buddy bro <:youngtroll:488559163832795136> <@434762632004894746>');
|
||||
case 'owned':
|
||||
const epicMessage = ['You cheated not ONLY the GAME, BUT yourself. You didn\'t GROW. You didn\'t IMPROVE. You TOOK a SHORTCUT and gained NOTHING. You EXPERIENCED a HOLLOW victory. NOTHING WAS risked and NOTHING WAS gained. It\'s SAD that you don\'t KNOW the DIFFERENCE.', 'TROLOLOLO OWNED EPIC STYLE', 'Owned noob', 'HAHA BRO YOU JUST GOT OOOOOOOOWNED HAHAHAHAHHAHA NOOOB NOOOOB NOOOB OWNED NOOB <:youngtroll:488559163832795136>', '<a:op:516341492982218756> op op op owned epic style <a:op:516341492982218756>', 'HAHAHA BRO YOU HAVE BEEN OWNED TROLL BRO STYLE', 'OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED YOU JUST GOT OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED YOU JUST GOT OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED YOU JUST GOT OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED OWNED YOU JUST GOT OWNED', 'OWNED\nFUCKING OWNED', 'OWNED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!', 'You just got owned <a:troll:525724709833277442>', 'you just been....epicly trolled <:trole:241942993022615552>', 'I hope you have a nice day, just a simple reminder that I love you and I think you\'re pretty epic!!!!'];
|
||||
|
||||
const ownedMessage = epicMessage[Math.floor(Math.random() * epicMessage.length)];
|
||||
|
||||
await interaction.guild.members.fetch();
|
||||
let owned = args.somethingelse ? interaction.guild.members.cache.find(u => u.user.username.toLowerCase().includes(args.somethingelse.toLowerCase())) : null;
|
||||
if (interaction.isMessage) {
|
||||
if (interaction.mentions.members.first()) {
|
||||
console.log('test');
|
||||
owned = interaction.mentions.members.first();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.somethingelse) {
|
||||
|
||||
if (owned.id === client.user.id) {
|
||||
return interaction.reply('You really thought you could own me?, pathetic...');
|
||||
}
|
||||
else if (owned.id === ownerId) {
|
||||
return interaction.reply('You really thought you could own him?, pathetic...');
|
||||
}
|
||||
else if (owned.id === '286054184623538177' || owned.id === '172112210863194113') {
|
||||
owned = interaction.user;
|
||||
}
|
||||
|
||||
|
||||
if (ownedMessage === epicMessage[0]) {
|
||||
return interaction.reply(ownedMessage);
|
||||
}
|
||||
|
||||
return interaction.reply(`${owned}, ${ownedMessage}`);
|
||||
}
|
||||
else {
|
||||
return interaction.reply(ownedMessage);
|
||||
}
|
||||
case 'fartpiss':
|
||||
if (interaction.guild.id != '240843640375607296') {
|
||||
return;
|
||||
}
|
||||
|
||||
await interaction.guild.members.fetch();
|
||||
const member = args.somethingelse ? interaction.guild.members.cache.find(u => u.user.username.toLowerCase().includes(args.somethingelse.toLowerCase())) : null;
|
||||
|
||||
if (member) {
|
||||
return await member.setNickname('fart piss')
|
||||
.then(() => interaction.reply(`sucessfully fart pissed on ${member.user.username} <:youngtroll:488559163832795136>`))
|
||||
.catch((error) => {
|
||||
if (process.env.NODE_ENV === 'development') console.error(error);
|
||||
interaction.reply(`Sorry i could not fart piss on ${member.user.username} :(`);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
return await interaction.member.setNickname('fart piss')
|
||||
.then(() => interaction.reply('sucessfully fart pissed on you <:youngtroll:488559163832795136>'))
|
||||
.catch((error) => {
|
||||
if (process.env.NODE_ENV === 'development') console.error(error);
|
||||
interaction.reply('Sorry i could not fart piss on you :(');
|
||||
});
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
};
|
@ -1,63 +0,0 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { execFile } from 'node:child_process';
|
||||
import db from '../../models/index.js';
|
||||
const donator = db.donator;
|
||||
|
||||
const { ownerId, uptimePage } = process.env;
|
||||
|
||||
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;
|
||||
const tina = await client.users.fetch('336492042299637771');
|
||||
const creator = await client.users.fetch('267065637183029248');
|
||||
const maintainer = await client.users.fetch(ownerId);
|
||||
|
||||
let description = 'I\'m a fun multipurpose bot made using [discord.js](https://github.com/discordjs/discord.js)'
|
||||
+ '\nFor a better experience use the slash commands!\n\nThe people who donated for the bot <3\n';
|
||||
|
||||
if (Donator[0]) {
|
||||
for (let i = 0; i < Donator.length; i++) {
|
||||
const user = await client.users.fetch(Donator[i].get('userID').toString());
|
||||
if (user !== null) {
|
||||
description += `**${user.username} (${user.id}) | ${Donator[i].get('comment')}**\n`;
|
||||
}
|
||||
else {
|
||||
description += `**A user of discord (${user.id}) | ${Donator[i].get('comment')} (This user no longer share a server with the bot)**\n`;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
description += 'No one :(\n';
|
||||
}
|
||||
|
||||
description += `\nThanks to ${tina.username} (336492042299637771) for inspiring me for making this bot!`;
|
||||
|
||||
// description += '\nThanks to Jetbrains for providing their IDE!';
|
||||
|
||||
execFile('git', ['rev-parse', '--short', 'HEAD'], (err, stdout) => {
|
||||
const aboutEmbed = new EmbedBuilder()
|
||||
.setColor(interaction.member ? interaction.member.displayHexColor : 'Navy')
|
||||
.setAuthor({ name: client.user.username, iconURL: client.user.displayAvatarURL(), url: 'https://libtar.de' })
|
||||
.setTitle('About me')
|
||||
.setDescription(description)
|
||||
.addFields(
|
||||
{ name: 'Current commit', value: stdout },
|
||||
{ name: 'Current maintainer', value: `${maintainer.username} (${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', inline: true },
|
||||
{ name: 'Status page', value: uptimePage.toString(), inline: true },
|
||||
|
||||
)
|
||||
.setFooter({ text: `Original bot made by ${creator.username} (267065637183029248)` });
|
||||
|
||||
interaction.reply({ embeds: [aboutEmbed] });
|
||||
});
|
||||
},
|
||||
};
|
@ -1,99 +0,0 @@
|
||||
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
|
||||
import utils from '../../utils/videos.js';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
|
||||
const { ytpChannelId } = process.env;
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('addytp')
|
||||
.setDescription('Add a video to the pool of ytps. You can add 5 per day.')
|
||||
.addStringOption(option =>
|
||||
option.setName('url')
|
||||
.setDescription('URL of the video you want to add.')
|
||||
.setRequired(true)),
|
||||
category: 'utility',
|
||||
ratelimit: 5,
|
||||
cooldown: 86400,
|
||||
async execute(interaction, args) {
|
||||
const url = args.url;
|
||||
// This is rather rudementary, a proper way would be using yt-dlp to know if it is a playlist
|
||||
if (url.includes('list=')) {
|
||||
return interaction.reply({ content: '❌ Playlists are not allowed!', ephemeral: true });
|
||||
}
|
||||
|
||||
if (!await utils.stringIsAValidurl(url)) {
|
||||
console.error(`Not a url!!! ${url}`);
|
||||
return interaction.reply({ content: '❌ This does not look like a valid url!', ephemeral: true });
|
||||
}
|
||||
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
utils.downloadVideo(url, interaction.id, 'bestvideo[height<=?480]+bestaudio/best')
|
||||
.then(async () => {
|
||||
const file = fs.readdirSync(os.tmpdir()).filter(fn => fn.startsWith(interaction.id));
|
||||
const output = `${os.tmpdir()}/${file}`;
|
||||
|
||||
const fileStat = fs.statSync(output);
|
||||
const fileSize = fileStat.size / 1000000.0;
|
||||
|
||||
if (fileSize > 50) {
|
||||
// await interaction.deleteReply();
|
||||
await interaction.editReply({ content: '❌ Uh oh! The video is too big!', ephemeral: true });
|
||||
}
|
||||
else {
|
||||
// CopyFile instead of rename in case you have /tmp and the asset folder on different a disk.
|
||||
fs.copyFileSync(output, `./asset/ytp/userVid/${file}`);
|
||||
const mp4 = [];
|
||||
fs.readdirSync('./asset/ytp/userVid/').forEach(f => {
|
||||
if (f.endsWith('mp4')) {
|
||||
mp4.push(f);
|
||||
}
|
||||
});
|
||||
|
||||
// (Hopefully) limit video to 2k
|
||||
if (mp4.length > 2000) {
|
||||
const f = mp4.sort((a, b) => {
|
||||
const time1 = fs.statSync(`./asset/ytp/userVid/${b}`).ctime;
|
||||
const time2 = fs.statSync(`./asset/ytp/userVid/${a}`).ctime;
|
||||
if (time1 < time2) return 1;
|
||||
if (time1 > time2) return -1;
|
||||
return 0;
|
||||
}).slice(0, 1);
|
||||
fs.unlinkSync(`./asset/ytp/userVid/${f[0]}`);
|
||||
}
|
||||
|
||||
interaction.editReply({ content: `Video successfully added to the pool! There is now ${mp4.length} videos`, ephemeral: true });
|
||||
|
||||
const Embed = new EmbedBuilder()
|
||||
.setAuthor({ name: interaction.user.username, iconURL: interaction.user.displayAvatarURL() })
|
||||
.addFields([
|
||||
{ name: 'Channel ID', value: interaction.channel.id.toString(), inline: true },
|
||||
{ name: 'Message ID', value: interaction.id.toString(), inline: true },
|
||||
{ name: 'Author', value: `${interaction.user.username} (${interaction.user.id})`, inline: true },
|
||||
])
|
||||
.setTimestamp();
|
||||
|
||||
if (interaction.guild) {
|
||||
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}` },
|
||||
]);
|
||||
}
|
||||
else {
|
||||
Embed.addFields([
|
||||
{ name: 'Message link', value: `https://discord.com/channels/@me/${interaction.channel.id}/${interaction.id}` },
|
||||
]);
|
||||
}
|
||||
|
||||
const channel = interaction.client.channels.resolve(ytpChannelId);
|
||||
// Send as 2 separate message otherwise the url won't get embedded.
|
||||
channel.send({ content: url });
|
||||
return channel.send({ embeds: [Embed] });
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
@ -1,49 +1,34 @@
|
||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
const { Command } = require('discord.js-commando');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
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');
|
||||
|
||||
module.exports = class AvatarCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'avatar',
|
||||
group: 'utility',
|
||||
memberName: 'avatar',
|
||||
description: 'Send the avatar of the mentionned user.',
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'What do you want me to say',
|
||||
type: 'user',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
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] });
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
async run(message, { user }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
if (!user)
|
||||
return message.say(`Your avatar:\n${message.author.displayAvatarURL}`);
|
||||
else
|
||||
return message.say(`${user.username}'s avatar:\n${user.displayAvatarURL}`);
|
||||
}
|
||||
};
|
@ -1,23 +0,0 @@
|
||||
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 EmbedBuilder()
|
||||
.setColor(interaction.member ? interaction.member.displayHexColor : 'Navy')
|
||||
.setTitle('Donation link')
|
||||
.setDescription(desc);
|
||||
|
||||
return interaction.reply({ embeds: [Embed] });
|
||||
},
|
||||
};
|
@ -1,31 +0,0 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import db from '../../models/index.js';
|
||||
const donator = db.donator;
|
||||
|
||||
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;
|
||||
const Donator = await donator.findAll({ order: ['id'] });
|
||||
|
||||
let donatorMessage = 'Thanks to:\n';
|
||||
|
||||
if (Donator[0]) {
|
||||
for (let i = 0; i < Donator.length; i++) {
|
||||
const user = await client.users.fetch(Donator[i].get('userID').toString());
|
||||
if (user !== null) {donatorMessage += `**${user.username} (${user.id}) | ${Donator[i].get('comment')}**\n`;}
|
||||
else {donatorMessage += `**A user of discord (${user.id}) | ${Donator[i].get('comment')} (This user no longer share a server with the bot)**\n`;}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
donatorMessage += 'No one :(';
|
||||
}
|
||||
|
||||
return interaction.editReply(donatorMessage);
|
||||
},
|
||||
};
|
@ -1,304 +1,53 @@
|
||||
import { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, StringSelectMenuBuilder } from 'discord.js';
|
||||
import { execFile } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import utils from '../../utils/videos.js';
|
||||
const { Command } = require('discord.js-commando');
|
||||
const fs = require('fs');
|
||||
const youtubedl = require('youtube-dl');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const { fbuser, fbpasswd } = require('../../config.json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
module.exports = class downloadCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'download',
|
||||
group: 'utility',
|
||||
memberName: 'download',
|
||||
description: `Download any video from the link you provided.`,
|
||||
args: [
|
||||
{
|
||||
key: 'link',
|
||||
prompt: 'Wich video would you like to download?',
|
||||
type: 'string',
|
||||
default: 'https://www.youtube.com/watch?v=6n3pFFPSlW4'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { link }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
if(link.includes("http") || link.includes("www")) {
|
||||
message.say('Downloading...').then(msg => {
|
||||
video.on('end', function() {
|
||||
msg.delete()
|
||||
})
|
||||
})
|
||||
let video = youtubedl(link, [`--username=${fbuser}`,`--password=${fbpasswd}`])
|
||||
video.pipe(fs.createWriteStream('./video.mp4'))
|
||||
video.on('error', function error(err) {
|
||||
console.log('error 2:', err);
|
||||
message.say("An error has occured, i can't download from the link you provided.")
|
||||
});
|
||||
video.on('end', function() {
|
||||
message.delete();
|
||||
message.channel.send(`Downloaded by ${message.author.username}`, {files: ["./video.mp4"]})
|
||||
.catch(error => message.say('File too big'))
|
||||
})
|
||||
} else
|
||||
message.say("You need to input a valid link")
|
||||
}
|
||||
|
||||
let client;
|
||||
let maxFileSize;
|
||||
|
||||
let { ytdlpMaxResolution } = process.env;
|
||||
// Convert to number as process.env is always a string
|
||||
ytdlpMaxResolution = Number(ytdlpMaxResolution);
|
||||
|
||||
export default {
|
||||
data: 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))
|
||||
.addBooleanOption(option =>
|
||||
option.setName('description')
|
||||
.setDescription('Include the video description?')
|
||||
.setRequired(false)),
|
||||
category: 'utility',
|
||||
alias: ['dl'],
|
||||
|
||||
async execute(interaction, args, c) {
|
||||
client = c;
|
||||
const url = args.url;
|
||||
const format = args.format;
|
||||
maxFileSize = await utils.getMaxFileSize(interaction.guild);
|
||||
interaction.doCompress = args.compress;
|
||||
|
||||
await interaction.deferReply({ ephemeral: false });
|
||||
|
||||
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 (format) {
|
||||
let qualitys = await new Promise((resolve, reject) => {
|
||||
execFile('./bin/yt-dlp', [url, '--print', '%()j'], (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(stderr);
|
||||
}
|
||||
if (stderr) {
|
||||
console.error(stderr);
|
||||
}
|
||||
resolve(stdout);
|
||||
});
|
||||
});
|
||||
|
||||
qualitys = JSON.parse(qualitys);
|
||||
const options = [];
|
||||
|
||||
qualitys.formats.forEach(f => {
|
||||
if (f.format.includes('storyboard')) return;
|
||||
options.push({
|
||||
label: f.resolution ? f.resolution : 'Unknown format',
|
||||
description: `${f.format} V: ${f.vcodec} A: ${f.acodec}`,
|
||||
value: f.format_id,
|
||||
});
|
||||
});
|
||||
|
||||
if (options.length < 2) {
|
||||
await interaction.deleteReply();
|
||||
return interaction.followUp({ content: '❌ There is no other quality option for this video!', ephemeral: true });
|
||||
}
|
||||
|
||||
if (options.length > 25) {
|
||||
// Reverse so the higher quality formats are first
|
||||
options.reverse();
|
||||
while (options.length > 25) {
|
||||
// Remove the lower quality formats
|
||||
options.pop();
|
||||
}
|
||||
// Reverse again so the lower quality appears first
|
||||
options.reverse();
|
||||
}
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new StringSelectMenuBuilder()
|
||||
.setCustomId(`downloadQuality${interaction.user.id}${interaction.id}`)
|
||||
.setPlaceholder('Nothing selected')
|
||||
.setMinValues(1)
|
||||
.setMaxValues(2)
|
||||
.addOptions(options),
|
||||
);
|
||||
|
||||
await interaction.deleteReply();
|
||||
await interaction.followUp({ content: 'Which quality do you want?', ephemeral: true, components: [row] });
|
||||
|
||||
client.on('interactionCreate', async (interactionMenu) => {
|
||||
if (interaction.user !== interactionMenu.user) return;
|
||||
if (!interactionMenu.isSelectMenu()) return;
|
||||
if (interactionMenu.customId === `downloadQuality${interaction.user.id}${interaction.id}`) {
|
||||
await interactionMenu.deferReply({ ephemeral: false });
|
||||
|
||||
await checkSize(url, interactionMenu.values[0], args, interaction);
|
||||
return download(url, interactionMenu, interaction, undefined, true);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
const newFormat = await checkSize(url, undefined, args, interaction);
|
||||
return download(url, interaction, interaction, newFormat, args.description);
|
||||
},
|
||||
};
|
||||
|
||||
async function download(url, interaction, originalInteraction, format = undefined, description = false) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(interaction.member ? interaction.member.displayHexColor : 'Navy')
|
||||
.setAuthor({ name: `Downloaded by ${interaction.user.username}`, iconURL: interaction.user.displayAvatarURL(), url: url })
|
||||
.setFooter({ text: `You can get the original video by clicking on the "Downloaded by ${interaction.user.username}" message!` });
|
||||
|
||||
if (description) {
|
||||
Embed.setDescription(await getVideoDescription(url));
|
||||
}
|
||||
|
||||
if (interaction.customId === `downloadQuality${interaction.user.id}${originalInteraction.id}` && !format) {
|
||||
format = interaction.values[0];
|
||||
if (interaction.values[1]) format += '+' + interaction.values[1];
|
||||
}
|
||||
|
||||
utils.downloadVideo(url, interaction.id, format)
|
||||
.then(async () => {
|
||||
const file = fs.readdirSync(os.tmpdir()).filter(fn => fn.startsWith(interaction.id));
|
||||
let output = `${os.tmpdir()}/${file}`;
|
||||
|
||||
const compressInteraction = originalInteraction ? originalInteraction : interaction;
|
||||
if (compressInteraction.doCompress) {
|
||||
const presets = [ 'Social 8 MB 3 Minutes 360p30', 'Social 50 MB 10 Minutes 480p30', 'Social 50 MB 5 Minutes 720p30', 'Social 100 MB 5 Minutes 1080p30' ];
|
||||
const options = [];
|
||||
|
||||
presets.forEach(p => {
|
||||
options.push({
|
||||
label: p,
|
||||
value: p,
|
||||
});
|
||||
});
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new StringSelectMenuBuilder()
|
||||
.setCustomId(`preset${interaction.user.id}${interaction.id}`)
|
||||
.setPlaceholder('Nothing selected')
|
||||
.addOptions(options),
|
||||
);
|
||||
|
||||
await interaction.deleteReply();
|
||||
await interaction.followUp({ content: 'Which compression preset do you want?', ephemeral: true, components: [row] });
|
||||
client.on('interactionCreate', async (interactionMenu) => {
|
||||
if (interaction.user !== interactionMenu.user) return;
|
||||
if (!interactionMenu.isSelectMenu()) return;
|
||||
if (interactionMenu.customId === `preset${interaction.user.id}${interaction.id}`) {
|
||||
await interactionMenu.deferReply({ ephemeral: false });
|
||||
compress(file, interactionMenu, Embed);
|
||||
if (interaction.isMessage) {
|
||||
interaction.deleteReply();
|
||||
interaction.cleanUp();
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// If the video format is not one compatible with Discord, reencode it.
|
||||
const bannedFormats = ['hevc'];
|
||||
const codec = await utils.getVideoCodec(output);
|
||||
|
||||
if (bannedFormats.includes(codec)) {
|
||||
const oldOutput = output;
|
||||
output = `${os.tmpdir()}/264${file}`;
|
||||
await utils.ffmpeg(['-i', oldOutput, '-vcodec', 'libx264', '-acodec', 'aac', output]);
|
||||
}
|
||||
|
||||
const fileStat = fs.statSync(output);
|
||||
const fileSize = fileStat.size / 1000000.0;
|
||||
|
||||
Embed.setAuthor({ name: `${Embed.data.author.name} (${fileSize.toFixed(2)} MB)`, iconURL: Embed.data.author.icon_url, url: Embed.data.author.url });
|
||||
|
||||
let message = null;
|
||||
if (interaction.isMessage && interaction.reference !== null) {
|
||||
const channel = client.channels.resolve(interaction.reference.channelId);
|
||||
message = await channel.messages.fetch(interaction.reference.messageId);
|
||||
}
|
||||
|
||||
if (fileSize > 100) {
|
||||
await interaction.deleteReply();
|
||||
await interaction.followUp('Uh oh! The video you tried to download is too big!', { ephemeral: true });
|
||||
}
|
||||
else if (fileSize > maxFileSize) {
|
||||
const fileurl = await utils.upload(output)
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
await interaction.editReply({ content: `File was bigger than ${maxFileSize} mb. It has been uploaded to an external site.`, embeds: [Embed], ephemeral: false });
|
||||
if (interaction.isMessage && message) {
|
||||
await message.reply({ content: fileurl });
|
||||
}
|
||||
else {
|
||||
await interaction.followUp({ content: fileurl, ephemeral: false });
|
||||
}
|
||||
}
|
||||
else if (interaction.isMessage && message) {
|
||||
await message.reply({ embeds: [Embed], files: [output] });
|
||||
}
|
||||
else {
|
||||
await interaction.editReply({ embeds: [Embed], files: [output], ephemeral: false });
|
||||
}
|
||||
|
||||
if (interaction.isMessage) {
|
||||
interaction.deleteReply();
|
||||
interaction.cleanUp();
|
||||
}
|
||||
})
|
||||
.catch(async err => {
|
||||
console.error(err);
|
||||
await interaction.deleteReply();
|
||||
await interaction.followUp({ content: 'Uh oh! An error has occured!', ephemeral: true });
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
async function compress(input, interaction, embed) {
|
||||
const output = `compressed${input}.mp4`;
|
||||
// Delete the file as it apparently don't overwrite?
|
||||
if (fs.existsSync(output)) {
|
||||
fs.rmSync(output);
|
||||
}
|
||||
|
||||
utils.compressVideo(`${os.tmpdir()}/${input}`, output, interaction.values[0])
|
||||
.then(async () => {
|
||||
const fileStat = fs.statSync(`${os.tmpdir()}/${output}`);
|
||||
const fileSize = fileStat.size / 1000000.0;
|
||||
|
||||
embed.setAuthor({ name: `${embed.data.author.name} (${fileSize.toFixed(2)} MB)`, iconURL: embed.data.author.icon_url, url: embed.data.author.url });
|
||||
|
||||
if (fileSize > maxFileSize) {
|
||||
await interaction.editReply({ content: `File was bigger than ${maxFileSize} mb. It has been uploaded to an external site.`, ephemeral: false });
|
||||
}
|
||||
else {
|
||||
await interaction.editReply({ embeds: [embed], files: [`${os.tmpdir()}/${output}`], ephemeral: false });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function checkSize(url, format, args, interaction, tries = 0) {
|
||||
const resolutions = [144, 240, 360, 480, 720, 1080, 1440, 2160];
|
||||
|
||||
while (tries < 4) {
|
||||
format = `bestvideo[height<=?${resolutions[resolutions.indexOf(ytdlpMaxResolution) - tries]}]+bestaudio/best`;
|
||||
const aproxFileSize = await utils.getVideoSize(url, format);
|
||||
if (isNaN(aproxFileSize)) return format;
|
||||
|
||||
if (format || tries >= 4) {
|
||||
if (aproxFileSize > 100 && !args.compress && tries > 4) {
|
||||
return await interaction.followUp(`Uh oh! The video you tried to download is larger than 100 mb (is ${aproxFileSize} mb)! Try again with a lower resolution format.`);
|
||||
}
|
||||
else if (aproxFileSize > 500 && tries > 4) {
|
||||
return await interaction.followUp(`Uh oh! The video you tried to download is larger than 500 mb (is ${aproxFileSize} mb)! Try again with a lower resolution format.`);
|
||||
}
|
||||
}
|
||||
|
||||
if (aproxFileSize < 100) {
|
||||
return format;
|
||||
}
|
||||
|
||||
if (tries < 4 && aproxFileSize > 100) {
|
||||
tries++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function getVideoDescription(urlArg) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
execFile('./bin/yt-dlp', [urlArg, '--no-warnings', '-O', '%(description)s'], (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(stderr);
|
||||
}
|
||||
if (stderr) {
|
||||
console.error(stderr);
|
||||
}
|
||||
resolve(stdout.slice(0, 240));
|
||||
});
|
||||
});
|
||||
}
|
@ -1,42 +1,38 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { feedbackChannel } = require('../../config.json');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
const { feedbackChannelId } = process.env;
|
||||
|
||||
export default {
|
||||
data: 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)),
|
||||
category: 'utility',
|
||||
async execute(interaction, args) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setAuthor({ name: `${interaction.user.username} (${interaction.user.id})`, iconURL: interaction.user.avatarURL() })
|
||||
.setTimestamp();
|
||||
const fs = require('fs');
|
||||
module.exports = class feedbackCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'feedback',
|
||||
group: 'utility',
|
||||
memberName: 'feedback',
|
||||
description: `Send feedback ( if you abuse you will get blacklisted )`,
|
||||
throttling: {
|
||||
usages: 2,
|
||||
duration: 60,
|
||||
},
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What would you want to send as feedback?',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
if (interaction.guild) Embed.addFields({ name: 'Guild', value: `${interaction.guild.name} (${interaction.guild.id})`, inline: true });
|
||||
Embed.addFields({ name: 'Feedback', value: args.feedback, inline: true });
|
||||
|
||||
// Don't let new account use this command to prevent spam
|
||||
const date = new Date();
|
||||
if (interaction.user.createdAt > date.setDate(date.getDate() - 7)) {
|
||||
return interaction.reply({ content: '❌ Your account is too new to be able to use this command!', ephemeral: true });
|
||||
}
|
||||
|
||||
const channel = interaction.client.channels.resolve(feedbackChannelId);
|
||||
if (args.image) {
|
||||
channel.send({ embeds: [Embed], files: [args.image] });
|
||||
}
|
||||
else {
|
||||
channel.send({ embeds: [Embed] });
|
||||
}
|
||||
await interaction.reply({ content: 'Your feedback has been sent! Don\'t forget to have dm open if you want to get an answer from the dev!', ephemeral: true });
|
||||
},
|
||||
};
|
||||
async run(message, { text }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
const channel = this.client.channels.get(feedbackChannel);
|
||||
channel.send(`from ${message.author.username} (${message.author.id}) : ${text}`);
|
||||
message.say('Your feedback has been sent!');
|
||||
}
|
||||
};
|
@ -1,164 +0,0 @@
|
||||
import { SlashCommandBuilder, EmbedBuilder, AttachmentBuilder, PermissionsBitField } from 'discord.js';
|
||||
import fs from 'node:fs';
|
||||
import ratelimiter from '../../utils/ratelimiter.js';
|
||||
|
||||
const { ownerId, prefix } = process.env;
|
||||
const prefixs = prefix.split(',');
|
||||
|
||||
export default {
|
||||
data: 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.')),
|
||||
category: 'utility',
|
||||
async execute(interaction, args, client) {
|
||||
if (args.command) {
|
||||
const command = client.commands.get(args.command);
|
||||
if (!command) return interaction.reply(`Did not found any command named \`\`${args.command}\`\`. Please make sure it is a valid command and not an alias.`);
|
||||
const description = Object.assign({
|
||||
content: 'No description available.',
|
||||
usage: '',
|
||||
examples: [],
|
||||
fields: [],
|
||||
}, command.data);
|
||||
|
||||
const usage = command.data.options.map(cmd => {
|
||||
let type = 'String';
|
||||
const constructorName = cmd.constructor.name.toLowerCase();
|
||||
if (constructorName.includes('boolean')) {
|
||||
if (interaction.isMessage) {
|
||||
type = `--${cmd.name}`;
|
||||
}
|
||||
else {
|
||||
type = 'True/False';
|
||||
}
|
||||
}
|
||||
else if (constructorName.includes('mentionable')) {
|
||||
type = 'User';
|
||||
}
|
||||
else if (constructorName.includes('attachment')) {
|
||||
type = 'Attachment';
|
||||
}
|
||||
|
||||
return `[${cmd.name}: ${type}]`;
|
||||
});
|
||||
|
||||
let p = '/';
|
||||
if (interaction.isMessage) {
|
||||
p = prefixs[0];
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(interaction.member ? interaction.member.displayHexColor : 'Navy')
|
||||
.setTitle(`\`${p}${command.data.name} ${usage.join(' ')}\``)
|
||||
.addFields(
|
||||
{ name: 'Description', value: description.description },
|
||||
)
|
||||
.setFooter({ text: `All the available prefix: ${prefixs.join(' | ')}` });
|
||||
|
||||
for (const field of description.fields) embed.addFields({ name: field.name, value: field.value });
|
||||
|
||||
if (description.examples.length) {
|
||||
const text = `${prefixs[0]}${command.alias[0]}`;
|
||||
embed.addFields({ name: 'Examples', value: `\`${text} ${description.examples.join(`\`\n\`${text} `)}\``, inline: true });
|
||||
}
|
||||
else {
|
||||
const example = command.data.options.map(cmd => {
|
||||
let string = '"lorem ipsum"';
|
||||
const constructorName = cmd.constructor.name.toLowerCase();
|
||||
if (constructorName.includes('boolean')) {
|
||||
if (interaction.isMessage) {
|
||||
string = `--${cmd.name}`;
|
||||
}
|
||||
else {
|
||||
string = 'True/False';
|
||||
}
|
||||
}
|
||||
else if (constructorName.includes('mentionable')) {
|
||||
string = `@${interaction.user.username}`;
|
||||
}
|
||||
else if (constructorName.includes('attachment')) {
|
||||
string = 'Attachment';
|
||||
}
|
||||
|
||||
if (!interaction.isMessage) {
|
||||
string = `\`\`${cmd.name}:${string}\`\``;
|
||||
}
|
||||
return string;
|
||||
});
|
||||
|
||||
embed.addFields({ name: 'Example', value: `${p}${command.data.name} ${example.join(' ')}`, inline: true });
|
||||
}
|
||||
|
||||
if (command.alias) {
|
||||
if (command.alias.length >= 1) {
|
||||
embed.addFields({ name: 'Aliases', value: `\`${command.alias.join('` `')}\``, inline: true });
|
||||
}
|
||||
|
||||
}
|
||||
if (command.userPermissions) {
|
||||
const perm = [];
|
||||
command.userPermissions.forEach(permission => {
|
||||
perm.push(new PermissionsBitField(permission).toArray());
|
||||
});
|
||||
embed.addFields({ name: 'User permission', value: `\`${perm.join('` `')}\``, inline: true });
|
||||
}
|
||||
|
||||
if (command.clientPermissions) {
|
||||
const perm = [];
|
||||
command.clientPermissions.forEach(permission => {
|
||||
perm.push(new PermissionsBitField(permission).toArray());
|
||||
});
|
||||
embed.addFields({ name: 'Bot permission', value: `\`${perm.join('` `')}\``, inline: true });
|
||||
}
|
||||
|
||||
if (command.parallelLimit) {
|
||||
const paralellimit = ratelimiter.checkParallel(interaction.user, command.data.name, command);
|
||||
|
||||
embed.addFields({ name: 'Current number of executions', value: `\`${paralellimit.current}\``, inline: false });
|
||||
embed.addFields({ name: 'Maximum number of executions', value: `\`${command.parallelLimit}\``, inline: true });
|
||||
}
|
||||
|
||||
if (fs.existsSync(`./asset/img/command/${command.category}/${command.data.name}.png`)) {
|
||||
const file = new AttachmentBuilder(`./asset/img/command/${command.category}/${command.data.name}.png`);
|
||||
embed.setImage(`attachment://${command.data.name}.png`);
|
||||
return interaction.reply({ embeds: [embed], files: [file] });
|
||||
}
|
||||
return interaction.reply({ embeds: [embed] });
|
||||
}
|
||||
else {
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(interaction.member ? interaction.member.displayHexColor : 'Navy')
|
||||
.addFields({ name: 'Command List', value: `This is a list of commands.\nTo view details for a command, do \`${prefixs[0]}help <command>\`.` })
|
||||
.setFooter({ text: `All the available prefix: ${prefixs.join('| ')}` });
|
||||
|
||||
const object = { };
|
||||
for (const command of client.commands.values()) {
|
||||
if (command.category === 'secret') continue;
|
||||
if (interaction.user.id !== ownerId && command.category === 'owner') continue;
|
||||
if (object[command.category]) {
|
||||
object[command.category].push(command.data.name);
|
||||
}
|
||||
else {
|
||||
object[command.category] = [ command.data.name ];
|
||||
}
|
||||
}
|
||||
|
||||
for (const category in object) {
|
||||
const title = {
|
||||
fun: '🎉\u2000Fun',
|
||||
utility: '🔩\u2000Utility',
|
||||
admin: '⚡\u2000Admin',
|
||||
owner: '🛠️\u2000Owner',
|
||||
voice: '🗣️\u2000Voice',
|
||||
AI: '🦾\u2000AI',
|
||||
}[category];
|
||||
|
||||
embed.addFields({ name: title, value: `\`${object[category].join('` `')}\`` });
|
||||
}
|
||||
return interaction.reply({ embeds: [embed] });
|
||||
}
|
||||
},
|
||||
};
|
@ -0,0 +1,47 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const fetch = require('node-fetch')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
module.exports = class InfoCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'info',
|
||||
group: 'fun',
|
||||
memberName: 'info',
|
||||
description: `Search DuckDuckGo for answer`,
|
||||
args: [
|
||||
{
|
||||
key: 'search',
|
||||
prompt: 'What do you want me to search',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { search }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let searchURL = encodeURI(search)
|
||||
fetch("https://api.duckduckgo.com/?q=" + searchURL + "&format=json").then((response) => {
|
||||
return response.json();
|
||||
}).then((response) => {
|
||||
if (response.unsafe == 1)
|
||||
return message.say("No nsfw sorry...")
|
||||
const ddgEmbed = new Discord.RichEmbed()
|
||||
.setColor("#ff9900")
|
||||
.setTitle(response.Heading)
|
||||
.setURL(response.AbstractURL)
|
||||
.setDescription(response.Abstract)
|
||||
.addField("Topic", response.meta.topic)
|
||||
.setImage(response.Image)
|
||||
.setTimestamp()
|
||||
|
||||
message.say(ddgEmbed);
|
||||
});
|
||||
}};
|
@ -1,24 +1,25 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('invite')
|
||||
.setDescription('Generate invite link for the bot or another')
|
||||
.addMentionableOption(option =>
|
||||
option.setName('bot')
|
||||
.setDescription('The bot you want to make an invite link for.')
|
||||
.setRequired(false)),
|
||||
category: 'utility',
|
||||
async execute(interaction, args, client) {
|
||||
if (args.bot) {
|
||||
if (args.bot.user.bot) {
|
||||
return interaction.reply(`You can add the bot you mentioned with this link: https://discordapp.com/oauth2/authorize?client_id=${args.bot.id}&permissions=2684406848&scope=bot%20applications.commands\n\`Note: The invite will not work if the bot is not public\``);
|
||||
}
|
||||
else {
|
||||
return interaction.reply('I\'m sorry but the user you mentioned is not a bot!');
|
||||
}
|
||||
}
|
||||
else {
|
||||
return interaction.reply(`You can add me from here: https://discord.com/oauth2/authorize?client_id=${client.user.id}&permissions=2684406848&scope=bot%20applications.commands`);
|
||||
}
|
||||
},
|
||||
};
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { supportServer } = require('../../config.json');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
module.exports = class InviteCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'invite',
|
||||
group: 'utility',
|
||||
memberName: 'invite',
|
||||
description: 'Send invite to add the bot',
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
message.say('Check your dm')
|
||||
return message.author.send(`You can add me from here: https://discordapp.com/oauth2/authorize?client_id=${this.client.user.id}&scope=bot&permissions=0\nYou can also join my support server over here: ${supportServer} come and say hi :)`);
|
||||
}
|
||||
};
|
@ -1,66 +0,0 @@
|
||||
import { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
|
||||
import db from '../../models/index.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('optout')
|
||||
.setDescription('Opt out of the non commands features and arguments logging (for debugging purposes)'),
|
||||
category: 'utility',
|
||||
async execute(interaction, args, client) {
|
||||
const isOptOut = await db.optout.findOne({ where: { userID: interaction.user.id } });
|
||||
|
||||
if (!isOptOut) {
|
||||
const body = { userID: interaction.user.id };
|
||||
await db.optout.create(body);
|
||||
await interaction.reply({ content: 'You have successfully been opt out.', ephemeral: true });
|
||||
}
|
||||
else {
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`yes${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('Yes')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`no${interaction.user.id}${interaction.id}`)
|
||||
.setLabel('No')
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
);
|
||||
|
||||
await interaction.reply({ content: 'You are already opt out, do you wish to opt in?', components: [row], ephemeral: true });
|
||||
|
||||
listenButton(client, interaction, interaction.user);
|
||||
}
|
||||
|
||||
return interaction.followUp({
|
||||
content:
|
||||
'As a reminder here what opting out does:\n'
|
||||
+ '- Your user ID will no longer be used for debug logging.\n'
|
||||
+ '- servers will no longer be shown in added/kicked stats.\n'
|
||||
+ '- Your messages won\'t be quoted.\n'
|
||||
+ '- Won\'t show the arguments from commands.',
|
||||
ephemeral: true,
|
||||
},
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
async function listenButton(client, interaction, user = interaction.user, originalId = interaction.id) {
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (user !== interactionMenu.user) return listenButton(client, interaction, user, originalId);
|
||||
if (!interactionMenu.isButton()) return;
|
||||
|
||||
await interactionMenu.update({ components: [] });
|
||||
|
||||
if (interactionMenu.customId === `yes${interaction.user.id}${originalId}`) {
|
||||
db.optout.destroy({ where: { userID: interaction.user.id } });
|
||||
return interaction.editReply({ content: 'You have successfully been opt in', ephemeral: true });
|
||||
}
|
||||
else {
|
||||
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
|
||||
}
|
||||
});
|
||||
}
|
@ -1,21 +1,41 @@
|
||||
import { SlashCommandBuilder, ButtonBuilder, ActionRowBuilder, ButtonStyle } from 'discord.js';
|
||||
const { uptimePage } = process.env;
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('ping')
|
||||
.setDescription('Replies with Pong!'),
|
||||
category: 'utility',
|
||||
async execute(interaction) {
|
||||
const { oneLine } = require('common-tags');
|
||||
const { Command } = require('discord.js-commando');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setLabel('Status page')
|
||||
.setURL(uptimePage)
|
||||
.setStyle(ButtonStyle.Link),
|
||||
);
|
||||
|
||||
module.exports = class PingCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'ping',
|
||||
group: 'util',
|
||||
memberName: 'ping',
|
||||
description: 'Checks the bot\'s ping to the Discord server.',
|
||||
throttling: {
|
||||
usages: 5,
|
||||
duration: 10
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await interaction.reply({ content: `Pong! \`${Math.round(interaction.client.ws.ping)} ms\``, components: [row] });
|
||||
},
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
if(!message.editable) {
|
||||
const pingMsg = await message.say('Pinging...');
|
||||
return pingMsg.edit(oneLine`
|
||||
${message.channel.type !== 'dm' ? `${message.author},` : ''}
|
||||
<:ping:499226870047571978> Pong! The message round-trip took **${pingMsg.createdTimestamp - message.createdTimestamp}**ms.
|
||||
${this.client.ping ? `The heartbeat ping is **${Math.round(this.client.ping)}**ms.` : ''}
|
||||
`);
|
||||
} else {
|
||||
await message.edit('Pinging...');
|
||||
return message.edit(oneLine`
|
||||
Pong! The message round-trip took **${message.editedTimestamp - message.createdTimestamp}**ms.
|
||||
${this.client.ping ? `The heartbeat ping is **${Math.round(this.client.ping)}**ms.` : ''}
|
||||
`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -0,0 +1,42 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
module.exports = class ServerCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'server',
|
||||
group: 'utility',
|
||||
guildOnly: 'true',
|
||||
memberName: 'server',
|
||||
description: 'Show some stats about the server',
|
||||
guildOnly: true,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
try {
|
||||
let customresponse = new SelfReloadJSON(`./tag/${message.guild.id}.json`);
|
||||
var count = Object.keys(customresponse).length
|
||||
} catch {
|
||||
var count = 'None'
|
||||
}
|
||||
|
||||
|
||||
const addEmbed = {
|
||||
color: 0x0099ff,
|
||||
title: 'Stats of the server',
|
||||
thumbnail: {
|
||||
url: `${message.guild.iconURL}`,
|
||||
},
|
||||
description: `Member: **${message.guild.memberCount}** \nChannel number: **${message.guild.channels.size}**\nGuild created at **${message.guild.createdAt}**\nOwner: **${message.guild.owner}**\nTag number: **${count}**`,
|
||||
};
|
||||
|
||||
message.say({ embed: addEmbed });
|
||||
}
|
||||
};
|
@ -1,55 +1,30 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, version } from 'discord.js';
|
||||
import os from 'node:os';
|
||||
const { Command } = require('discord.js-commando');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
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();
|
||||
const date = new Date(uptime * 1000);
|
||||
const days = date.getUTCDate() - 1,
|
||||
hours = date.getUTCHours(),
|
||||
minutes = date.getUTCMinutes(),
|
||||
seconds = date.getUTCSeconds();
|
||||
|
||||
module.exports = class statsCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'stats',
|
||||
group: 'utility',
|
||||
memberName: 'stats',
|
||||
description: 'Show bot stats.',
|
||||
});
|
||||
}
|
||||
|
||||
const segments = [];
|
||||
|
||||
// Format the uptime string.
|
||||
if (days > 0) segments.push(days + ' day' + ((days == 1) ? '' : 's'));
|
||||
if (hours > 0) segments.push(hours + ' hour' + ((hours == 1) ? '' : 's'));
|
||||
if (minutes > 0) segments.push(minutes + ' minute' + ((minutes == 1) ? '' : 's'));
|
||||
if (seconds > 0) segments.push(seconds + ' second' + ((seconds == 1) ? '' : 's'));
|
||||
const dateString = segments.join(', ');
|
||||
|
||||
const bytesToSize = (bytes) => {
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
||||
if (bytes == 0) return '0 Byte';
|
||||
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
|
||||
return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
|
||||
};
|
||||
|
||||
const statsEmbed = new EmbedBuilder()
|
||||
.setColor(interaction.member ? interaction.member.displayHexColor : 'Navy')
|
||||
.setTitle('Bot stats')
|
||||
.setAuthor({ name: client.user.username, iconURL: client.user.displayAvatarURL(), url: 'https://libtar.de' })
|
||||
.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] });
|
||||
},
|
||||
};
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let totalSeconds = (this.client.uptime / 1000);
|
||||
let days = Math.floor(totalSeconds / 86400);
|
||||
let hours = Math.floor(totalSeconds / 3600);
|
||||
totalSeconds %= 3600;
|
||||
let minutes = Math.floor(totalSeconds / 60);
|
||||
let seconds = totalSeconds.toFixed(0) % 60;
|
||||
let uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`;
|
||||
return message.channel.send(`Servers: \`${this.client.guilds.size}\`\nChannels: \`${this.client.channels.size}\`\nUsers: \`${this.client.users.size}\`\nBot uptime: \`${uptime}\``);
|
||||
}
|
||||
};
|
@ -0,0 +1,23 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
module.exports = class supportMeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'supportme',
|
||||
group: 'utility',
|
||||
memberName: 'supportme',
|
||||
description: `Support me and my bot`,
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { text }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
message.say('If you want to support me and my bot you can donate here\nhttps://donatebot.io/checkout/487640086859743232\nor here on patreon: https://patreon.com/user?u=15330358&utm_medium=social&utm_source=twitter&utm_campaign=creatorshare\n(This is totally optional dont feel forced to do it)');
|
||||
}
|
||||
};
|
@ -0,0 +1,48 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
const Discord = require('discord.js');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const fs = require('fs');
|
||||
module.exports = class taglistCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'taglist',
|
||||
group: 'utility',
|
||||
memberName: 'taglist',
|
||||
description: `List all the tag`
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(blacklist[message.author.id])
|
||||
return message.channel.send("You are blacklisted")
|
||||
|
||||
try {
|
||||
let customresponse = new SelfReloadJSON(`./tag/${message.guild.id}.json`);
|
||||
let count = Object.keys(customresponse).length
|
||||
|
||||
|
||||
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
let json = JSON.stringify(data)
|
||||
json = json.replace(/[{}"\\]+/g, '')
|
||||
json = json.replace(/,+/g, '\n')
|
||||
const tagEmbed = new Discord.RichEmbed()
|
||||
.setColor("#ff9900")
|
||||
.setTitle('Tags list')
|
||||
.setDescription(`Trigger:Response\n\n${json}`)
|
||||
.setFooter(`You have ${count} tags on this server`)
|
||||
|
||||
message.say(tagEmbed);
|
||||
});
|
||||
} catch {
|
||||
message.say('An error has occured, do you have any tags on the server?')
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
@ -0,0 +1,59 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const fetch = require('node-fetch')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
const Discord = require('discord.js');
|
||||
const { yandexAPI } = require('../../config.json');
|
||||
|
||||
module.exports = class translationCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'translation',
|
||||
aliases: ['trn', 'translate'],
|
||||
group: 'utility',
|
||||
memberName: 'translation',
|
||||
description: `Translate what you say in english`,
|
||||
args: [
|
||||
{
|
||||
key: 'language',
|
||||
prompt: 'In what language do you want me to translate to? ( You can get the list here https://tech.yandex.com/translate/doc/dg/concepts/api-overview-docpage/)',
|
||||
type: 'string',
|
||||
default: 'en',
|
||||
oneOf: ["az","ml","sq","mt","am","mk","en","mi","ar","mr","hy","mhr","af","mn","eu","de","ba","ne","be","no","bn","pa","my","pap","bg","fa","bs","pl","cy","pt","hu","ro","vi","ru","ht","ceb","gl","sr","nl","si","mrj","sk","el","sl","ka","sw","gu","su","da","tg","he","th","yi","tl","id","ta","ga","tt","it","te","is","tr","es","udm","kk","uz","kn","uk","ca","ur","ky","fi","zh","fr","ko","hi","xh","hr","km","cs","lo","sv","la","gd","lv","et","lt","eo","lb","jv","mg","ja","ms"]
|
||||
},
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What do you want me to translate',
|
||||
type: 'string',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { text, language }) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
let textURI = encodeURI(text)
|
||||
fetch(`https://translate.yandex.net/api/v1.5/tr.json/translate?key=${yandexAPI}&text=${textURI}&lang=${language}&options=1`,{
|
||||
}).then((response) => {
|
||||
return response.json();
|
||||
}).then((response) => {
|
||||
if (response.code != '200')
|
||||
return message.say('An error has occured')
|
||||
|
||||
|
||||
const translationEmbed = new Discord.RichEmbed()
|
||||
.setColor('#0099ff')
|
||||
.setTitle('Asked for the following translation:')
|
||||
.setAuthor(message.author.username)
|
||||
.setDescription(response.text[0])
|
||||
.addField('Original text', text)
|
||||
.addField('Translated from', response.detected.lang)
|
||||
.setTimestamp()
|
||||
.setFooter('Powered by Yandex.Translate ');
|
||||
|
||||
message.say(translationEmbed)
|
||||
});
|
||||
}};
|
@ -0,0 +1,36 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../json/blacklist.json');
|
||||
|
||||
|
||||
module.exports = class UpDootCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'updoot',
|
||||
aliases: ['vote'],
|
||||
group: 'utility',
|
||||
memberName: 'updoot',
|
||||
description: 'Send link to updoot my bot :D.',
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
||||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
const upDoot = {
|
||||
color: 0x93C54B,
|
||||
title: 'Vote for my bot',
|
||||
url: 'https://discordbots.org/bot/377563711927484418/vote',
|
||||
description: 'You can vote for my bot if you think the bot is awesome!',
|
||||
timestamp: new Date(),
|
||||
footer: {
|
||||
text: 'Thanks for the updoots',
|
||||
icon_url: 'https://cdn.discordapp.com/avatars/377563711927484418/1335d202aa466dbeaa4ed2e4b616484a.png?size=2048',
|
||||
},
|
||||
};
|
||||
|
||||
message.channel.send({ embed: upDoot });
|
||||
}
|
||||
};
|
@ -1,43 +0,0 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { rand } from '../../utils/rand.js';
|
||||
import { execFile } from 'node:child_process';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('dectalk')
|
||||
.setDescription('Send a .wav sound file of what you wrote with dectalk')
|
||||
.addStringOption(option =>
|
||||
option.setName('message')
|
||||
.setDescription('Write something so I can talk it back with dectalk.')
|
||||
.setRequired(true)),
|
||||
category: 'voice',
|
||||
async execute(interaction, args) {
|
||||
args.message = rand(args.message, interaction);
|
||||
const output = `${interaction.id}_dectalk.wav`;
|
||||
const message = '[:phoneme on]' + args.message;
|
||||
await interaction.deferReply({ ephemeral: false });
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Untested, most likely do not work.
|
||||
execFile('say.exe', ['-w', output, `${message}`], { cwd: './bin/dectalk/' }, (error, stdout, stderr) => {
|
||||
sendMessage(output, error, stdout, stderr);
|
||||
});
|
||||
}
|
||||
else if (process.platform === 'linux' || process.platform === 'darwin') {
|
||||
execFile('wine', ['say.exe', '-w', output, `${message}`], { cwd: './bin/dectalk/' }, (error, stdout, stderr) => {
|
||||
sendMessage(`./bin/dectalk/${output}`, error, stdout, stderr);
|
||||
});
|
||||
}
|
||||
|
||||
async function sendMessage(file, error, stdout, stderr) {
|
||||
if (error) {
|
||||
console.error(stderr);
|
||||
console.error(error);
|
||||
return interaction.editReply('Oh no! an error has occurred!');
|
||||
}
|
||||
|
||||
return interaction.editReply({ files: [file] });
|
||||
}
|
||||
|
||||
},
|
||||
};
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"token": "Your token",
|
||||
"prefix": "Your prefix ",
|
||||
"ownerID": "Id of the owner ( probably you )",
|
||||
"botID": "id of the bot",
|
||||
"statsChannel": "channel where the bot send his stats",
|
||||
"supportServer": "Invite to the support server of the bot",
|
||||
"feedbackChannel": "id of the channel where the feedback goes",
|
||||
"printChannel": "Channel of where it will send the id of people who asked for print",
|
||||
"fbuser": "Facebook email",
|
||||
"fbpasswd": "Facebook passwd",
|
||||
"yandexAPI": "yandex api key"
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"development": {
|
||||
"dialect": "sqlite",
|
||||
"storage": "./database.sqlite3"
|
||||
},
|
||||
"test": {
|
||||
"dialect": "sqlite",
|
||||
"storage": ":memory"
|
||||
},
|
||||
"production": {
|
||||
"dialect": "sqlite",
|
||||
"storage": "./database.sqlite3"
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue