Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
feat: blocked message info btn
Browse files Browse the repository at this point in the history
  • Loading branch information
wdhdev committed Jun 29, 2023
1 parent 0888574 commit c6a4f42
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 2 deletions.
36 changes: 36 additions & 0 deletions src/buttons/logs/blocked-message-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const emoji = require("../../config.json").emojis;

const blockedSchema = require("../../models/blockedSchema");

module.exports = {
name: "blocked-message-info",
startsWith: true,
async execute(interaction, client, Discord) {
try {
const id = interaction.customId.replace("blocked-message-info-", "");

if(!await blockedSchema.exists({ _id: id })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.error} No message was found with that ID!`)

await interaction.reply({ embeds: [error], ephemeral: true });
return;
}

const data = await blockedSchema.findOne({ _id: id });

const info = new Discord.EmbedBuilder()
.setColor(client.config_embeds.default)
.addFields (
{ name: "💬 Message ID", value: `${data._id}` },
{ name: "👤 User ID", value: `${data.user}` },
{ name: "🗄️ Guild ID", value: `${data.guild}` }
)

await interaction.reply({ embeds: [info], ephemeral: true });
} catch(err) {
client.logButtonError(err, interaction, Discord);
}
}
}
5 changes: 5 additions & 0 deletions src/util/filter/tests/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ module.exports = async function(message, client, Discord) {

const actions = new Discord.ActionRowBuilder()
.addComponents (
new Discord.ButtonBuilder()
.setStyle(Discord.ButtonStyle.Secondary)
.setCustomId(`blocked-message-info-${message.id}`)
.setEmoji("ℹ️"),

new Discord.ButtonBuilder()
.setStyle(Discord.ButtonStyle.Secondary)
.setCustomId(`ban-${message.author.id}`)
Expand Down
10 changes: 9 additions & 1 deletion src/util/filter/tests/phishing.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ module.exports = async function(message, client, Discord) {
{ name: "⚒️ Action", value: "🔨 Ban" }
)

const actions = new Discord.ActionRowBuilder()
.addComponents (
new Discord.ButtonBuilder()
.setStyle(Discord.ButtonStyle.Secondary)
.setCustomId(`blocked-message-info-${message.id}`)
.setEmoji("ℹ️")
)

const ban = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setTitle("Banned")
Expand Down Expand Up @@ -73,7 +81,7 @@ module.exports = async function(message, client, Discord) {

blocked.setAuthor({ name: message.author.tag.endsWith("#0") ? `@${message.author.username}` : message.author.tag, iconURL: message.author.displayAvatarURL({ format: "png", dynamic: true }), url: `https://discord.com/users/${message.author.id}` });

blockedChannel.send({ embeds: [blocked] });
blockedChannel.send({ embeds: [blocked], components: [actions] });

const banLog = new Discord.EmbedBuilder()
.setColor(client.config_embeds.default)
Expand Down
10 changes: 10 additions & 0 deletions src/util/filter/tests/profanity.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ module.exports = async function(message, client, Discord) {

const actions = new Discord.ActionRowBuilder()
.addComponents (
new Discord.ButtonBuilder()
.setStyle(Discord.ButtonStyle.Secondary)
.setCustomId(`blocked-message-info-${message.id}`)
.setEmoji("ℹ️"),

new Discord.ButtonBuilder()
.setStyle(Discord.ButtonStyle.Secondary)
.setCustomId(`ban-${message.author.id}`)
Expand Down Expand Up @@ -126,6 +131,11 @@ module.exports = async function(message, client, Discord) {

const actions = new Discord.ActionRowBuilder()
.addComponents (
new Discord.ButtonBuilder()
.setStyle(Discord.ButtonStyle.Secondary)
.setCustomId(`blocked-message-info-${message.id}`)
.setEmoji("ℹ️"),

new Discord.ButtonBuilder()
.setStyle(Discord.ButtonStyle.Secondary)
.setCustomId(`ban-${message.author.id}`)
Expand Down
10 changes: 9 additions & 1 deletion src/util/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ module.exports = async function (message, client, Discord) {
)
.setTimestamp()

const actions = new Discord.ActionRowBuilder()
.addComponents (
new Discord.ButtonBuilder()
.setStyle(Discord.ButtonStyle.Secondary)
.setCustomId(`blocked-message-info-${message.id}`)
.setEmoji("ℹ️")
)

if(message.content.length) blocked.setDescription(message.content);

if(message.attachments.first()) {
Expand All @@ -48,7 +56,7 @@ module.exports = async function (message, client, Discord) {
}
}

blockedChannel.send({ embeds: [blocked] });
blockedChannel.send({ embeds: [blocked], components: [actions] });
return;
}

Expand Down

0 comments on commit c6a4f42

Please sign in to comment.