toowake

Disable autoreply

Aug 7th, 2023
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require("discord.js");
  2. const Schema = require("../../Schemas.js/autoreply");
  3.  
  4. module.exports = {
  5. data: new SlashCommandBuilder()
  6. .setName("autoreply-delete")
  7. .setDescription("Delete the autoreply in your server")
  8. .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
  9. .addStringOption(option => option
  10. .setName("keyword")
  11. .setDescription("the keyword for the reply")
  12. .setRequired(true)
  13. ),
  14.  
  15. async execute (interaction, client) {
  16. const embed = new EmbedBuilder();
  17.  
  18. const {options, guild} = interaction;
  19. const g = guild.id;
  20. const keyword = options.getString("keyword");
  21.  
  22. const data = await Schema.findOne({ Guild: g, Keyword: keyword });
  23.  
  24. if (data) {
  25. embed.setDescription(`Deleted Autoreply for **${keyword}**! | Reply: **${data.Reply}**`).setColor("Red")
  26.  
  27. await Schema.deleteMany({
  28. Guild: g,
  29. Keyword: keyword
  30. })
  31.  
  32. await interaction.reply({
  33. embeds: [embed],
  34. ephemeral: true
  35. });
  36. } else {
  37. embed.setColor("White").setDescription(`Error: could not find a schema for **${keyword}**!`)
  38.  
  39. await interaction.reply({ embeds: [embed], ephemeral: true });
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment