Created
June 29, 2021 14:53
-
-
Save EveryDayRains/e7e129f1d249707fbf5d8dd9640fbc57 to your computer and use it in GitHub Desktop.
Тикеты на тредах
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Важно
Данный код работает на dev версии discord.js
npm i discord.js@dev
Документация:
https://discord.js.org/#/docs/main/master
https://discord.js.org/#/docs/main/master/class/ThreadChannel
https://discord.js.org/#/docs/main/master/class/Interaction
https://discord.js.org/#/docs/main/master/class/Client?scrollTo=e-interaction