Coder Social home page Coder Social logo

discord-tickets's Introduction


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

discord-tickets's People

Contributors

derpinou avatar donzee529 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.