forked from Supositware/Haha-Yes
Enable guild block list
This commit is contained in:
parent
50b55edae3
commit
49c756bd62
3 changed files with 33 additions and 19 deletions
|
@ -32,6 +32,15 @@ export default {
|
|||
if (!blacklist) {
|
||||
const body = { type:command, uid: userid, reason: reason };
|
||||
Blacklists.create(body);
|
||||
if (command === 'guild') {
|
||||
let guildid = userid;
|
||||
await client.guilds.fetch(guildid);
|
||||
const guild =client.guilds.resolve(guildid).name;
|
||||
|
||||
return interaction.editReply(`The guild ${guild} (${guildid}) has been blacklisted with the following reason \`${reason}\``);
|
||||
|
||||
}
|
||||
else {
|
||||
let user = userid;
|
||||
await client.users.fetch(userid);
|
||||
user = client.users.resolve(userid).username;
|
||||
|
@ -39,6 +48,7 @@ export default {
|
|||
|
||||
return interaction.editReply(`${user} (${userid}) has been blacklisted from ${command} with the following reason \`${reason}\``);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
|
|
|
@ -12,18 +12,20 @@ export default {
|
|||
const client = interaction.client;
|
||||
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
||||
|
||||
const globalBlacklist = await db.Blacklists.findOne({ where: { type:'global', uid:interaction.user.id } });
|
||||
// const serverBlacklist = await db.Blacklists.findOne({ where: { type:'guild', uid:interaction.guild.id } });
|
||||
const globalBlacklist = await db.Blacklists.findOne({ where: { type:'global', uid:interaction.user.id } })
|
||||
const commandBlacklist = await db.Blacklists.findOne({ where: { type:interaction.commandName, uid:interaction.user.id } });
|
||||
|
||||
if (interaction.guild) {
|
||||
const serverBlacklist = await db.Blacklists.findOne({ where: { type:'guild', uid:interaction.guild.id } });
|
||||
if (serverBlacklist) {
|
||||
interaction.reply({ content: `This guild has been blacklisted for the following reason: \`${serverBlacklist.reason}\``, ephemeral: true });
|
||||
return interaction.guild.leave();
|
||||
}
|
||||
}
|
||||
|
||||
if (globalBlacklist) {
|
||||
return interaction.reply({ content: `You are globally blacklisted for the following reason: \`${globalBlacklist.reason}\``, ephemeral: true });
|
||||
}
|
||||
/* Server blacklist is untested
|
||||
else if (serverBlacklist) {
|
||||
return interaction.reply({ content: `This guild has been blacklisted for the following reason: \`${serverBlacklist.reason}\``, ephemeral: true });
|
||||
}
|
||||
*/
|
||||
else if (commandBlacklist) {
|
||||
return interaction.reply({ content: `You are blacklisted for the following reason: \`${commandBlacklist.reason}\``, ephemeral: true });
|
||||
}
|
||||
|
|
|
@ -282,17 +282,19 @@ export default {
|
|||
if (!command) return;
|
||||
|
||||
const globalBlacklist = await db.Blacklists.findOne({ where: { type:'global', uid:message.author.id } });
|
||||
// const serverBlacklist = await db.Blacklists.findOne({ where: { type:'guild', uid:message.guild.id } });
|
||||
const commandBlacklist = await db.Blacklists.findOne({ where: { type:commandName, uid:message.author.id } });
|
||||
|
||||
if (message.guild) {
|
||||
const serverBlacklist = await db.Blacklists.findOne({ where: { type:'guild', uid:message.guild.id } });
|
||||
if (serverBlacklist) {
|
||||
message.reply({ content: `This guild has been blacklisted for the following reason: \`${serverBlacklist.reason}\``, ephemeral: true });
|
||||
return message.guild.leave();
|
||||
}
|
||||
}
|
||||
|
||||
if (globalBlacklist) {
|
||||
return message.reply({ content: `You are globally blacklisted for the following reason: \`${globalBlacklist.reason}\``, ephemeral: true });
|
||||
}
|
||||
/* Server blacklist is untested
|
||||
else if (serverBlacklist) {
|
||||
return message.reply({ content: `This guild has been blacklisted for the following reason: \`${serverBlacklist.reason}\``, ephemeral: true });
|
||||
}
|
||||
*/
|
||||
else if (commandBlacklist) {
|
||||
return message.reply({ content: `You are blacklisted for the following reason: \`${commandBlacklist.reason}\``, ephemeral: true });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue