Advertisement
mach10

Untitled

Feb 11th, 2023
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.56 KB | Source Code | 0 0
  1. const { SlashCommandBuilder } = require(`@discordjs/builders`);
  2. const { PermissionsBitField, EmbedBuilder, } = require(`discord.js`);
  3. const warningSchema = require(`../../Models/warningSchema`)
  4.  
  5.  
  6. module.exports = {
  7.     data:new SlashCommandBuilder()
  8.     .setName(`warnings`)
  9.     .setDescription(`This shows a server members warnings`)
  10.     .addUserOption(option => option.setName('user').setDescription(`The user you want to check the warns of`).setRequired(true)),
  11.     async execute(interaction) {
  12.  
  13.        
  14.         const { options, guildId, user } = interaction;
  15.  
  16.         const target = options.getUser('user');
  17.  
  18.         const embed = new EmbedBuilder()
  19.         const noWarns = new EmbedBuilder()
  20.  
  21.         warningSchema.findOne({ GuildID: guildId, UserID: user.id, UserTag: target.tag }, async (err, data) => {
  22.  
  23.             if (err) throw err;
  24.  
  25.             if (data) {
  26.                 embed.setColor("Blue")
  27.                 .setDescription(`<@${target.tag}>'s warnings: \n${data.Content.map(
  28.                     (w, i) =>
  29.                        `
  30.                         **Warning**: ${i + 1}
  31.                         **Warning Moderator**: ${w.ExecuterTag}
  32.                         **Warn Reason**: ${w.Reason}
  33.                        `
  34.  
  35.                ).join(`-`)}`)
  36.                interaction.reply({ embeds: [embed] });
  37.            } else {
  38.                noWarns.setColor("Blue")
  39.                .setDescription(`<@${target.id}> has no warnings.`)
  40.  
  41.                interaction.reply({ embeds: [noWarns]})
  42.            }
  43.        });
  44.  
  45.    }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement