mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-02 08:41:25 +03:00
v2.1.1 - Paths are no longer relative
This commit is contained in:
@@ -8,10 +8,9 @@
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const {
|
||||
MessageEmbed
|
||||
} = require('discord.js');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
const archive = require('../modules/archive');
|
||||
|
||||
module.exports = {
|
||||
@@ -74,8 +73,8 @@ module.exports = {
|
||||
);
|
||||
|
||||
let success;
|
||||
let pre = fs.existsSync(`user/transcripts/text/${channel.id}.txt`) ||
|
||||
fs.existsSync(`user/transcripts/raw/${channel.id}.log`) ?
|
||||
let pre = fs.existsSync(join(__dirname, `../../user/transcripts/text/${channel.id}.txt`)) ||
|
||||
fs.existsSync(join(__dirname, `../../user/transcripts/raw/${channel.id}.log`)) ?
|
||||
`You will be able to view an archived version later with \`${config.prefix}transcript ${ticket.id}\`` :
|
||||
'';
|
||||
|
||||
@@ -136,15 +135,15 @@ module.exports = {
|
||||
.setTitle(`Ticket ${ticket.id}`)
|
||||
.setFooter(guild.name, guild.iconURL());
|
||||
|
||||
if (fs.existsSync(`user/transcripts/text/${ticket.get('channel')}.txt`)) {
|
||||
if (fs.existsSync(join(__dirname, `../../user/transcripts/text/${ticket.get('channel')}.txt`))) {
|
||||
embed.addField('Text transcript', 'See attachment');
|
||||
res.files = [{
|
||||
attachment: `user/transcripts/text/${ticket.get('channel')}.txt`,
|
||||
attachment: join(__dirname, `../../user/transcripts/text/${ticket.get('channel')}.txt`),
|
||||
name: `ticket-${ticket.id}-${ticket.get('channel')}.txt`
|
||||
}];
|
||||
}
|
||||
|
||||
if (fs.existsSync(`user/transcripts/raw/${ticket.get('channel')}.log`) && fs.existsSync(`user/transcripts/raw/entities/${ticket.get('channel')}.json`)) {
|
||||
if (fs.existsSync(join(__dirname, `../../user/transcripts/raw/${ticket.get('channel')}.log`)) && fs.existsSync(join(__dirname, `../../user/transcripts/raw/entities/${ticket.get('channel')}.json`))) {
|
||||
embed.addField('Web archive', await archive.export(Ticket, channel));
|
||||
}
|
||||
|
||||
@@ -154,7 +153,12 @@ module.exports = {
|
||||
|
||||
res.embed = embed;
|
||||
|
||||
dm.send(res).then();
|
||||
|
||||
try {
|
||||
dm.send(res).then();
|
||||
} catch (e) {
|
||||
message.channel.send(':x: Couldn\'t send DM');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@ const {
|
||||
MessageEmbed
|
||||
} = require('discord.js');
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
module.exports = {
|
||||
name: 'delete',
|
||||
@@ -117,9 +118,9 @@ module.exports = {
|
||||
.setFooter(guild.name, guild.iconURL())
|
||||
);
|
||||
|
||||
let txt = `user/transcripts/text/${ticket.get('channel')}.txt`,
|
||||
raw = `user/transcripts/raw/${ticket.get('channel')}.log`,
|
||||
json = `user/transcripts/raw/entities/${ticket.get('channel')}.json`;
|
||||
let txt = join(__dirname, `../../user/transcripts/text/${ticket.get('channel')}.txt`),
|
||||
raw = join(__dirname, `../../user/transcripts/raw/${ticket.get('channel')}.log`),
|
||||
json = join(__dirname, `../../user/transcripts/raw/entities/${ticket.get('channel')}.json`);
|
||||
|
||||
if (fs.existsSync(txt)) fs.unlinkSync(txt);
|
||||
if (fs.existsSync(raw)) fs.unlinkSync(raw);
|
||||
|
@@ -10,6 +10,7 @@ const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
module.exports = {
|
||||
name: 'new',
|
||||
@@ -149,11 +150,10 @@ module.exports = {
|
||||
await c.send(ping + `${message.author} has created a new ticket`);
|
||||
|
||||
if (config.tickets.send_img) {
|
||||
const images = fs.readdirSync('user/images');
|
||||
const images = fs.readdirSync(join(__dirname, '../../user/images'));
|
||||
await c.send({
|
||||
files: [
|
||||
'user/images/' +
|
||||
images[Math.floor(Math.random() * images.length)]
|
||||
join(__dirname, '../../user/images', images[Math.floor(Math.random() * images.length)])
|
||||
]
|
||||
});
|
||||
}
|
||||
|
@@ -15,7 +15,6 @@ module.exports = {
|
||||
description: 'Create or a panel widget in the channel the command is used in. Note that there can only be 1 panel.',
|
||||
usage: '',
|
||||
aliases: ['widget'],
|
||||
example: '',
|
||||
args: false,
|
||||
permission: 'MANAGE_GUILD',
|
||||
async execute(client, message, _args, {config, Setting}) {
|
||||
|
@@ -13,7 +13,7 @@ module.exports = {
|
||||
description: 'Rename a ticket channel',
|
||||
usage: '<new name>',
|
||||
aliases: ['none'],
|
||||
example: '',
|
||||
example: 'rename important-ticket',
|
||||
args: true,
|
||||
async execute(client, message, args, {config, Ticket}) {
|
||||
const guild = client.guilds.cache.get(config.guild);
|
||||
@@ -49,7 +49,7 @@ module.exports = {
|
||||
.setFooter(guild.name, guild.iconURL())
|
||||
);
|
||||
|
||||
message.channel.setName(args.join(' ')); // new channel name
|
||||
message.channel.setName(args.join('-')); // new channel name
|
||||
|
||||
message.channel.send(
|
||||
new MessageEmbed()
|
||||
|
@@ -13,7 +13,7 @@ module.exports = {
|
||||
description: 'View ticket stats.',
|
||||
usage: '',
|
||||
aliases: ['data', 'statistics'],
|
||||
example: '',
|
||||
|
||||
args: false,
|
||||
async execute(client, message, _args, {config, Ticket}) {
|
||||
const guild = client.guilds.cache.get(config.guild);
|
||||
|
@@ -8,13 +8,13 @@
|
||||
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
module.exports = {
|
||||
name: 'tickets',
|
||||
description: 'List your recent tickets to access transcripts / archives.',
|
||||
usage: '[@member]',
|
||||
aliases: ['list'],
|
||||
example: '',
|
||||
args: false,
|
||||
async execute(client, message, args, {config, Ticket}) {
|
||||
const guild = client.guilds.cache.get(config.guild);
|
||||
@@ -88,7 +88,7 @@ module.exports = {
|
||||
let desc = closedTickets.rows[t].topic.substring(0, 30);
|
||||
let transcript = '';
|
||||
let c = closedTickets.rows[t].channel;
|
||||
if (fs.existsSync(`user/transcripts/text/${c}.txt`) || config.transcripts.web.enabled) {
|
||||
if (config.transcripts.web.enabled || fs.existsSync(join(__dirname, `../../user/transcripts/text/${c}.txt`))) {
|
||||
transcript = `\n> Type \`${config.prefix}transcript ${closedTickets.rows[t].id}\` to view.`;
|
||||
}
|
||||
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
const {
|
||||
MessageEmbed
|
||||
} = require('discord.js');
|
||||
@@ -59,11 +61,12 @@ module.exports = {
|
||||
.setTitle(`Ticket ${id}`)
|
||||
.setFooter(guild.name, guild.iconURL());
|
||||
|
||||
if (fs.existsSync(`user/transcripts/text/${ticket.channel}.txt`)) {
|
||||
let file = `../../user/transcripts/text/${ticket.channel}.txt`;
|
||||
if (fs.existsSync(join(__dirname, file))) {
|
||||
embed.addField('Text transcript', 'See attachment');
|
||||
res.files = [
|
||||
{
|
||||
attachment: `user/transcripts/text/${ticket.channel}.txt`,
|
||||
attachment: join(__dirname, file),
|
||||
name: `ticket-${id}-${ticket.channel}.txt`
|
||||
}
|
||||
];
|
||||
|
Reference in New Issue
Block a user