Compare commits

..

No commits in common. "850a6fb827cdaf8ae712a58ad1162c69d7e79dc5" and "73e5050ded46e78a60a9baba3e30e8191a6fd17e" have entirely different histories.

7 changed files with 37 additions and 245 deletions

View file

@ -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.');
}
});
},
};

View file

@ -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.');
}
});
},
};

View file

@ -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.');
}
});
},
};

View file

@ -205,8 +205,6 @@ 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' } });
if (quotationstat && (message.content.includes('discordapp.com/channels/') || message.content.includes('discord.com/channels/'))) {
@ -249,7 +247,6 @@ export default {
return message.channel.send({ embeds: [Embed] });
}
}
}
// Command handling from message
@ -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

View file

@ -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');
}
};

View file

@ -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;
};

View file

@ -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'),