toowake

steal.js

May 22nd, 2023
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { SlashCommandBuilder } = require('@discordjs/builders');
  2. const { default: axios } = require('axios');
  3. const { EmbedBuilder, PermissionsBitField } = require('discord.js');
  4.  
  5. module.exports = {
  6.     data: new SlashCommandBuilder()
  7.     .setName('steal')
  8.     .setDescription('Adds a given emoji to the server')
  9.     .addStringOption(option => option.setName('emoji').setDescription('The emoji you would like to add to the server').setRequired(true))
  10.     .addStringOption(option => option.setName('name').setDescription('The name for your emoji').setRequired(true)),
  11.     async execute(interaction) {
  12.         const errEmbed = new EmbedBuilder()
  13.         .setTitle("ERROR")
  14.         .setColor("Red")
  15.         .setDescription("Missing Permissions: Manage Emojis and Stickers")
  16.         .setTimestamp()
  17.  
  18.         if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageEmojisAndStickers)) return await interaction.reply({ embeds: [errEmbed], ephemeral: true});
  19.  
  20.         let emoji = interaction.options.getString('emoji')?.trim();
  21.         const name = interaction.options.getString('name');
  22.  
  23.         if (emoji.startsWith("<") && emoji.endsWith(">")) {
  24.             const id = emoji.match(/\d{15,}/g)[0];
  25.  
  26.             const type = await axios.get(`https://cdn.discordapp.com/emojis/${id}.gif`)
  27.             .then(image => {
  28.                 if (image) return "gif"
  29.                 else return "png"
  30.             }).catch(err => {
  31.                 return "png"
  32.             })
  33.  
  34.             emoji = `https://cdn.discordapp.com/emojis/${id}.${type}?quality=lossless`
  35.         }
  36.  
  37.         if (!emoji.startsWith("http")) {
  38.             return await interaction.reply({ content: "You cannot steal default emojis!"})
  39.         }
  40.  
  41.         if (!emoji.startsWith("https")) {
  42.             return await interaction.reply({ content: "You cannot steal default emojis!"})
  43.         }
  44.  
  45.         if (emoji.startsWith("+")) {
  46.             return;
  47.         }
  48.  
  49.         if (emoji.startsWith("-")) {
  50.             return;
  51.         }
  52.  
  53.         if (emoji.startsWith("=")) {
  54.             return;
  55.         }
  56.  
  57.         if (name.startsWith("+")) {
  58.             return ("You cant use those Characters!")
  59.         }
  60.  
  61.         if (name.startsWith("-")) {
  62.             return ("You cant use those Characters!")
  63.         }
  64.  
  65.         if (name.startsWith("=")) {
  66.             return ("You cant use those Characters!")
  67.         }
  68.  
  69.         interaction.guild.emojis.create({ attachment: `${emoji}`, name: `${name}`})
  70.         .then(emoji => {
  71.             const embed = new EmbedBuilder()
  72.             .setColor("DarkOrange")
  73.             .setDescription(`Added ${emoji}, with the name "**${name}**"`)
  74.  
  75.             return interaction.reply({ embeds: [embed] });
  76.         }).catch(err => {
  77.             console.log(err)
  78.             interaction.reply({ content: "You cannot add this emoji because you have reached your server emoji limit", ephemeral: true})
  79.         })
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment