Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Events, Embed, } = require('discord.js')
- const chalk = require('chalk');
- const wait = require('node:timers/promises').setTimeout;
- module.exports = {
- data: new SlashCommandBuilder()
- .setName('standoff')
- .setDescription(`Have a western standoff with another user.`)
- .addUserOption(option =>
- option.setName('user')
- .setDescription(`Who do you want to have a standoff with?`)
- .setRequired(true)),
- async execute (interaction) {
- const { client } = interaction;
- const target = interaction.options.getUser('user');
- const intUser = interaction.user
- let today = new Date();
- let date = today.getMonth()+1+`/`+today.getDate()+`/`+today.getFullYear();
- let logTime = today.getHours() + `:` + today.getMinutes()
- let dateTime = date+' '+logTime;
- const standoffErrorEmbed = new EmbedBuilder()
- standoffErrorEmbed.setTitle(`STANDOFF`)
- standoffErrorEmbed.setColor(`Red`)
- if (target.bot) {
- standoffErrorEmbed.setDescription(`<@${interaction.user.id}>, you can't have a standoff against a bot.`)
- interaction.reply({ embeds: [standoffErrorEmbed] })
- console.log(chalk.white(`${dateTime} │ `,chalk.green(`${interaction.user.tag} in ${interaction.guild.name} tried using /standoff on a bot.`)));
- return;
- } else if (target.id === interaction.user.id) {
- standoffErrorEmbed.setDescription(`<@${interaction.user.id}>, you can't have a standoff with yourself.`)
- interaction.reply({ embeds: [standoffErrorEmbed] })
- console.log(chalk.white(`${dateTime} │ `,chalk.green(`${interaction.user.tag} in ${interaction.guild.name} tried using /standoff on themself.`)));
- return;
- } else if (!target || target === null) {
- standoffErrorEmbed.setDescription(`<@${interaction.user.id}>, you need to select a valid opponent`)
- interaction.reply({ embeds: [standoffErrorEmbed] })
- console.log(chalk.white(`${dateTime} │ `,chalk.green(`${interaction.user.tag} in ${interaction.guild.name} tried using /standoff on an invalid user.`)));
- return;
- } else {
- const standoffEmbed = new EmbedBuilder()
- standoffEmbed.setTitle(`STANDOFF`)
- standoffEmbed.setColor('Yellow')
- standoffEmbed.setThumbnail('https://cdn.discordapp.com/attachments/762927301108695141/1137185724286902272/R.png')
- 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!`)
- const shootTimeList = [4000, 5000, 6000, 7000, 8000 ]
- const shootTime = shootTimeList[Math.floor(Math.random() * shootTimeList.length)]
- let standoffMessage = `🤠<:revolver_left:1137134967697182741> <:revolver_right:1137134969374900275>🤠`
- const standoffEmbedShot = await interaction.reply({ content: `${standoffMessage}`, embeds: [standoffEmbed], fetchReply: true })
- const collectorFilter = (reaction, user) => {
- return reaction.emoji.id === '<:revolver_left:1137134967697182741>' && user.id === interaction.user.id || user.id === target.id;
- };
- const collector = standoffEmbedShot.createReactionCollector({ filter: collectorFilter, time: shootTime + 2000 });
- collector.on('collect', (reaction, user) => {
- wait(shootTime);
- standoffEmbedShot.react('<:revolver_left:1137134967697182741>')
- if (user.id === interaction.user.id) {
- standoffMessage = `🤠<:revolver_left:1137134967697182741>💥 <:revolver_right:1137134969374900275>💀`
- standoffEmbed.setDescription(`<@${interaction.user.id}> won the standoff!`)
- standoffEmbed.setColor('Green')
- interaction.editReply({ content: `${standoffMessage}`, embeds: [standoffEmbed] })
- 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}.`)));
- return;
- } else if (user.id === target.id) {
- standoffMessage = `💀<:revolver_left:1137134967697182741> 💥<:revolver_right:1137134969374900275>🤠`
- standoffEmbed.setDescription(`<@${target.id}> won the standoff!`)
- standoffEmbed.setColor('Green')
- interaction.editReply({ content: `${standoffMessage}`, embeds: [standoffEmbed] })
- console.log(chalk.white(`${dateTime} │ `,chalk.green(`${interaction.user.tag} in ${interaction.guild.name} used /standoff on ${target.tag}. The winner was ${target.tag}.`)));
- return;
- }
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment