mirror of
https://github.com/JonnyBro/JaBa.git
synced 2025-04-01 03:32:00 +05:00
rewrite /number to use threads
This commit is contained in:
parent
5308d19d56
commit
dbfc178bac
19 changed files with 242 additions and 189 deletions
|
@ -206,7 +206,7 @@ class JaBaClient extends Client {
|
|||
* @param {Object[]} [data.fields] - An array of field objects for the embed.
|
||||
* @param {string} [data.image] - The URL of the image for the embed.
|
||||
* @param {string} [data.url] - The URL to be used as the embed's hyperlink.
|
||||
* @param {number} [data.color] - The color of the embed's border. If not provided, the default color from the client's configuration will be used.
|
||||
* @param {string} [data.color] - The HEX color of the embed's border. If not provided, the default color from the client's configuration will be used.
|
||||
* @param {string} [data.footer] - The text to be displayed as the embed's footer. If not provided, the default footer from the client's configuration will be used.
|
||||
* @param {Date} [data.timestamp] - The timestamp to be displayed in the embed's footer. If not provided, the current timestamp will be used.
|
||||
* @param {string|Object} [data.author] - The author information for the embed. Can be a string (name) or an object with `name` and/or `iconURL` properties.
|
||||
|
@ -316,7 +316,7 @@ class JaBaClient extends Client {
|
|||
/**
|
||||
* Finds or creates a user in the database based on the provided user ID.
|
||||
* @param {string} userID - The ID of the user to find or create.
|
||||
* @returns {import("./User")} The user data object, either retrieved from the database or newly created.
|
||||
* @returns {Promise<import("./User")>} The user data object, either retrieved from the database or newly created.
|
||||
*/
|
||||
async findOrCreateUser(userID) {
|
||||
let userData = await this.usersData.findOne({ id: userID });
|
||||
|
@ -341,7 +341,7 @@ class JaBaClient extends Client {
|
|||
* @param {Object} options - The options for finding or creating the member.
|
||||
* @param {string} options.id - The ID of the member to find or create.
|
||||
* @param {string} options.guildId - The ID of the guild the member belongs to.
|
||||
* @returns {import("./Member")} The member data object, either retrieved from the database or newly created.
|
||||
* @returns {Promise<import("./Member")>} The member data object, either retrieved from the database or newly created.
|
||||
*/
|
||||
async findOrCreateMember({ id: memberID, guildId }) {
|
||||
let memberData = await this.membersData.findOne({ guildID: guildId, id: memberID });
|
||||
|
@ -372,7 +372,7 @@ class JaBaClient extends Client {
|
|||
/**
|
||||
* Finds or creates a guild in the database based on the provided guild ID.
|
||||
* @param {string} guildId - The ID of the guild to find or create.
|
||||
* @returns {import("./Guild")} The guild data object, either retrieved from the database or newly created.
|
||||
* @returns {Promise<import("./Guild")>} The guild data object, either retrieved from the database or newly created.
|
||||
*/
|
||||
async findOrCreateGuild(guildId) {
|
||||
let guildData = await this.guildsData.findOne({ id: guildId }).populate("members");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { SlashCommandBuilder, MessageCollector } = require("discord.js");
|
||||
const { SlashCommandBuilder, MessageCollector, ButtonBuilder, ActionRowBuilder, ButtonStyle, ThreadAutoArchiveDuration } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand"),
|
||||
currentGames = {};
|
||||
|
||||
|
@ -31,43 +31,51 @@ class Number extends BaseCommand {
|
|||
if (currentGames[interaction.guildId]) return interaction.error("fun/number:GAME_RUNNING");
|
||||
|
||||
const participants = [],
|
||||
number = client.functions.randomNum(1000, 5000);
|
||||
number = client.functions.randomNum(100, 101);
|
||||
|
||||
await interaction.replyT("fun/number:GAME_START");
|
||||
|
||||
const gameCreatedAt = Date.now();
|
||||
let channel;
|
||||
|
||||
if (interaction.channel.isThread()) channel = interaction.channel;
|
||||
else
|
||||
channel = await interaction.channel.threads.create({
|
||||
name: `number-guessing-${client.functions.randomNum(10000, 20000)}`,
|
||||
autoArchiveDuration: ThreadAutoArchiveDuration.OneHour,
|
||||
});
|
||||
|
||||
const gameCreatedAt = Date.now();
|
||||
const filter = m => !m.author.bot;
|
||||
const collector = new MessageCollector(interaction.channel, {
|
||||
const collector = new MessageCollector(channel, {
|
||||
filter,
|
||||
time: 5 * 60 * 1000,
|
||||
});
|
||||
currentGames[interaction.guildId] = true;
|
||||
|
||||
collector.on("collect", async msg => {
|
||||
if (!participants.includes(msg.author.id)) participants.push(msg.author.id);
|
||||
if (!participants.includes(msg.author)) participants.push(msg.author);
|
||||
if (msg.content === "STOP") return collector.stop("force");
|
||||
if (isNaN(msg.content)) return;
|
||||
|
||||
const parsedNumber = parseInt(msg.content, 10);
|
||||
|
||||
if (parsedNumber === number) {
|
||||
interaction.channel.send({
|
||||
channel.send({
|
||||
content: interaction.translate("fun/number:GAME_STATS", {
|
||||
winner: msg.author.toString(),
|
||||
number,
|
||||
time: `<t:${Math.floor(gameCreatedAt / 1000)}:R>`,
|
||||
participantCount: participants.length,
|
||||
participants: participants.map(p => `<@${p}>`).join(", "),
|
||||
participants: participants.map(p => p.toString()).join(", "),
|
||||
}),
|
||||
});
|
||||
|
||||
if (participants.length > 1) {
|
||||
const won = 100 * (participants.length * 0.5);
|
||||
|
||||
interaction.channel.send({
|
||||
channel.send({
|
||||
content: interaction.translate("fun/number:WON", {
|
||||
winner: msg.author.username,
|
||||
winner: msg.author.toString(),
|
||||
credits: `**${won}** ${client.functions.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
}),
|
||||
});
|
||||
|
@ -91,6 +99,33 @@ class Number extends BaseCommand {
|
|||
await memberData.save();
|
||||
}
|
||||
|
||||
interaction.editReply({
|
||||
content: interaction.translate("fun/number:GAME_STATS", {
|
||||
winner: msg.author.toString(),
|
||||
number,
|
||||
time: `<t:${Math.floor(gameCreatedAt / 1000)}:R>`,
|
||||
participantCount: participants.length,
|
||||
participants: participants.map(p => p.toString()).join(", "),
|
||||
}),
|
||||
});
|
||||
|
||||
channel.setArchived(true);
|
||||
|
||||
const deleteYes = new ButtonBuilder()
|
||||
.setCustomId("number_delete_yes")
|
||||
.setLabel(interaction.translate("common:YES"))
|
||||
.setStyle(ButtonStyle.Danger);
|
||||
const deleteNo = new ButtonBuilder()
|
||||
.setCustomId("number_delete_no")
|
||||
.setLabel(interaction.translate("common:NO"))
|
||||
.setStyle(ButtonStyle.Secondary);
|
||||
const row = new ActionRowBuilder().addComponents(deleteYes, deleteNo);
|
||||
|
||||
channel.send({
|
||||
content: interaction.translate("fun/number:DELETE_CHANNEL"),
|
||||
components: [row],
|
||||
});
|
||||
|
||||
collector.stop();
|
||||
}
|
||||
|
||||
|
@ -110,6 +145,23 @@ class Number extends BaseCommand {
|
|||
else if (reason === "force") return interaction.editReply({ content: interaction.translate("misc:FORCE_STOP", { user: interaction.member.toString(), number }) });
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
async onLoad(client) {
|
||||
client.on("interactionCreate", async interaction => {
|
||||
if (!interaction.isButton()) return;
|
||||
|
||||
await interaction.deferUpdate();
|
||||
|
||||
if (interaction.customId === "number_delete_yes")
|
||||
interaction.channel.delete();
|
||||
else if (interaction.customId === "number_delete_no")
|
||||
interaction.message.delete();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Number;
|
||||
|
|
|
@ -30,176 +30,174 @@ class CreateTicketEmbed extends BaseCommand {
|
|||
client.on("interactionCreate", async interaction => {
|
||||
if (!interaction.isButton()) return;
|
||||
|
||||
if (interaction.isButton()) {
|
||||
interaction.data = [];
|
||||
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||
interaction.data = [];
|
||||
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||
|
||||
const guildData = interaction.data.guild,
|
||||
ticketsCategory = guildData.plugins?.tickets?.ticketsCategory,
|
||||
ticketLogs = guildData.plugins?.tickets?.ticketLogs,
|
||||
transcriptionLogs = guildData.plugins?.tickets?.transcriptionLogs;
|
||||
const guildData = interaction.data.guild,
|
||||
ticketsCategory = guildData.plugins?.tickets?.ticketsCategory,
|
||||
ticketLogs = guildData.plugins?.tickets?.ticketLogs,
|
||||
transcriptionLogs = guildData.plugins?.tickets?.transcriptionLogs;
|
||||
|
||||
const button = interaction.component;
|
||||
const button = interaction.component;
|
||||
|
||||
if (button.customId === "support_ticket") {
|
||||
if (interaction.guild.channels.cache.get(ticketsCategory).children.cache.size >= 50) {
|
||||
const sorted = interaction.guild.channels.cache.get(ticketsCategory).children.cache.sort((ch1, ch2) => ch1.createdTimestamp - ch2.createdTimestamp);
|
||||
if (button.customId === "support_ticket") {
|
||||
if (interaction.guild.channels.cache.get(ticketsCategory).children.cache.size >= 50) {
|
||||
const sorted = interaction.guild.channels.cache.get(ticketsCategory).children.cache.sort((ch1, ch2) => ch1.createdTimestamp - ch2.createdTimestamp);
|
||||
|
||||
await sorted.first().delete();
|
||||
}
|
||||
|
||||
if (guildData.plugins.tickets.count === undefined) guildData.plugins.tickets.count = 0;
|
||||
|
||||
guildData.plugins.tickets.count++;
|
||||
|
||||
guildData.markModified("plugins.tickets");
|
||||
await guildData.save();
|
||||
|
||||
const channel = await interaction.guild.channels.create({
|
||||
name: `${interaction.user.username}-support-${guildData.plugins.tickets.count}`,
|
||||
topic: interaction.user.id,
|
||||
type: ChannelType.GuildText,
|
||||
parent: ticketsCategory,
|
||||
permissionOverwrites: [
|
||||
{
|
||||
id: interaction.user.id,
|
||||
allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages],
|
||||
},
|
||||
{
|
||||
id: interaction.guild.roles.everyone,
|
||||
deny: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const logChannel = interaction.guild.channels.cache.get(ticketLogs);
|
||||
const logEmbed = client.embed({
|
||||
title: interaction.translate("tickets/createticketembed:TICKET_CREATED_TITLE"),
|
||||
description: `${interaction.user.toString()} (${channel.toString()})`,
|
||||
});
|
||||
|
||||
await logChannel.send({ embeds: [logEmbed] });
|
||||
await interaction.success("tickets/createticketembed:TICKET_CREATED", {
|
||||
channel: channel.toString(),
|
||||
}, { ephemeral: true });
|
||||
|
||||
await channel.send(`<@${interaction.user.id}>`);
|
||||
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.user.getUsername(),
|
||||
iconURL: interaction.user.displayAvatarURL(),
|
||||
},
|
||||
title: "Support Ticket",
|
||||
description: interaction.translate("tickets/createticketembed:TICKET_CREATED_DESC"),
|
||||
});
|
||||
|
||||
const closeButton = new ButtonBuilder()
|
||||
.setCustomId("close_ticket")
|
||||
.setLabel(interaction.translate("tickets/closeticket:CLOSE_TICKET"))
|
||||
.setStyle(ButtonStyle.Danger);
|
||||
const transcriptButton = new ButtonBuilder()
|
||||
.setCustomId("transcript_ticket")
|
||||
.setLabel(interaction.translate("tickets/closeticket:TRANSCRIPT_TICKET"))
|
||||
.setStyle(ButtonStyle.Secondary);
|
||||
const row = new ActionRowBuilder().addComponents(closeButton, transcriptButton);
|
||||
|
||||
await channel.send({ embeds: [embed], components: [row] });
|
||||
} else if (button.customId === "close_ticket") {
|
||||
const embed = client.embed({
|
||||
title: interaction.translate("tickets/closeticket:CLOSING_TITLE"),
|
||||
description: interaction.translate("tickets/closeticket:CLOSING_DESC"),
|
||||
fields: [
|
||||
{
|
||||
name: interaction.translate("common:TICKET"),
|
||||
value: interaction.channel.name,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("tickets/closeticket:CLOSING_BY"),
|
||||
value: interaction.user.getUsername(),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const button = new ButtonBuilder().setCustomId("cancel_closing").setLabel(interaction.translate("common:CANCEL")).setStyle(ButtonStyle.Danger);
|
||||
const row = new ActionRowBuilder().addComponents(button);
|
||||
|
||||
await interaction.reply({
|
||||
embeds: [embed],
|
||||
components: [row],
|
||||
});
|
||||
|
||||
const filter = i => i.customId === "cancel_closing";
|
||||
const collector = interaction.channel.createMessageComponentCollector({ filter, time: 5000 });
|
||||
|
||||
collector.on("collect", async i => {
|
||||
await i.update({ content: interaction.translate("tickets/closeticket:CLOSING_CANCELED"), components: [] });
|
||||
collector.stop("canceled");
|
||||
});
|
||||
|
||||
collector.on("end", async (_, reason) => {
|
||||
if (reason !== "canceled") {
|
||||
const reversedMessages = (await interaction.channel.messages.fetch()).filter(m => !m.author.bot);
|
||||
const messages = Array.from(reversedMessages.values()).reverse();
|
||||
|
||||
if (messages.length > 1) {
|
||||
let transcript = "---- TICKET CREATED ----\n";
|
||||
messages.forEach(message => {
|
||||
transcript += `[${client.functions.printDate(client, message.createdTimestamp, null, interaction.getLocale())}] ${message.author.getUsername()}: ${message.content}\n`;
|
||||
});
|
||||
transcript += "---- TICKET CLOSED ----\n";
|
||||
|
||||
if (transcriptionLogs !== null) interaction.guild.channels.cache.get(transcriptionLogs).send({ content: interaction.translate("tickets/closeticket:TRANSCRIPT", { channel: `<#${interaction.channelId}>` }), files: [{ attachment: Buffer.from(transcript), name: `${interaction.channel.name}.txt` }] });
|
||||
|
||||
try {
|
||||
await interaction.user.send({
|
||||
content: interaction.translate("tickets/closeticket:TRANSCRIPT", { channel: interaction.channel.name }),
|
||||
files: [{ attachment: Buffer.from(transcript), name: `${interaction.channel.name}.txt` }],
|
||||
});
|
||||
} catch (e) {
|
||||
interaction.followUp({ content: interaction.translate("misc:CANT_DM"), ephemeral: true });
|
||||
}
|
||||
}
|
||||
|
||||
const logChannel = interaction.guild.channels.cache.get(ticketLogs);
|
||||
const logEmbed = client.embed({
|
||||
title: interaction.translate("tickets/createticketembed:TICKET_CLOSED_TITLE"),
|
||||
description: `${interaction.user.toString()} (${interaction.channel.toString()})`,
|
||||
});
|
||||
|
||||
logChannel.send({ embeds: [logEmbed] });
|
||||
|
||||
interaction.channel.send("Closed!");
|
||||
|
||||
const member = interaction.guild.members.cache.find(u => u.user.id === interaction.channel.topic);
|
||||
|
||||
await interaction.channel.permissionOverwrites.edit(member, { ViewChannel: false, SendMessages: null });
|
||||
await interaction.channel.setName(`${interaction.channel.name}-closed`);
|
||||
}
|
||||
});
|
||||
} else if (button.customId === "transcript_ticket") {
|
||||
await interaction.deferUpdate();
|
||||
|
||||
const reversedMessages = (await interaction.channel.messages.fetch()).filter(m => !m.author.bot);
|
||||
const messages = Array.from(reversedMessages.values()).reverse();
|
||||
|
||||
if (messages.length > 1) {
|
||||
let transcript = "---- TICKET CREATED ----\n";
|
||||
messages.forEach(message => {
|
||||
transcript += `[${client.functions.printDate(client, message.createdTimestamp, null, interaction.getLocale())}] ${message.author.getUsername()}: ${message.content}\n`;
|
||||
});
|
||||
transcript += "---- TICKET CLOSED ----\n";
|
||||
|
||||
try {
|
||||
await interaction.user.send({
|
||||
content: interaction.translate("tickets/closeticket:TRANSCRIPT", { channel: `<#${interaction.channelId}>` }),
|
||||
files: [{ attachment: Buffer.from(transcript), name: `${interaction.channel.name}.txt` }],
|
||||
});
|
||||
} catch (error) {
|
||||
interaction.followUp({ content: interaction.translate("misc:CANT_DM"), ephemeral: true });
|
||||
}
|
||||
} else return;
|
||||
await sorted.first().delete();
|
||||
}
|
||||
|
||||
if (guildData.plugins.tickets.count === undefined) guildData.plugins.tickets.count = 0;
|
||||
|
||||
guildData.plugins.tickets.count++;
|
||||
|
||||
guildData.markModified("plugins.tickets");
|
||||
await guildData.save();
|
||||
|
||||
const channel = await interaction.guild.channels.create({
|
||||
name: `${interaction.user.username}-support-${guildData.plugins.tickets.count}`,
|
||||
topic: interaction.user.id,
|
||||
type: ChannelType.GuildText,
|
||||
parent: ticketsCategory,
|
||||
permissionOverwrites: [
|
||||
{
|
||||
id: interaction.user.id,
|
||||
allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages],
|
||||
},
|
||||
{
|
||||
id: interaction.guild.roles.everyone,
|
||||
deny: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const logChannel = interaction.guild.channels.cache.get(ticketLogs);
|
||||
const logEmbed = client.embed({
|
||||
title: interaction.translate("tickets/createticketembed:TICKET_CREATED_TITLE"),
|
||||
description: `${interaction.user.toString()} (${channel.toString()})`,
|
||||
});
|
||||
|
||||
await logChannel.send({ embeds: [logEmbed] });
|
||||
await interaction.success("tickets/createticketembed:TICKET_CREATED", {
|
||||
channel: channel.toString(),
|
||||
}, { ephemeral: true });
|
||||
|
||||
await channel.send(`<@${interaction.user.id}>`);
|
||||
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.user.getUsername(),
|
||||
iconURL: interaction.user.displayAvatarURL(),
|
||||
},
|
||||
title: "Support Ticket",
|
||||
description: interaction.translate("tickets/createticketembed:TICKET_CREATED_DESC"),
|
||||
});
|
||||
|
||||
const closeButton = new ButtonBuilder()
|
||||
.setCustomId("close_ticket")
|
||||
.setLabel(interaction.translate("tickets/closeticket:CLOSE_TICKET"))
|
||||
.setStyle(ButtonStyle.Danger);
|
||||
const transcriptButton = new ButtonBuilder()
|
||||
.setCustomId("transcript_ticket")
|
||||
.setLabel(interaction.translate("tickets/closeticket:TRANSCRIPT_TICKET"))
|
||||
.setStyle(ButtonStyle.Secondary);
|
||||
const row = new ActionRowBuilder().addComponents(closeButton, transcriptButton);
|
||||
|
||||
await channel.send({ embeds: [embed], components: [row] });
|
||||
} else if (button.customId === "close_ticket") {
|
||||
const embed = client.embed({
|
||||
title: interaction.translate("tickets/closeticket:CLOSING_TITLE"),
|
||||
description: interaction.translate("tickets/closeticket:CLOSING_DESC"),
|
||||
fields: [
|
||||
{
|
||||
name: interaction.translate("common:TICKET"),
|
||||
value: interaction.channel.name,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("tickets/closeticket:CLOSING_BY"),
|
||||
value: interaction.user.getUsername(),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const button = new ButtonBuilder().setCustomId("cancel_closing").setLabel(interaction.translate("common:CANCEL")).setStyle(ButtonStyle.Danger);
|
||||
const row = new ActionRowBuilder().addComponents(button);
|
||||
|
||||
await interaction.reply({
|
||||
embeds: [embed],
|
||||
components: [row],
|
||||
});
|
||||
|
||||
const filter = i => i.customId === "cancel_closing";
|
||||
const collector = interaction.channel.createMessageComponentCollector({ filter, time: 5000 });
|
||||
|
||||
collector.on("collect", async i => {
|
||||
await i.update({ content: interaction.translate("tickets/closeticket:CLOSING_CANCELED"), components: [] });
|
||||
collector.stop("canceled");
|
||||
});
|
||||
|
||||
collector.on("end", async (_, reason) => {
|
||||
if (reason !== "canceled") {
|
||||
const reversedMessages = (await interaction.channel.messages.fetch()).filter(m => !m.author.bot);
|
||||
const messages = Array.from(reversedMessages.values()).reverse();
|
||||
|
||||
if (messages.length > 1) {
|
||||
let transcript = "---- TICKET CREATED ----\n";
|
||||
messages.forEach(message => {
|
||||
transcript += `[${client.functions.printDate(client, message.createdTimestamp, null, interaction.getLocale())}] ${message.author.getUsername()}: ${message.content}\n`;
|
||||
});
|
||||
transcript += "---- TICKET CLOSED ----\n";
|
||||
|
||||
if (transcriptionLogs !== null) interaction.guild.channels.cache.get(transcriptionLogs).send({ content: interaction.translate("tickets/closeticket:TRANSCRIPT", { channel: `<#${interaction.channelId}>` }), files: [{ attachment: Buffer.from(transcript), name: `${interaction.channel.name}.txt` }] });
|
||||
|
||||
try {
|
||||
await interaction.user.send({
|
||||
content: interaction.translate("tickets/closeticket:TRANSCRIPT", { channel: interaction.channel.name }),
|
||||
files: [{ attachment: Buffer.from(transcript), name: `${interaction.channel.name}.txt` }],
|
||||
});
|
||||
} catch (e) {
|
||||
interaction.followUp({ content: interaction.translate("misc:CANT_DM"), ephemeral: true });
|
||||
}
|
||||
}
|
||||
|
||||
const logChannel = interaction.guild.channels.cache.get(ticketLogs);
|
||||
const logEmbed = client.embed({
|
||||
title: interaction.translate("tickets/createticketembed:TICKET_CLOSED_TITLE"),
|
||||
description: `${interaction.user.toString()} (${interaction.channel.toString()})`,
|
||||
});
|
||||
|
||||
logChannel.send({ embeds: [logEmbed] });
|
||||
|
||||
interaction.channel.send("Closed!");
|
||||
|
||||
const member = interaction.guild.members.cache.find(u => u.user.id === interaction.channel.topic);
|
||||
|
||||
await interaction.channel.permissionOverwrites.edit(member, { ViewChannel: false, SendMessages: null });
|
||||
await interaction.channel.setName(`${interaction.channel.name}-closed`);
|
||||
}
|
||||
});
|
||||
} else if (button.customId === "transcript_ticket") {
|
||||
await interaction.deferUpdate();
|
||||
|
||||
const reversedMessages = (await interaction.channel.messages.fetch()).filter(m => !m.author.bot);
|
||||
const messages = Array.from(reversedMessages.values()).reverse();
|
||||
|
||||
if (messages.length > 1) {
|
||||
let transcript = "---- TICKET CREATED ----\n";
|
||||
messages.forEach(message => {
|
||||
transcript += `[${client.functions.printDate(client, message.createdTimestamp, null, interaction.getLocale())}] ${message.author.getUsername()}: ${message.content}\n`;
|
||||
});
|
||||
transcript += "---- TICKET CLOSED ----\n";
|
||||
|
||||
try {
|
||||
await interaction.user.send({
|
||||
content: interaction.translate("tickets/closeticket:TRANSCRIPT", { channel: `<#${interaction.channelId}>` }),
|
||||
files: [{ attachment: Buffer.from(transcript), name: `${interaction.channel.name}.txt` }],
|
||||
});
|
||||
} catch (error) {
|
||||
interaction.followUp({ content: interaction.translate("misc:CANT_DM"), ephemeral: true });
|
||||
}
|
||||
} else return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,20 +19,20 @@ BaseInteraction.prototype.replyT = async function (key, args, options = {}) {
|
|||
const translated = this.translate(key, args, this.getLocale());
|
||||
const string = options.prefixEmoji ? `${this.client.customEmojis[options.prefixEmoji]} | ${translated}` : translated;
|
||||
|
||||
if (options.edit) return await this.editReply({ content: string, ephemeral: options.ephemeral || false });
|
||||
else return await this.reply({ content: string, ephemeral: options.ephemeral || false });
|
||||
if (options.edit) return this.editReply({ content: string, ephemeral: options.ephemeral || false });
|
||||
else return this.reply({ content: string, ephemeral: options.ephemeral || false });
|
||||
};
|
||||
|
||||
BaseInteraction.prototype.success = async function (key, args, options = {}) {
|
||||
options.prefixEmoji = "success";
|
||||
|
||||
return await this.replyT(key, args, options);
|
||||
return this.replyT(key, args, options);
|
||||
};
|
||||
|
||||
BaseInteraction.prototype.error = async function (key, args, options = {}) {
|
||||
options.prefixEmoji = "error";
|
||||
|
||||
return await this.replyT(key, args, options);
|
||||
return this.replyT(key, args, options);
|
||||
};
|
||||
|
||||
Message.prototype.getLocale = function () {
|
||||
|
@ -50,18 +50,18 @@ Message.prototype.replyT = async function (key, args, options = {}) {
|
|||
const translated = this.translate(key, args, this.getLocale());
|
||||
const string = options.prefixEmoji ? `${this.client.customEmojis[options.prefixEmoji]} | ${translated}` : translated;
|
||||
|
||||
if (options.edit) return await this.edit({ content: string, allowedMentions: { repliedUser: options.mention ? true : false } });
|
||||
else return await this.reply({ content: string, allowedMentions: { repliedUser: options.mention ? true : false } });
|
||||
if (options.edit) return this.edit({ content: string, allowedMentions: { repliedUser: options.mention ? true : false } });
|
||||
else return this.reply({ content: string, allowedMentions: { repliedUser: options.mention ? true : false } });
|
||||
};
|
||||
|
||||
Message.prototype.success = async function (key, args, options = {}) {
|
||||
options.prefixEmoji = "success";
|
||||
|
||||
return await this.replyT(key, args, options);
|
||||
return this.replyT(key, args, options);
|
||||
};
|
||||
|
||||
Message.prototype.error = async function (key, args, options = {}) {
|
||||
options.prefixEmoji = "error";
|
||||
|
||||
return await this.replyT(key, args, options);
|
||||
return this.replyT(key, args, options);
|
||||
};
|
||||
|
|
|
@ -8,5 +8,6 @@
|
|||
"WON": "{{winner}} has won {{credits}}",
|
||||
"DEFEAT": "No one guessed the number! It was **{{number}}**",
|
||||
"GAME_STATS": "🎉 | {{winner}} has guessed the number! It was **{{number}}**!\n\n**Statistics:**\n*-* __**Duration**__: {{time}}\n*-* __**Participants ({{participantCount}})**__: {{participants}}",
|
||||
"GAME_RUNNING": "The game is already in progress"
|
||||
"GAME_RUNNING": "The game is already in progress",
|
||||
"DELETE_CHANNEL": "Game has ended. Do you want to delete this channel?"
|
||||
}
|
|
@ -8,5 +8,6 @@
|
|||
"WON": "{{winner}} выиграл {{credits}}",
|
||||
"DEFEAT": "Никто не угадал число! Им было **{{number}}**",
|
||||
"GAME_STATS": "🎉 | {{winner}} угадал число! Им было **{{number}}**!\n\n**Статистика:**\n*-* __**Длительность**__: {{time}}\n*-* __**Участники ({{participantCount}})**__: {{participants}}",
|
||||
"GAME_RUNNING": "Игра уже идёт"
|
||||
"GAME_RUNNING": "Игра уже идёт",
|
||||
"DELETE_CHANNEL": "Игра окончена. Вы хотите удалить этот канал?"
|
||||
}
|
|
@ -8,5 +8,6 @@
|
|||
"WON": "{{winner}} виграв {{credits}}",
|
||||
"DEFEAT": "Ніхто не вгадав число! Їм було **{{number}}**",
|
||||
"GAME_STATS": "🎉 | {{winner}} вгадав число! Їм було **{{number}}**!\n\n**Статистика:**\n*-* __**Тривалість**__: {{time}}\n*-* __**Учасники ({{participantCount}})**__: {{participants}}",
|
||||
"GAME_RUNNING": "Гра вже йде"
|
||||
"GAME_RUNNING": "Гра вже йде",
|
||||
"DELETE_CHANNEL": "Гру закінчено. Ви хочете видалити цей канал?"
|
||||
}
|
Loading…
Add table
Reference in a new issue