mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-22 15:53:08 +02:00
fix: allow staff to get transcripts of other members (closes #400)
This commit is contained in:
parent
afa0123d22
commit
a44539914e
@ -5,6 +5,7 @@ const Cryptr = require('cryptr');
|
||||
const { decrypt } = new Cryptr(process.env.ENCRYPTION_KEY);
|
||||
const Keyv = require('keyv');
|
||||
const ms = require('ms');
|
||||
const { isStaff } = require('../lib/users');
|
||||
|
||||
module.exports = class TicketCompleter extends Autocompleter {
|
||||
constructor(client, options) {
|
||||
@ -72,12 +73,14 @@ module.exports = class TicketCompleter extends Autocompleter {
|
||||
* @param {import("discord.js").AutocompleteInteraction} interaction
|
||||
*/
|
||||
async run(value, command, interaction) {
|
||||
const otherMember = await isStaff(interaction.guild, interaction.user.id) && interaction.options.data[1]?.value;
|
||||
const userId = otherMember || interaction.user.id;
|
||||
await interaction.respond(
|
||||
await this.getOptions(value, {
|
||||
guildId: interaction.guild.id,
|
||||
open: ['add', 'close', 'force-close', 'remove'].includes(command.name), // false for `new`, `transcript` etc
|
||||
userId: interaction.user.id,
|
||||
userId,
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -24,6 +24,11 @@ module.exports = class TranscriptSlashCommand extends SlashCommand {
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
{
|
||||
name: 'member',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.User,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
@ -143,4 +148,4 @@ module.exports = class TranscriptSlashCommand extends SlashCommand {
|
||||
await interaction.editReply({ files: [attachment] });
|
||||
// TODO: add portal link
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -222,8 +222,11 @@ commands:
|
||||
description: Get the transcript of a ticket
|
||||
name: transcript
|
||||
options:
|
||||
member:
|
||||
description: The member to search for tickets of
|
||||
name: member
|
||||
ticket:
|
||||
description: The number of the ticket to get the transcript of
|
||||
description: The ticket to get the transcript of
|
||||
name: ticket
|
||||
transfer:
|
||||
description: Transfer ownership of a ticket to another member
|
||||
|
Loading…
Reference in New Issue
Block a user