Compare commits

..

4 commits

11 changed files with 201 additions and 31 deletions

View file

@ -0,0 +1,37 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import Twit from 'twit';
import dotenv from 'dotenv';
dotenv.config();
const { twiConsumer, twiConsumerSecret, twiToken, twiTokenSecret } = process.env;
export default {
data: new SlashCommandBuilder()
.setName('deletewteet')
.setDescription('Delete a tweet')
.addStringOption(option =>
option.setName('tweetid')
.setDescription('The id of the tweet you wish to delete.')
.setRequired(true)),
ownerOnly: true,
async execute(interaction) {
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: interaction.options.getString('tweetid'),
});
return interaction.editReply('Tweet have been deleted!');
}
catch (err) {
console.error(err);
return interaction.editReply('Oh no, an error has occurred :(');
}
},
};

View file

@ -1,17 +1,12 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import dotenv from 'dotenv';
import process from 'node:process';
dotenv.config();
const { ownerId } = process.env;
export default {
data: new SlashCommandBuilder()
.setName('die')
.setDescription('Kill the bot'),
ownerOnly: true,
async execute(interaction) {
if (interaction.user.id !== ownerId) {
return interaction.reply({ content: '❌ This command is reserved for the owner!', ephemeral: true });
}
console.log('\x1b[31m\x1b[47m\x1b[5mSHUTING DOWN!!!!!\x1b[0m');
await interaction.reply({ content: 'Good bye', ephemeral: true })
.then(() => {

View file

@ -0,0 +1,70 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { MessageButton, MessageActionRow } 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)),
ownerOnly: true,
async execute(interaction) {
await interaction.deferReply({ ephemeral: true });
const client = interaction.client;
const command = interaction.options.getString('command');
const userid = interaction.options.getString('userid');
const reason = interaction.options.getString('reason');
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;
if (command !== 'guild') {user = client.users.resolve(userid).tag;}
return interaction.editReply(`${user} has been blacklisted from ${command} with the following reason ${reason}`);
}
else {
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('yes')
.setLabel('Yes')
.setStyle('PRIMARY'),
)
.addComponents(
new MessageButton()
.setCustomId('no')
.setLabel('No')
.setStyle('DANGER'),
);
await interaction.editReply({ content: 'This user is already blacklisted, do you want to unblacklist him?', ephemeral: true, components: [row] });
interaction.client.once('interactionCreate', async (interactionMenu) => {
if (!interactionMenu.isButton) return;
interactionMenu.update({ components: [] });
if (interactionMenu.customId === 'yes') {
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.');
}
});
}
},
};

View file

@ -0,0 +1,30 @@
import { SlashCommandBuilder } from '@discordjs/builders';
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'),
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.tag} (${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);
},
};

View file

@ -1,18 +0,0 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
require('dotenv').config();
const { clientId, guildId, token } = process.env;
const commands = [
new SlashCommandBuilder()
.setName('die')
.setDescription('Kill the bot'),
]
.map(command => command.toJSON());
const rest = new REST({ version: '9' }).setToken(token);
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
.then(() => console.log(`Successfully registered application commands for the guild ${guildId}.`))
.catch(console.error);

View file

@ -4,7 +4,7 @@ import { MessageEmbed } from 'discord.js';
import dotenv from 'dotenv';
dotenv.config();
const { statusChannel } = process.env;
const { statusChannel, NODE_ENV } = process.env;
export default {
name: 'guildCreate',
@ -21,7 +21,7 @@ export default {
}
// If stats channel settings exist, send bot stats to it
if (statusChannel) {
if (statusChannel && NODE_ENV !== 'development') {
const channel = client.channels.resolve(statusChannel);
const botCount = guild.members.cache.filter(member => member.user.bot).size;
console.log(guild.memberCount);

View file

@ -4,7 +4,7 @@ import { MessageEmbed } from 'discord.js';
import dotenv from 'dotenv';
dotenv.config();
const { statusChannel } = process.env;
const { statusChannel, NODE_ENV } = process.env;
export default {
name: 'guildDelete',
@ -17,7 +17,7 @@ export default {
const blacklist = await guildBlacklist.findOne({ where: { guildID:guild.id } });
// If stats channel settings exist, send bot stats to it
if (statusChannel) {
if (statusChannel && NODE_ENV !== 'development') {
const channel = client.channels.resolve(statusChannel);
const botCount = guild.members.cache.filter(member => member.user.bot).size;
console.log(guild.memberCount);

View file

@ -1,5 +1,10 @@
import db from '../../models/index.js';
const ratelimit = {};
import dotenv from 'dotenv';
dotenv.config();
const { ownerId } = process.env;
export default {
name: 'interactionCreate',
async execute(interaction) {
@ -20,10 +25,15 @@ export default {
const commandName = interaction.commandName;
const command = client.commands.get(commandName);
console.log(`\x1b[33m${userTag} (${userID})\x1b[0m launched command \x1b[33m${commandName}\x1b[0m`);
if (!command) return;
console.log(`\x1b[33m${userTag} (${userID})\x1b[0m launched command \x1b[33m${commandName}\x1b[0m`);
if (command.ownerOnly && interaction.user.id !== ownerId) {
return interaction.reply({ content: '❌ This command is reserved for the owner!', ephemeral: true });
}
try {
const date = new Date();
if (ratelimit[userID]) {

View file

@ -1,7 +1,7 @@
import { exec } from 'node:child_process';
import dotenv from 'dotenv';
dotenv.config();
const { statusChannel } = process.env;
const { statusChannel, NODE_ENV } = process.env;
export default {
name: 'ready',
@ -34,7 +34,7 @@ export default {
console.log('===========[ READY ]===========');
// If stats channel settings exist, send bot stats to it
if (statusChannel) {
if (statusChannel && NODE_ENV !== 'development') {
const channel = client.channels.resolve(statusChannel);
channel.send(`Ready to serve in ${channelSize} channels on ${guildSize} servers.\nThere is ${commandSize} command loaded.\nRunning yt-dlp ${ytdlpVersion.replace('\n', '')}\n${client.readyAt}`);
}

View file

@ -69,6 +69,10 @@ const commands = [
option.setName('board')
.setDescription('The board you wish to see')
.setRequired(true)),
new SlashCommandBuilder()
.setName('donator')
.setDescription('All the people who donated for this bot <3'),
]
.map(command => command.toJSON());

View file

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