Sam-Dunlap / Draft-Boy-Advance

Other
1 stars 1 forks source link

/submit command #2

Open Valdens opened 2 months ago

Valdens commented 2 months ago

Would this .js plug directly in to add a basic command for Draft Boy to post replay links to #match-submission?

const { SlashCommandBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('submit')
        .setDescription('Submits match replays.')
        .addStringOption(option => 
            option.setName('player1')
                .setDescription('Name of player 1')
                .setRequired(true))
        .addStringOption(option => 
            option.setName('player2')
                .setDescription('Name of player 2')
                .setRequired(true))
        .addStringOption(option => 
            option.setName('link1')
                .setDescription('First replay link')
                .setRequired(true))
        .addStringOption(option => 
            option.setName('link2')
                .setDescription('Second replay link')
                .setRequired(true))
        .addStringOption(option => 
            option.setName('link3')
                .setDescription('Third replay link')
                .setRequired(true)),
    async execute(interaction) {
        const player1 = interaction.options.getString('player1');
        const player2 = interaction.options.getString('player2');
        const link1 = interaction.options.getString('link1');
        const link2 = interaction.options.getString('link2');
        const link3 = interaction.options.getString('link3');

        const channel = interaction.guild.channels.cache.find(ch => ch.name === 'match-submission');
        if (!channel) {
            await interaction.reply('The #match-submission channel does not exist.');
            return;
        }

        const embed = {
            color: 0x0099ff,
            title: 'Match Submission',
            description: `**${player1}** vs **${player2}**`,
            fields: [
                { name: 'Replay 1', value: link1, inline: true },
                { name: 'Replay 2', value: link2, inline: true },
                { name: 'Replay 3', value: link3, inline: true }
            ],
            timestamp: new Date(),
            footer: {
                text: 'Match submitted'
            }
        };

        await channel.send({ embeds: [embed] });
        await interaction.reply('Match replays submitted successfully!');
    }
};
Sam-Dunlap commented 2 months ago