Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { SlashCommandBuilder } = require(`@discordjs/builders`);
- const { PermissionsBitField, EmbedBuilder, } = require(`discord.js`);
- const warningSchema = require(`../../Models/warningSchema`)
- module.exports = {
- data:new SlashCommandBuilder()
- .setName(`warnings`)
- .setDescription(`This shows a server members warnings`)
- .addUserOption(option => option.setName('user').setDescription(`The user you want to check the warns of`).setRequired(true)),
- async execute(interaction) {
- const { options, guildId, user } = interaction;
- const target = options.getUser('user');
- const embed = new EmbedBuilder()
- const noWarns = new EmbedBuilder()
- warningSchema.findOne({ GuildID: guildId, UserID: user.id, UserTag: target.tag }, async (err, data) => {
- if (err) throw err;
- if (data) {
- embed.setColor("Blue")
- .setDescription(`<@${target.tag}>'s warnings: \n${data.Content.map(
- (w, i) =>
- `
- **Warning**: ${i + 1}
- **Warning Moderator**: ${w.ExecuterTag}
- **Warn Reason**: ${w.Reason}
- `
- ).join(`-`)}`)
- interaction.reply({ embeds: [embed] });
- } else {
- noWarns.setColor("Blue")
- .setDescription(`<@${target.id}> has no warnings.`)
- interaction.reply({ embeds: [noWarns]})
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement