Skip to content

Instantly share code, notes, and snippets.

@EveryDayRains
Created June 29, 2021 14:53
Show Gist options
  • Save EveryDayRains/e7e129f1d249707fbf5d8dd9640fbc57 to your computer and use it in GitHub Desktop.
Save EveryDayRains/e7e129f1d249707fbf5d8dd9640fbc57 to your computer and use it in GitHub Desktop.
Тикеты на тредах
const { Client, MessageActionRow, MessageButton, Intents, MessageEmbed} = require('discord.js');
const client = new Client({intents: Intents.ALL})
client.on('ready', () => {
const buttons = new MessageActionRow()
.addComponents(
new MessageButton({
customID: 'create',
style: "PRIMARY",
type: "BUTTON",
label: 'Создать'
}))
const embeds = [
new MessageEmbed()
.setColor('BLURPLE')
.setTitle('Система тикетов')
.setDescription('Для того чтобы создать тикет, нажмите на кнопку ниже.')
]
const channel = client.channels.cache.get('859164680240234526')
channel.messages.fetch().then(x => {
console.log(x)
console.log(x.filter(r => r.author.id === client.user.id).size)
if(x.filter(r => r.author.id === client.user.id).size <= 0) return channel.send({embeds, components: [buttons]});
else return;
})
})
client.on('interaction', async interaction => {
if (!interaction.isButton()) return;
const embeds = [
new MessageEmbed()
.setColor('BLURPLE')
.setTitle('Система тикетов')
.setDescription(`${interaction.user.toString()} Опишите как можно детальнее вашу проблему и ожидайте ответа от <@&859439062413737996>. \n Если ваш вопрос решён, напишите об этом в обсуждении и нажмите ПКМ по каналу и покинуть.`)
]
interaction.channel.threads.create({
name: `Тикет ${interaction.user.tag}`,
autoArchiveDuration: 1440,
reason: 'Создание тикета'
}).then(x => {
x.send({content: `${interaction.user.toString()} <@&859439062413737996>`, embeds})
interaction.reply({ephemeral: true, content: `Успешно! Ваш тикет <#${x.id}>`})
})
});
client.login('')
@EveryDayRains
Copy link
Author

EveryDayRains commented Jun 29, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment