npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-ticket-framework

v1.0.0

Published

A framework that allow you to mange ticket system with simplicity and facility

Downloads

28

Readme

What is this ?

Discord ticket is a node module that allow you to create ticket simply and easy

Installation

npm i discord-ticket-framework

Exemple

const Discord = require('discord.js');
const {TicketsManager} = require('discord-ticket-framework');
const client = new Discord.Client();
// this is a sequelize connection you, if you already have one don't do this.

const db = new Sequelize(config.database.name, config.database.user, config.database.password, {
    dialect: "mysql",
    define: {
        charset: 'utf8mb4',
        collate: 'utf8mb4_general_ci',
        timestamps: false,
        freezeTableName: true,
    },
    logging: true
})
client.on('ready', () => {
    console.log("client is ready")
    db.authenticate().then(() => console.log("Db login")).catch(err => console.log(err))
    client.ticket = new TicketsManager(client, db) // parsing the Discord.Client and the database connection

})
client.login('token')

Options

This package require 2 options, both are required for the package to work :

  • Discord.Client
  • Database connection - Sequelize

The dabase connection is required for the package to work only sequelize is supported for now

Setup ticket

Before starting creating ticket the guild must setup the ticket system with the cilent.ticket.setup() method


client.on('message', async (message) => {
    const prefix = config.prefix;
    if (!message.content.startsWith(prefix)) return;
    if (message.author.bot || message.system) return;
    const args = message.content.slice(prefix.length).trim().split(/ +/g);
    args.shift();
    if (message.content.includes(`${prefix}setup`)) {
        client.ticket.setup(message, { // parsing the message where the command is executed
            messageId: args[0], // parsin the messageId of the reactrole if none parse empty string
            modRoles: [args[1]], // give the mod role to be add in ticket important for  moderators to see the ticket
        }).then((res) => {
            message.channel.send('Tickets are now setup');
        })
    }
})

Create a ticket

To create a ticket you simply just do client.ticket.create(welcomeMessage, authorId) welcomeMessage is a string that will be display

You have the method client.ticket.create that allow you to be creative with for exemple creating a reactrole clic to to open a ticket

    client.on('message', async (message) => {
    const prefix = config.prefix;
    if (!message.content.startsWith(prefix)) return;
    if (message.author.bot || message.system) return;
    const args = message.content.slice(prefix.length).trim().split(/ +/g);
    args.shift();
    if (message.content.includes(`${prefix}create`)) {
        // :create
        // This will create a ticket 
        await client.ticket.create(message, {
            welcomeMessage: 'Welcome',
            authorId: message.author.id,
        }).then(ticket => {
            console.log(ticket);
            //this return the ticket information
        })

    }
})

Delete a ticket

To delete a ticket you can react to the reaction on the welcomeMessage or create a command with client.ticket.deleteTicket(channelId) method.

    client.on('message', async (message) => {
    const prefix = config.prefix;
    if (!message.content.startsWith(prefix)) return;
    if (message.author.bot || message.system) return;
    const args = message.content.slice(prefix.length).trim().split(/ +/g);
    args.shift();
    if (message.content.includes(`${prefix}close`)) {
        // :close
        // This will close the ticket 
        await client.ticket.deleteTicket(message.channel.id)
    }
})

Add somebody to a ticket

    client.on('message', async (message) => {
    const prefix = config.prefix;
    if (!message.content.startsWith(prefix)) return;
    if (message.author.bot || message.system) return;
    const args = message.content.slice(prefix.length).trim().split(/ +/g);
    args.shift();
    const memberToAdd = message.mentions.members.first().id || args[0]; // this will get the id of the member to add
    if (message.content.includes(`${prefix}add`)) {
        await client.ticket.add(memberToAdd, message.channel.id);
    }
})

Remove somebody to a ticket

    client.on('message', async (message) => {
    const prefix = config.prefix;
    if (!message.content.startsWith(prefix)) return;
    if (message.author.bot || message.system) return;
    const args = message.content.slice(prefix.length).trim().split(/ +/g);
    args.shift();
    const memberToRemove = message.mentions.members.first().id || args[0]; // this will get the id of the member to remove
    if (message.content.includes(`${prefix}remove`)) {
        await client.ticket.remove(memberToRemove, message.channel.id);
    }
})

Support

If you need help you can contact open a github issue