toowake

Discord Coding Lounge

Mar 30th, 2023
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.58 KB | None | 0 0
  1. const { SlashCommandBuilder, EmbedBuilder, PermissionsBitField} = require("discord.js");
  2.  
  3. module.exports = {
  4. data: new SlashCommandBuilder()
  5. .setName("automod")
  6. .setDescription("Setup the Automod")
  7. .addSubcommand(command => command
  8. .setName("flagged-words")
  9. .setDescription("block profanity, specific content, and slurs")
  10. )
  11. .addSubcommand(command => command
  12. .setName("spam-messages")
  13. .setDescription("anti spam")
  14. )
  15. .addSubcommand(command => command
  16. .setName("mention-spam")
  17. .setDescription("anti spam")
  18. .addIntegerOption(option => option
  19. .setName("number")
  20. .setDescription("The Number of max Mentions")
  21. .setRequired(true))
  22. )
  23. .addSubcommand(command => command
  24. .setName("keyword")
  25. .setDescription("Block a given Keyword in the Server")
  26. .addStringOption(option => option
  27. .setName("word")
  28. .setDescription("The word")
  29. .setRequired(true))
  30. ),
  31.  
  32. async execute (interaction) {
  33. const { guild, options } = interaction;
  34. const sub = options.getSubcommand();
  35.  
  36. const errEmbed = new EmbedBuilder()
  37. .setTitle("ERROR")
  38. .setColor("Red")
  39. .setDescription("Missing Permissions: Administrator")
  40. .setTimestamp()
  41.  
  42. if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) return await interaction.reply({
  43. embeds: [errEmbed],
  44. ephemeral: true
  45. });
  46.  
  47. switch (sub) {
  48. case "flagged-words":
  49.  
  50. await interaction.reply({ content: `Loading your Automod rule....`});
  51.  
  52. const rule = await guild.autoModerationRules.create({
  53. name: `Block profinity, sexual content, and slurs by Aura Bot`,
  54. creatorId: '1046468420037787720',
  55. enabled: true,
  56. eventType: 1,
  57. triggerType: 4,
  58. triggerMetadata:
  59. {
  60. presets: [1, 2, 3]
  61. },
  62. actions: [
  63. {
  64. type: 1,
  65. metadata: {
  66. channel: interaction.channel,
  67. durationSeconds: 10,
  68. customMessage: 'This message was prevented by Aura Bot'
  69. }
  70. }
  71. ]
  72. }).catch(async err => {
  73. setTimeout(async () => {
  74. return;
  75. }, 2000)
  76. })
  77.  
  78. setTimeout(async () => {
  79. if (!rule) return;
  80.  
  81. const embed = new EmbedBuilder()
  82. .setColor("Green")
  83. .setDescription(`Your automod rule has been created`)
  84.  
  85. await interaction.editReply({
  86. content: ``,
  87. embeds: [embed]
  88. })
  89. }, 3000)
  90.  
  91. break;
  92.  
  93. case 'keyword':
  94.  
  95. await interaction.reply({ content: `Loading your Automod rule....`});
  96. const word = options.getString("word");
  97.  
  98. const rule2 = await guild.autoModerationRules.create({
  99. name: `Prevent the word ${word} by Aura Bot`,
  100. creatorId: '1046468420037787720',
  101. enabled: true,
  102. eventType: 1,
  103. triggerType: 1,
  104. triggerMetadata:
  105. {
  106. keywordFilter: [`${word}`]
  107. },
  108. actions: [
  109. {
  110. type: 1,
  111. metadata: {
  112. channel: interaction.channel,
  113. durationSeconds: 10,
  114. customMessage: 'This message was prevented by Aura Bot'
  115. }
  116. }
  117. ]
  118. }).catch(async err => {
  119. setTimeout(async () => {
  120. return;
  121. }, 2000)
  122. })
  123.  
  124. setTimeout(async () => {
  125. if (!rule2) return;
  126.  
  127. const embed2 = new EmbedBuilder()
  128. .setColor("Green")
  129. .setDescription(`Your automod rule has been created. Messages with **${word}** will be deleted`)
  130.  
  131. await interaction.editReply({
  132. content: ``,
  133. embeds: [embed2]
  134. })
  135. }, 3000)
  136.  
  137. break;
  138.  
  139. case 'spam-messages':
  140.  
  141. await interaction.reply({ content: `Loading your Automod rule....`});
  142.  
  143.  
  144. const rule3 = await guild.autoModerationRules.create({
  145. name: `Prevent Spam Messages by Aura Bot`,
  146. creatorId: '1046468420037787720',
  147. enabled: true,
  148. eventType: 1,
  149. triggerType: 5,
  150. triggerMetadata:
  151. {
  152. //mentionTotalLimit: number
  153. },
  154. actions: [
  155. {
  156. type: 1,
  157. metadata: {
  158. channel: interaction.channel,
  159. durationSeconds: 10,
  160. customMessage: 'This message was prevented by Aura Bot'
  161. }
  162. }
  163. ]
  164. }).catch(async err => {
  165. setTimeout(async () => {
  166. return;
  167. }, 2000)
  168. })
  169.  
  170. setTimeout(async () => {
  171. if (!rule3) return;
  172.  
  173. const embed3 = new EmbedBuilder()
  174. .setColor("Green")
  175. .setDescription(`Your automod rule has been created`)
  176.  
  177. await interaction.editReply({
  178. content: ``,
  179. embeds: [embed3]
  180. })
  181. }, 3000)
  182.  
  183. break;
  184.  
  185. case 'mention-spam':
  186. await interaction.reply({ content: `Loading your Automod rule....`});
  187. const number = options.getInteger("number")
  188.  
  189. const rule4 = await guild.autoModerationRules.create({
  190. name: `Prevent Spam Messages by Aura Bot`,
  191. creatorId: '1046468420037787720',
  192. enabled: true,
  193. eventType: 1,
  194. triggerType: 5,
  195. triggerMetadata:
  196. {
  197. mentionTotalLimit: number
  198. },
  199. actions: [
  200. {
  201. type: 1,
  202. metadata: {
  203. channel: interaction.channel,
  204. durationSeconds: 10,
  205. customMessage: 'This message was prevented by Aura Bot'
  206. }
  207. }
  208. ]
  209. }).catch(async err => {
  210. setTimeout(async () => {
  211. return;
  212. }, 2000)
  213. })
  214.  
  215. setTimeout(async () => {
  216. if (!rule4) return;
  217.  
  218. const embed4 = new EmbedBuilder()
  219. .setColor("Green")
  220. .setDescription(`Your automod rule has been created`)
  221.  
  222. await interaction.editReply({
  223. content: ``,
  224. embeds: [embed4]
  225. })
  226. }, 3000)
  227.  
  228. break;
  229.  
  230. }
  231. }
  232. }
Advertisement
Add Comment
Please, Sign In to add comment