mirror of
https://github.com/nx-bat/discordbot-ng.git
synced 2026-11-11 07:13:37 -05:00
(buttons): Type-checking & linting.
This commit is contained in:
@@ -11,13 +11,13 @@ class ClaimTicketButton implements Button<Client> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const channel = await context.channels.fetch(interaction.channelId);
|
const channel = await context.channels.fetch(interaction.channelId);
|
||||||
|
|
||||||
if (!channel) throw new Error("The interaction channel couldn't be fetched.");
|
if (!channel) throw new Error("The interaction channel couldn't be fetched.");
|
||||||
if (!channel.isThread() || channel.type != ChannelType.PrivateThread) throw new Error('This interaction was not run in a ticket thread.');
|
if (!channel.isThread() || channel.type != ChannelType.PrivateThread) throw new Error('This interaction was not run in a ticket thread.');
|
||||||
if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel.");
|
if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel.");
|
||||||
|
|
||||||
const settings = await Database.getOrCreateSettings(interaction.guildId);
|
const settings = await Database.getOrCreateSettings(interaction.guildId);
|
||||||
if (!settings.private_help_role_id) throw new Error("\`private_help_role_id\` hasn't been configured. Please report this error to staff.");
|
if (!settings.private_help_role_id) throw new Error("`private_help_role_id` hasn't been configured. Please report this error to staff.");
|
||||||
|
|
||||||
const guild = await context.guilds.fetch(interaction.guildId);
|
const guild = await context.guilds.fetch(interaction.guildId);
|
||||||
const member = await guild.members.fetch(interaction.user.id);
|
const member = await guild.members.fetch(interaction.user.id);
|
||||||
|
|||||||
@@ -10,22 +10,22 @@ class CloseModTicketButton implements Button<Client> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const channel = await context.channels.fetch(interaction.channelId);
|
const channel = await context.channels.fetch(interaction.channelId);
|
||||||
|
|
||||||
if (!channel) throw new Error("The interaction channel couldn't be fetched.");
|
if (!channel) throw new Error("The interaction channel couldn't be fetched.");
|
||||||
if (!channel.isThread() || channel.type != ChannelType.PrivateThread) throw new Error('This interaction was not run in a ticket thread.');
|
if (!channel.isThread() || channel.type != ChannelType.PrivateThread) throw new Error('This interaction was not run in a ticket thread.');
|
||||||
if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel.");
|
if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel.");
|
||||||
|
|
||||||
if (!interaction.memberPermissions.has('KickMembers')) throw new Error("You don't have permission to close this ticket.");
|
if (!interaction.memberPermissions.has('KickMembers')) throw new Error("You don't have permission to close this ticket.");
|
||||||
|
|
||||||
await interaction.message.edit({
|
await interaction.message.edit({
|
||||||
content: interaction.message.content,
|
content: interaction.message.content,
|
||||||
components: []
|
components: []
|
||||||
});
|
});
|
||||||
|
|
||||||
await channel.send('This ticket has been closed by staff.');
|
await channel.send('This ticket has been closed by staff.');
|
||||||
|
|
||||||
await interaction.editReply({ content: 'Ticket closed.' });
|
await interaction.editReply({ content: 'Ticket closed.' });
|
||||||
|
|
||||||
await channel.edit({
|
await channel.edit({
|
||||||
archived: true,
|
archived: true,
|
||||||
locked: true
|
locked: true
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class CloseTicketButton implements Button<Client> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const channel = await context.channels.fetch(interaction.channelId);
|
const channel = await context.channels.fetch(interaction.channelId);
|
||||||
|
|
||||||
if (!channel) throw new Error("The interaction channel couldn't be fetched.");
|
if (!channel) throw new Error("The interaction channel couldn't be fetched.");
|
||||||
if (!channel.isThread() || channel.type != ChannelType.PrivateThread) throw new Error('This interaction was not run in a ticket thread.');
|
if (!channel.isThread() || channel.type != ChannelType.PrivateThread) throw new Error('This interaction was not run in a ticket thread.');
|
||||||
if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel.");
|
if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel.");
|
||||||
|
|||||||
+12
-12
@@ -1,15 +1,15 @@
|
|||||||
import claimTicket from "./claimTicket";
|
import claimTicket from './claimTicket';
|
||||||
import closeModTicket from "./closeModTicket";
|
import closeModTicket from './closeModTicket';
|
||||||
import closeTicket from "./closeTicket";
|
import closeTicket from './closeTicket';
|
||||||
import devWatch from "./devWatch";
|
import devWatch from './devWatch';
|
||||||
import noteNext from "./noteNext";
|
import noteNext from './noteNext';
|
||||||
import notePrevious from "./notePrevious";
|
import notePrevious from './notePrevious';
|
||||||
import openTicketForReportedMessage from "./openTicketForReportedMessage";
|
import openTicketForReportedMessage from './openTicketForReportedMessage';
|
||||||
import privateHelp from "./privateHelp";
|
import privateHelp from './privateHelp';
|
||||||
import recordsNext from "./recordsNext";
|
import recordsNext from './recordsNext';
|
||||||
import recordsPrevious from "./recordsPrevious";
|
import recordsPrevious from './recordsPrevious';
|
||||||
import roleButton from "./roleButton";
|
import roleButton from './roleButton';
|
||||||
import unclaimTicket from "./unclaimTicket";
|
import unclaimTicket from './unclaimTicket';
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
claimTicket,
|
claimTicket,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class UnclaimTicketButton implements Button<Client> {
|
|||||||
|
|
||||||
async execute(context: Client<boolean>, interaction: ButtonInteraction): Promise<void> {
|
async execute(context: Client<boolean>, interaction: ButtonInteraction): Promise<void> {
|
||||||
if (!interaction.inGuild()) return;
|
if (!interaction.inGuild()) return;
|
||||||
await interaction.deferReply();
|
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const channel = await context.channels.fetch(interaction.channelId);
|
const channel = await context.channels.fetch(interaction.channelId);
|
||||||
@@ -17,13 +17,13 @@ class UnclaimTicketButton implements Button<Client> {
|
|||||||
if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel.");
|
if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel.");
|
||||||
|
|
||||||
const settings = await Database.getOrCreateSettings(interaction.guildId);
|
const settings = await Database.getOrCreateSettings(interaction.guildId);
|
||||||
if (!settings.private_help_role_id) throw new Error("\`private_help_role_id\` hasn't been configured. Please report this error to staff.");
|
if (!settings.private_help_role_id) throw new Error("`private_help_role_id` hasn't been configured. Please report this error to staff.");
|
||||||
|
|
||||||
const guild = await context.guilds.fetch(interaction.guildId);
|
const guild = await context.guilds.fetch(interaction.guildId);
|
||||||
const member = await guild.members.fetch(interaction.user.id);
|
const member = await guild.members.fetch(interaction.user.id);
|
||||||
if (!member.roles.cache.has(settings.private_help_role_id)) throw new Error("You don't have permission to claim tickets.");
|
if (!member.roles.cache.has(settings.private_help_role_id)) throw new Error("You don't have permission to claim tickets.");
|
||||||
|
|
||||||
if (!interaction.message.content.split('\n').at(-1)!.includes(`<@${interaction.user.id}>`)) throw new Error(`You haven't claimed this ticket.`);
|
if (!interaction.message.content.split('\n').at(-1)!.includes(`<@${interaction.user.id}>`)) throw new Error('You haven\'t claimed this ticket.');
|
||||||
|
|
||||||
const closeButton = new ButtonBuilder()
|
const closeButton = new ButtonBuilder()
|
||||||
.setCustomId('close-ticket')
|
.setCustomId('close-ticket')
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { ButtonInteraction } from "discord.js";
|
import { ButtonInteraction } from 'discord.js';
|
||||||
|
|
||||||
export interface Button<Context> {
|
export interface Button<Context> {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user