Guest User

Untitled

a guest
Aug 4th, 2023
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 5.18 KB | Source Code | 0 0
  1. const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Events, Embed, } = require('discord.js')
  2. const chalk = require('chalk');
  3. const wait = require('node:timers/promises').setTimeout;
  4.  
  5. module.exports = {
  6.     data: new SlashCommandBuilder()
  7.         .setName('standoff')
  8.         .setDescription(`Have a western standoff with another user.`)
  9.         .addUserOption(option =>
  10.             option.setName('user')
  11.                 .setDescription(`Who do you want to have a standoff with?`)
  12.                 .setRequired(true)),
  13.  
  14.     async execute (interaction) {
  15.  
  16.             const { client } = interaction;
  17.  
  18.             const target = interaction.options.getUser('user');
  19.             const intUser = interaction.user
  20.  
  21.             let today = new Date();
  22.             let date = today.getMonth()+1+`/`+today.getDate()+`/`+today.getFullYear();
  23.             let logTime = today.getHours() + `:` + today.getMinutes()
  24.             let dateTime = date+' '+logTime;
  25.  
  26.  
  27.         const standoffErrorEmbed = new EmbedBuilder()
  28.             standoffErrorEmbed.setTitle(`STANDOFF`)
  29.             standoffErrorEmbed.setColor(`Red`)
  30.  
  31.         if (target.bot) {
  32.             standoffErrorEmbed.setDescription(`<@${interaction.user.id}>, you can't have a standoff against a bot.`)
  33.            interaction.reply({ embeds: [standoffErrorEmbed] })
  34.            console.log(chalk.white(`${dateTime} │ `,chalk.green(`${interaction.user.tag} in ${interaction.guild.name} tried using /standoff on a bot.`)));
  35.            return;
  36.        } else if (target.id === interaction.user.id) {
  37.            standoffErrorEmbed.setDescription(`<@${interaction.user.id}>, you can't have a standoff with yourself.`)
  38.             interaction.reply({ embeds: [standoffErrorEmbed] })
  39.             console.log(chalk.white(`${dateTime} │ `,chalk.green(`${interaction.user.tag} in ${interaction.guild.name} tried using /standoff on themself.`)));
  40.             return;
  41.         } else if (!target || target === null) {
  42.             standoffErrorEmbed.setDescription(`<@${interaction.user.id}>, you need to select a valid opponent`)
  43.             interaction.reply({ embeds: [standoffErrorEmbed] })
  44.             console.log(chalk.white(`${dateTime} │ `,chalk.green(`${interaction.user.tag} in ${interaction.guild.name} tried using /standoff on an invalid user.`)));
  45.             return;
  46.         } else {
  47.  
  48.             const standoffEmbed = new EmbedBuilder()
  49.                 standoffEmbed.setTitle(`STANDOFF`)
  50.                 standoffEmbed.setColor('Yellow')
  51.                 standoffEmbed.setThumbnail('https://cdn.discordapp.com/attachments/762927301108695141/1137185724286902272/R.png')
  52.                 standoffEmbed.setDescription(`<@${interaction.user.id}> challenged <@${target.id}> to a standoff! \nThe first person to click the <:revolver_left:1137134967697182741> when it appears will win!`)
  53.  
  54.             const shootTimeList = [4000, 5000, 6000, 7000, 8000 ]
  55.  
  56.             const shootTime = shootTimeList[Math.floor(Math.random() * shootTimeList.length)]
  57.  
  58.             let standoffMessage = `🤠<:revolver_left:1137134967697182741>       <:revolver_right:1137134969374900275>🤠`
  59.  
  60.             const standoffEmbedShot = await interaction.reply({ content: `${standoffMessage}`, embeds: [standoffEmbed], fetchReply: true })
  61.  
  62.             const collectorFilter = (reaction, user) => {
  63.                 return reaction.emoji.id === '<:revolver_left:1137134967697182741>' && user.id === interaction.user.id || user.id === target.id;
  64.             };
  65.  
  66.             const collector = standoffEmbedShot.createReactionCollector({ filter: collectorFilter, time: shootTime + 2000 });
  67.            
  68.             collector.on('collect', (reaction, user) => {
  69.                 wait(shootTime);
  70.                 standoffEmbedShot.react('<:revolver_left:1137134967697182741>')
  71.  
  72.                 if (user.id === interaction.user.id) {
  73.                     standoffMessage = `🤠<:revolver_left:1137134967697182741>💥       <:revolver_right:1137134969374900275>💀`
  74.                     standoffEmbed.setDescription(`<@${interaction.user.id}> won the standoff!`)
  75.                     standoffEmbed.setColor('Green')
  76.                     interaction.editReply({ content: `${standoffMessage}`, embeds: [standoffEmbed] })
  77.                     console.log(chalk.white(`${dateTime} │ `,chalk.green(`${interaction.user.tag} in ${interaction.guild.name} used /standoff on ${target.tag}. The winner was ${interaction.user.tag}.`)));
  78.                     return;
  79.                 } else if (user.id === target.id) {
  80.                     standoffMessage = `💀<:revolver_left:1137134967697182741>       💥<:revolver_right:1137134969374900275>🤠`
  81.                     standoffEmbed.setDescription(`<@${target.id}> won the standoff!`)
  82.                     standoffEmbed.setColor('Green')
  83.                     interaction.editReply({ content: `${standoffMessage}`, embeds: [standoffEmbed] })
  84.                     console.log(chalk.white(`${dateTime} │ `,chalk.green(`${interaction.user.tag} in ${interaction.guild.name} used /standoff on ${target.tag}. The winner was ${target.tag}.`)));
  85.                     return;
  86.                 }
  87.             });
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment