Compare commits
No commits in common. "850a6fb827cdaf8ae712a58ad1162c69d7e79dc5" and "73e5050ded46e78a60a9baba3e30e8191a6fd17e" have entirely different histories.
850a6fb827
...
73e5050ded
7 changed files with 37 additions and 245 deletions
|
@ -1,48 +0,0 @@
|
|||
import { SlashCommandBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder, PermissionFlagsBits } from 'discord.js';
|
||||
import db from '../../models/index.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('autoresponse')
|
||||
.setDescription('Enable or disable autoresponse'),
|
||||
category: 'utility',
|
||||
userPermissions: [PermissionFlagsBits.ManageMessages],
|
||||
async execute(interaction, args, client) {
|
||||
const autoresponseStat = await db.autoresponseStat.findOne({ where: { serverID: interaction.guild.id } });
|
||||
|
||||
if (autoresponseStat.stat !== 'enable') {
|
||||
const body = { serverID: interaction.guild.id, stat: 'enable' };
|
||||
await db.autoresponseStat.create(body);
|
||||
return await interaction.reply({ content: 'Autoresponse has been enabled.' });
|
||||
}
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('yes')
|
||||
.setLabel('Yes')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('no')
|
||||
.setLabel('No')
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
);
|
||||
|
||||
await interaction.reply({ content: 'Autoresponse is already enabled, do you wish to disable it?', components: [row] });
|
||||
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (!interactionMenu.isButton) return;
|
||||
interactionMenu.update({ components: [] });
|
||||
if (interactionMenu.customId === 'yes') {
|
||||
const body = { serverID: interaction.guild.id, stat: 'disable' };
|
||||
await db.autoresponseStat.update(body, { where: { serverID: interaction.guild.id } });
|
||||
return interaction.editReply('Auto response has been disabled.');
|
||||
}
|
||||
else {
|
||||
return interaction.editReply('Nothing has been changed.');
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
|
@ -1,48 +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'),
|
||||
category: 'utility',
|
||||
userPermissions: [PermissionFlagsBits.ManageMessages],
|
||||
async execute(interaction, args, client) {
|
||||
const quotationstat = await db.quotationstat.findOne({ where: { serverID: interaction.guild.id } });
|
||||
|
||||
if (quotationstat.stat !== 'enable') {
|
||||
const body = { serverID: interaction.guild.id, stat: 'enable' };
|
||||
await db.quotationstat.create(body);
|
||||
return await interaction.reply({ content: 'Quotation has been enabled.' });
|
||||
}
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('yes')
|
||||
.setLabel('Yes')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('no')
|
||||
.setLabel('No')
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
);
|
||||
|
||||
await interaction.reply({ content: 'Quotation is already enabled, do you wish to disable it?', components: [row] });
|
||||
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (!interactionMenu.isButton) return;
|
||||
interactionMenu.update({ components: [] });
|
||||
if (interactionMenu.customId === 'yes') {
|
||||
const body = { serverID: interaction.guild.id, stat: 'disable' };
|
||||
await db.quotationstat.update(body, { where: { serverID: interaction.guild.id } });
|
||||
return interaction.editReply('Quotation has been disabled.');
|
||||
}
|
||||
else {
|
||||
return interaction.editReply('Nothing has been changed.');
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
|
@ -1,46 +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 quotation command.'),
|
||||
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);
|
||||
return await interaction.reply({ content: 'You have successfully been opt out.' });
|
||||
}
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('yes')
|
||||
.setLabel('Yes')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('no')
|
||||
.setLabel('No')
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
);
|
||||
|
||||
await interaction.reply({ content: 'You are already opt out, do you wish to opt in?', components: [row] });
|
||||
|
||||
client.once('interactionCreate', async (interactionMenu) => {
|
||||
if (!interactionMenu.isButton) return;
|
||||
interactionMenu.update({ components: [] });
|
||||
if (interactionMenu.customId === 'yes') {
|
||||
await db.optout.destroy({ where: { userID: interaction.user.id } });
|
||||
return interaction.editReply('You have successfully been opt in');
|
||||
}
|
||||
else {
|
||||
return interaction.editReply('Nothing has been changed.');
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
|
@ -205,49 +205,46 @@ export default {
|
|||
* This section will contain the code for the quotation feature, it will detect link for it and send it as embed
|
||||
*
|
||||
*/
|
||||
const isOptOut = await db.optout.findOne({ where: { userID: message.author.id } });
|
||||
if (!isOptOut) {
|
||||
const quotationstat = await db.quotationStat.findOne({ where: { serverID: message.guild.id, stat: 'enable' } });
|
||||
const quotationstat = await db.quotationStat.findOne({ where: { serverID: message.guild.id, stat: 'enable' } });
|
||||
|
||||
if (quotationstat && (message.content.includes('discordapp.com/channels/') || message.content.includes('discord.com/channels/'))) {
|
||||
const url = message.content.split('/');
|
||||
const guildID = url[4];
|
||||
const channelID = url[5];
|
||||
const messageID = url[6].split(' ')[0];
|
||||
if (quotationstat && (message.content.includes('discordapp.com/channels/') || message.content.includes('discord.com/channels/'))) {
|
||||
const url = message.content.split('/');
|
||||
const guildID = url[4];
|
||||
const channelID = url[5];
|
||||
const messageID = url[6].split(' ')[0];
|
||||
|
||||
|
||||
// Verify if the guild, channel and message exist
|
||||
const guild = client.guilds.resolve(guildID);
|
||||
if (!guild) return;
|
||||
const channel = client.channels.resolve(channelID);
|
||||
if (!channel) return;
|
||||
const quote = await channel.messages.fetch(messageID)
|
||||
.catch(() => {
|
||||
return;
|
||||
});
|
||||
if (!quote) return;
|
||||
// Verify if the guild, channel and message exist
|
||||
const guild = client.guilds.resolve(guildID);
|
||||
if (!guild) return;
|
||||
const channel = client.channels.resolve(channelID);
|
||||
if (!channel) return;
|
||||
const quote = await channel.messages.fetch(messageID)
|
||||
.catch(() => {
|
||||
return;
|
||||
});
|
||||
if (!quote) return;
|
||||
|
||||
const Embed = new EmbedBuilder()
|
||||
.setAuthor({ name: quote.author.username, iconURL: quote.author.displayAvatarURL() })
|
||||
.setColor(message.member ? message.member.displayHexColor : 'NAVY')
|
||||
.addFields(
|
||||
{ name: 'Jump to', value: `[message](https://discordapp.com/channels/${message.guild.id}/${channelID}/${messageID})`, inline: true },
|
||||
{ name: 'In channel', value: quote.channel.name.toString(), inline: true },
|
||||
{ name: 'Quoted by', value: message.author.toString(), inline: true },
|
||||
)
|
||||
.setDescription(quote.content)
|
||||
.setTimestamp(quote.createdTimestamp);
|
||||
const Embed = new EmbedBuilder()
|
||||
.setAuthor({ name: quote.author.username, iconURL: quote.author.displayAvatarURL() })
|
||||
.setColor(message.member ? message.member.displayHexColor : 'NAVY')
|
||||
.addFields(
|
||||
{ name: 'Jump to', value: `[message](https://discordapp.com/channels/${message.guild.id}/${channelID}/${messageID})`, inline: true },
|
||||
{ name: 'In channel', value: quote.channel.name.toString(), inline: true },
|
||||
{ name: 'Quoted by', value: message.author.toString(), inline: true },
|
||||
)
|
||||
.setDescription(quote.content)
|
||||
.setTimestamp(quote.createdTimestamp);
|
||||
|
||||
if (quote.member) Embed.setAuthor({ name: `${quote.author.username}#${quote.author.discriminator}`, iconURL: quote.author.displayAvatarURL() });
|
||||
if (quote.member) Embed.setAuthor({ name: `${quote.author.username}#${quote.author.discriminator}`, iconURL: quote.author.displayAvatarURL() });
|
||||
|
||||
if (quote.author.bot) Embed.setAuthor({ name: `${quote.author.username}#${quote.author.discriminator} (BOT)`, iconURL: quote.author.displayAvatarURL() });
|
||||
if (quote.author.bot) Embed.setAuthor({ name: `${quote.author.username}#${quote.author.discriminator} (BOT)`, iconURL: quote.author.displayAvatarURL() });
|
||||
|
||||
if (guild.id != message.guild.id) Embed.addFields({ name: 'In guild', value: guild.name, inline: true });
|
||||
const Attachment = Array.from(message.attachments.values());
|
||||
if (Attachment[0]) Embed.setImage(Attachment[0].url);
|
||||
if (guild.id != message.guild.id) Embed.addFields({ name: 'In guild', value: guild.name, inline: true });
|
||||
const Attachment = Array.from(message.attachments.values());
|
||||
if (Attachment[0]) Embed.setImage(Attachment[0].url);
|
||||
|
||||
return message.channel.send({ embeds: [Embed] });
|
||||
}
|
||||
return message.channel.send({ embeds: [Embed] });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,22 +260,9 @@ export default {
|
|||
if (!hasPrefix) return;
|
||||
|
||||
const messageArray = message.content.match(/"[^"]*"|\S+/g).map(m => m.slice(0, 1) === '"' ? m.slice(1, -1) : m);
|
||||
let commandName = messageArray[1].toLowerCase();
|
||||
const commandName = messageArray[1].toLowerCase();
|
||||
let messageArgs = messageArray.splice(2, messageArray.length);
|
||||
|
||||
// Search for alias
|
||||
client.commands.find(c => {
|
||||
if (c.alias) {
|
||||
if (c.alias.includes(commandName)) {
|
||||
commandName = c.data.name;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const command = client.commands.get(commandName);
|
||||
|
||||
if (!command) return;
|
||||
|
||||
const globalBlacklist = await db.Blacklists.findOne({ where: { type:'global', uid:message.author.id } });
|
||||
const commandBlacklist = await db.Blacklists.findOne({ where: { type:commandName, uid:message.author.id } });
|
||||
|
||||
|
@ -292,6 +276,10 @@ export default {
|
|||
const userTag = message.author.tag;
|
||||
const userID = message.author.id;
|
||||
|
||||
const command = client.commands.get(commandName);
|
||||
|
||||
if (!command) return;
|
||||
|
||||
console.log(`\x1b[33m${userTag} (${userID})\x1b[0m launched command \x1b[33m${commandName}\x1b[0m`);
|
||||
|
||||
// Owner only check
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
'use strict';
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.createTable('optouts', {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
userID: {
|
||||
type: Sequelize.BIGINT
|
||||
},
|
||||
createdAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
},
|
||||
updatedAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
}
|
||||
});
|
||||
},
|
||||
async down(queryInterface, Sequelize) {
|
||||
await queryInterface.dropTable('optouts');
|
||||
}
|
||||
};
|
|
@ -1,23 +0,0 @@
|
|||
'use strict';
|
||||
const {
|
||||
Model
|
||||
} = require('sequelize');
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
class optout extends Model {
|
||||
/**
|
||||
* Helper method for defining associations.
|
||||
* This method is not a part of Sequelize lifecycle.
|
||||
* The `models/index` file will call this method automatically.
|
||||
*/
|
||||
static associate(models) {
|
||||
// define association here
|
||||
}
|
||||
}
|
||||
optout.init({
|
||||
userID: DataTypes.BIGINT
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'optout',
|
||||
});
|
||||
return optout;
|
||||
};
|
|
@ -114,10 +114,6 @@ const commands = [
|
|||
.setDescription('🤫')
|
||||
.setRequired(true)),
|
||||
|
||||
new SlashCommandBuilder()
|
||||
.setName('autoresponse')
|
||||
.setDescription('Enable or disable autoresponse'),
|
||||
|
||||
new SlashCommandBuilder()
|
||||
.setName('die')
|
||||
.setDescription('Kill the bot'),
|
||||
|
|
Loading…
Reference in a new issue