mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-17 09:23:07 +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 { decrypt } = new Cryptr(process.env.ENCRYPTION_KEY);
|
||||||
const Keyv = require('keyv');
|
const Keyv = require('keyv');
|
||||||
const ms = require('ms');
|
const ms = require('ms');
|
||||||
|
const { isStaff } = require('../lib/users');
|
||||||
|
|
||||||
module.exports = class TicketCompleter extends Autocompleter {
|
module.exports = class TicketCompleter extends Autocompleter {
|
||||||
constructor(client, options) {
|
constructor(client, options) {
|
||||||
@ -72,11 +73,13 @@ module.exports = class TicketCompleter extends Autocompleter {
|
|||||||
* @param {import("discord.js").AutocompleteInteraction} interaction
|
* @param {import("discord.js").AutocompleteInteraction} interaction
|
||||||
*/
|
*/
|
||||||
async run(value, command, 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 interaction.respond(
|
||||||
await this.getOptions(value, {
|
await this.getOptions(value, {
|
||||||
guildId: interaction.guild.id,
|
guildId: interaction.guild.id,
|
||||||
open: ['add', 'close', 'force-close', 'remove'].includes(command.name), // false for `new`, `transcript` etc
|
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,
|
required: true,
|
||||||
type: ApplicationCommandOptionType.String,
|
type: ApplicationCommandOptionType.String,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'member',
|
||||||
|
required: false,
|
||||||
|
type: ApplicationCommandOptionType.User,
|
||||||
|
},
|
||||||
].map(option => {
|
].map(option => {
|
||||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||||
option.description = option.descriptionLocalizations['en-GB'];
|
option.description = option.descriptionLocalizations['en-GB'];
|
||||||
|
@ -222,8 +222,11 @@ commands:
|
|||||||
description: Get the transcript of a ticket
|
description: Get the transcript of a ticket
|
||||||
name: transcript
|
name: transcript
|
||||||
options:
|
options:
|
||||||
|
member:
|
||||||
|
description: The member to search for tickets of
|
||||||
|
name: member
|
||||||
ticket:
|
ticket:
|
||||||
description: The number of the ticket to get the transcript of
|
description: The ticket to get the transcript of
|
||||||
name: ticket
|
name: ticket
|
||||||
transfer:
|
transfer:
|
||||||
description: Transfer ownership of a ticket to another member
|
description: Transfer ownership of a ticket to another member
|
||||||
|
Loading…
Reference in New Issue
Block a user