mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-05 12:23:09 +02:00
Fix ticket
and references
autocompleters
This commit is contained in:
parent
83ab003db5
commit
33d61869d8
@ -1,4 +1,7 @@
|
||||
const { Autocompleter } = require('@eartharoid/dbf');
|
||||
const emoji = require('node-emoji');
|
||||
const Cryptr = require('cryptr');
|
||||
const cryptr = new Cryptr(process.env.ENCRYPTION_KEY);
|
||||
|
||||
module.exports = class ReferencesCompleter extends Autocompleter {
|
||||
constructor(client, options) {
|
||||
@ -18,6 +21,14 @@ module.exports = class ReferencesCompleter extends Autocompleter {
|
||||
const client = this.client;
|
||||
const settings = await client.prisma.guild.findUnique({ where: { id: interaction.guild.id } });
|
||||
const tickets = await client.prisma.ticket.findMany({
|
||||
include: {
|
||||
category: {
|
||||
select: {
|
||||
emoji: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
where: {
|
||||
createdById: interaction.user.id,
|
||||
guildId: interaction.guild.id,
|
||||
@ -34,8 +45,10 @@ module.exports = class ReferencesCompleter extends Autocompleter {
|
||||
.slice(0, 25)
|
||||
.map(t => {
|
||||
const date = new Date(t.createdAt).toLocaleString(settings.locale, { dateStyle: 'short' });
|
||||
const topic = t.topic ? '| ' + cryptr.decrypt(t.topic).substring(0, 50) : '';
|
||||
const category = emoji.hasEmoji(t.category.emoji) ? emoji.get(t.category.emoji) + ' ' + t.category.name : t.category.name;
|
||||
return {
|
||||
name: `#${t.number} - ${date} ${t.topic ? '| ' + t.topic.substring(0, 50) : ''}`,
|
||||
name: `${category} #${t.number} - ${date} ${topic}`,
|
||||
value: t.id,
|
||||
};
|
||||
}),
|
||||
|
@ -1,5 +1,7 @@
|
||||
const { Autocompleter } = require('@eartharoid/dbf');
|
||||
const emoji = require('node-emoji');
|
||||
const Cryptr = require('cryptr');
|
||||
const cryptr = new Cryptr(process.env.ENCRYPTION_KEY);
|
||||
|
||||
module.exports = class TicketCompleter extends Autocompleter {
|
||||
constructor(client, options) {
|
||||
@ -43,7 +45,7 @@ module.exports = class TicketCompleter extends Autocompleter {
|
||||
.slice(0, 25)
|
||||
.map(t => {
|
||||
const date = new Date(t.createdAt).toLocaleString(settings.locale, { dateStyle: 'short' });
|
||||
const topic = t.topic ? '| ' + t.topic.substring(0, 50) : '';
|
||||
const topic = t.topic ? '| ' + cryptr.decrypt(t.topic).substring(0, 50) : '';
|
||||
const category = emoji.hasEmoji(t.category.emoji) ? emoji.get(t.category.emoji) + ' ' + t.category.name : t.category.name;
|
||||
return {
|
||||
name: `${category} #${t.number} - ${date} ${topic}`,
|
||||
|
Loading…
Reference in New Issue
Block a user