Untitled

mail@pastecode.io avatar
unknown
javascript
3 years ago
3.5 kB
5
Indexable
Never
client.on('message', (msg) => {
    if(msg.content === 'create'){

    

    let args = msg.content.slice(prefix.length).trim().split(/ +/g);

    let time = 10000;

    let ticketName = db.get(`ticketName_${msg.author.id}_${msg.guild.id}`)
    let ticketID = db.get(`ticketID_${msg.author.id}_${msg.guild.id}`)

    if(msg.channel.id === ticketID){
        msg.delete()
        msg.channel.send(`vous ne pouvez pas creer de ticket ici - ${msg.author}`).then(x => x.delete({ timeout: time}));
    } else {
        if(!msg.guild.channels.cache.find(x => x.name === ticketName)) {
            let buttonYes = new dbs.MessageButton().setStyle('green').setID('yes').setLabel('Yes');
            let buttonNo = new dbs.MessageButton().setStyle('red').setID('no').setLabel('No');
            let row = new dbs.MessageActionRow().addComponents(buttonYes, buttonNo);

            let embed = new Discord.MessageEmbed()
            .setColor('RANDOM')
            .setDescription('createt ticket fils de pute')
            .setTimestamp(Date.now())
            .setFooter('Ticket')
            msg.channel.send(embed, { components: row }).then((msg) => {
                const filter = (button1) => button1.clicker.user.id === msg.author.id;
                let collect = msg.createButtonCollector(filter, { time: 30000 });

                collect.on('collect', async(x) => {
                    x.reply.defer()
                    if (x.id === 'yes') {
                        msg.guild.channels.create(`ticket-${msg.author.tag}`).then((channel) => {
                            db.set(`ticketName_${msg.author.id}_${msg.guild.id}`, channel.name);
                            db.set(`ticketID_${msg.author.id}_${msg.guild.id}`, channel.id);
                            channel.setParent('875553771197980713');

                            channel.updateOverwrite(msg.author.id, {
                                SEND_MESSAGES: true,
                                VIEW_CHANNEL: true
                            })
                            channel.updateOverwrite(msg.guild.id, {
                                SEND_MESSAGES: false,
                                VIEW_CHANNEL: false
                            })

                            let embedyes = new Discord.MessageEmbed()
                            .setColor('GREEN')
                            .setDescription(`ticket created fils de pute - ${channel}`)
                            .setTimestamp(Date.now())
                            .setFooter('fdp')
                            msg.delete()
                            msg.channel.send(embedyes, null);
                        })
                    } else if (x.id === 'no') {
                        let embedNo = new Discord.MessageEmbed()
                        .setColor('RED')
                        .setDescription('Cancel ticket ntm')
                        .setTimestamp(Date.now())
                        msg.edit(embedNo, null).then(x => x.delete({ timeout: time }))
                    }
                })


                setTimeout(() => {
                    let embedTimeout = new Discord.MessageEmbed()
                    .setColor('RED')
                    .setDescription('pas de rep ntm la putes')
                    msg.edit(embedTimeout, null).then(x => x.delete({ timeout: time })); 
                }, 30000)
            })
        } else {
            msg.channel.send('deja fais fils')
        }
    }

}
})