-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Support DJS13 * fix: correct issue when sending a reply from guild * docs: specify that djs13 requires upgrade of node
- Loading branch information
Showing
21 changed files
with
2,096 additions
and
842 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,81 @@ | ||
const { Client } = require('discord.js'); | ||
const { MailboxManager } = require('../lib'); | ||
const { Client, Intents, Constants } = require('discord.js'); | ||
|
||
const client = new Client(); | ||
const { MailboxManager, MailboxManagerEvents } = require('../lib'); | ||
|
||
const client = new Client({ | ||
intents: [ | ||
Intents.FLAGS.GUILDS, | ||
Intents.FLAGS.GUILD_MESSAGES, | ||
Intents.FLAGS.GUILD_MESSAGE_REACTIONS, | ||
Intents.FLAGS.DIRECT_MESSAGES, | ||
], | ||
partials: [Constants.PartialTypes.CHANNEL, Constants.PartialTypes.MESSAGE], | ||
}); | ||
const manager = new MailboxManager(client, { | ||
forceCloseEmoji: '❌', | ||
replySentEmoji: '📤', | ||
loggingOptions: { | ||
generateFilename: ticket => `log-ticket-${ticket.id}.txt`, | ||
format: msg => `[${new Date(msg.createdTimestamp)}] ${msg.author.username} | ${msg.cleanContent}`, | ||
generateMessage: ticket => `Logs for ticket ${ticket.id} - closed at ${new Date(ticket.closedAt)}`, | ||
sendToRecipient: false, | ||
channel: 'LOG_CHANNEL_ID', | ||
showName: false | ||
}, | ||
mailboxChannel: 'MAIL_CHANNEL_ID', | ||
deleteReplies: true, | ||
cronTime: '* * * * *', // run each minute | ||
closeTicketAfter: 60, // in seconds | ||
maxOngoingTicketsPerUser: 3, | ||
notAllowedToPing: 'You are not allowed to mention @everyone or @here in a mail!', | ||
replyMessage: 'Please use the "reply" feature to send an answer to this message.', | ||
tooMuchTickets: 'You have too much tickets that are not closed! Please wait for your tickets to be closed before submitting new ones.', | ||
ticketClose: nbTickets => `This ticket has been closed due to inactivity or manually by the receiver. You now have ${nbTickets} tickets left opened.`, | ||
replyMessageInFooter: true, | ||
embedOptions: { | ||
send: true, | ||
color: 12272523 | ||
}, | ||
formatTitle: id => `[Ticket] ${id}` | ||
forceCloseEmoji: '❌', | ||
replySentEmoji: '📤', | ||
loggingOptions: { | ||
generateFilename: (ticket) => `log-ticket-${ticket.id}.txt`, | ||
format: (msg) => | ||
`[${new Date(msg.createdTimestamp)}] ${msg.author.username} | ${ | ||
msg.cleanContent | ||
}`, | ||
generateMessage: (ticket) => | ||
`Logs for ticket ${ticket.id} - closed at ${new Date( | ||
ticket.closedAt | ||
)}`, | ||
sendToRecipient: false, | ||
channel: 'TEXT_CHANNEL_ID', | ||
showName: false, | ||
}, | ||
mailboxChannel: 'TEXT_CHANNEL_ID', | ||
deleteReplies: true, | ||
cronTime: '* * * * *', // run each minute | ||
closeTicketAfter: 60, // in seconds | ||
maxOngoingTicketsPerUser: 3, | ||
notAllowedToPing: | ||
'You are not allowed to mention @everyone or @here in a mail!', | ||
replyMessage: | ||
'Please use the "reply" feature to send an answer to this message.', | ||
tooMuchTickets: | ||
'You have too much tickets that are not closed! Please wait for your tickets to be closed before submitting new ones.', | ||
ticketClose: (nbTickets) => | ||
`This ticket has been closed due to inactivity or manually by the receiver. You now have ${nbTickets} tickets left opened.`, | ||
replyMessageInFooter: true, | ||
embedOptions: { | ||
send: true, | ||
color: 12272523, | ||
}, | ||
formatTitle: (id) => `[Ticket] ${id}`, | ||
}); | ||
|
||
client.on('ready', () => console.log('Connected!')); | ||
|
||
client.on('message', message => { | ||
if (message.content === 'show me the tickets collection') { | ||
message.reply(`\`\`\`js\n${JSON.stringify(manager.userTickets, null, 2)}\n\`\`\``); | ||
} | ||
}) | ||
client.on('messageCreate', (message) => { | ||
if (message.content === 'show me the tickets collection') { | ||
message.reply( | ||
`\`\`\`js\n${JSON.stringify(manager.userTickets, null, 2)}\n\`\`\`` | ||
); | ||
} | ||
}); | ||
|
||
manager.on('ticketCreate', ticket => console.log(`${ticket.id} has been created!`)); | ||
manager.on('ticketUpdate', ticket => console.log(`${ticket.id} has been updated with a new message.`)); | ||
manager.on('ticketLog', (ticket) => console.log(`${ticket.id} got logged.`)); | ||
manager.on('ticketClose', ticket => console.log(`${ticket.id} got closed!`)); | ||
manager.on('ticketDelete', ticket => console.log(`${ticket.id} got deleted.`)); | ||
manager.on(MailboxManagerEvents.ticketCreate, (ticket) => | ||
console.log(`${ticket.id} has been created!`) | ||
); | ||
manager.on(MailboxManagerEvents.ticketUpdate, (ticket) => | ||
console.log(`${ticket.id} has been updated with a new message.`) | ||
); | ||
manager.on(MailboxManagerEvents.ticketLog, (ticket) => | ||
console.log(`${ticket.id} got logged.`) | ||
); | ||
manager.on(MailboxManagerEvents.ticketClose, (ticket) => | ||
console.log(`${ticket.id} got closed!`) | ||
); | ||
manager.on(MailboxManagerEvents.ticketForceClose, (ticket, user) => | ||
console.log(`${user.username} forced closed ticket ${ticket.id}.`) | ||
); | ||
manager.on(MailboxManagerEvents.ticketDelete, (ticket) => | ||
console.log(`${ticket.id} got deleted.`) | ||
); | ||
|
||
client.login('TOKEN'); |
Oops, something went wrong.