toowake

Adv. embed creator with Images

Apr 9th, 2023
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. const { SlashCommandBuilder, EmbedBuilder, PermissionsBitField} = require("discord.js");
  2.  
  3. module.exports = {
  4. data: new SlashCommandBuilder()
  5. .setName("create-embed")
  6. .setDescription("Create an embed message")
  7. .addStringOption(option => option
  8. .setName("title")
  9. .setDescription("The title of the embed")
  10. .setRequired(true)
  11. )
  12. .addStringOption(option => option
  13. .setName("description")
  14. .setDescription("The description")
  15. .setRequired(true)
  16. )
  17. .addStringOption(option => option
  18. .setName("color")
  19. .setDescription("The color of the embed")
  20. .setRequired(true)
  21. .addChoices(
  22. {name: "aqua", value: "#00FFFF"},
  23. {name: "blurple", value: "#7289DA"},
  24. {name: "fuchsia", value: "#FF00FF"},
  25. {name: "gold", value: "#FFD700"},
  26. {name: "green", value: "#008000"},
  27. {name: "grey", value: "#808080"},
  28. {name: "greyple", value: "#7D7F9A"},
  29. {name: "light-grey", value: "#D3D3D3"},
  30. {name: "luminos-vivid-pink", value: "#FF007F"},
  31. {name: "navy", value: "#000080"},
  32. {name: "not-quite-black", value: "#232323"},
  33. {name: "orange", value: "#FFA500"},
  34. {name: "purple", value: "#800080"},
  35. {name: "red", value: "#FF0000"},
  36. {name: "white", value: "#FFFFFF"},
  37. {name: "yellow", value: "#FFFF00"},
  38. {name: "blue", value: "#0000FF"}
  39. )
  40. )
  41. .addStringOption(option => option
  42. .setName("hyperlink-name")
  43. .setDescription("Name of the hyperlink")
  44. .setRequired(false)
  45. )
  46. .addStringOption(option => option
  47. .setName("hyperlink-link")
  48. .setDescription("Add a hyper link")
  49. .setRequired(false)
  50. )
  51. .addStringOption(option => option
  52. .setName("thumbnail")
  53. .setDescription("add a Thumbnail")
  54. .setRequired(false))
  55. .addStringOption(option => option
  56. .setName("image")
  57. .setDescription("image url")
  58. .setRequired(false)
  59. )
  60. .addChannelOption(option => option
  61. .setName("channel")
  62. .setDescription("The channel you will send this message")
  63. .setRequired(false)
  64. ),
  65.  
  66. async execute (interaction, client) {
  67. const Color = interaction.options.getString("color");
  68. const Title = interaction.options.getString("title");
  69. const Desc = interaction.options.getString("description");
  70. const hyName = interaction.options.getString("hyperlink-name") || "No link given";
  71. const hyLink = interaction.options.getString("hyperlink-link") || " ";
  72. const Channel = interaction.options.getChannel("channel") || interaction.channel;
  73. const IMAGE = interaction.options.getString("image");
  74. const THUMBNAIL = interaction.options.getString("thumbnail");
  75. const CID = Channel.id;
  76.  
  77. if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) return interaction.reply("You cant use this command");
  78.  
  79. const embed = new EmbedBuilder()
  80. .setColor(`${Color}`)
  81. .setTitle(`${Title}`)
  82. .setDescription(`${Desc}`)
  83. .addFields({
  84. name: "Link: ",
  85. value: `[${hyName}](https://${hyLink})`
  86. })
  87. .setImage(`${IMAGE}`)
  88. .setThumbnail(`${THUMBNAIL}`)
  89.  
  90. const channel = client.channels.cache.get(`${CID}`);
  91.  
  92. channel.send({
  93. embeds: [embed]
  94. }).catch(err => {
  95. return;
  96. });
  97.  
  98. await interaction.reply(`Embed has been send in <#${CID}> !`)
  99.  
  100.  
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment