Skip to content

Derpinou/discord-tickets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


discord-tickets


Discord server npm version npm downloads

About

discord-tickets is a powerful Node.js module that allows you to manage tickets very easily. Making your bot's code significantly tidier and easier to comprehend.

  • Object-oriented
  • Performant

Installation

Node.js 16.6.0 or newer is required.

npm install discord-tickets

Example usage

Init Text Ticket Manager:

const {TicketManager} = require('discord-tickets');


client.ticketManager = new TicketManager(client, {
     enabled: true,//If Module is enabled
     parentId: '696891020146638868',//Ticket's category
     staffRole: '613426529623605268',//Role who have access to tickets
     closeParentId: '613425648685547544',//Closed's tickets category
     channelTopic: true,
     storage: './tickets.json',//Storage
     ticketCache: true//Save tickets on cache (TicketManager#tickets.get("channelId"))
});

Init Threads Ticket Manager:

const {ThreadManager} = require('discord-tickets');


client.ticketManager = new ThreadManager(client, {
    enabled: true,
    channelId: "697138785317814292",
    staffRole: "613426529623605268",
    storage: `./tickets.json`,
    ticketCache: true
});

Create Ticket:

await client.ticketManager.createTicket(message.guild, message.member);

Get Ticket:

const ticket = client.ticketManager.tickets.get('channelId');

Close Ticket:

await client.ticketManager.closeTicket(ticket);
//or
await ticket.close();

ReOpen ticket:

await client.ticketManager.reOpenTicket(ticket);
//or
ticket.reopen();

Delete Ticket:

await client.ticketManager.deleteTicket(ticket);
//or
ticket.delete();

Using with Database:

const {TicketManager} = require('discord-tickets');
const db = require('quick.db');

class TicketManagerWithDB extends TicketManager {
    async getOptions(id){
        return  db.get(`options_${id}`)
    }
    async getAllTickets(){
        return  db.get('tickets')
    }
    async saveTicketRaws(){
        db.set('tickets', JSON.stringify(this.ticketRaws))
        return true
    }
}


client.ticketManager = new TicketManagerWithDB(client);

Links

Releases

No releases published

Packages

No packages published