2.1.1 • Published 3 years ago

djs-ticketsystem v2.1.1

Weekly downloads
32
License
ISC
Repository
github
Last release
3 years ago

DJS-TicketSystem

npm.io npm.io

DJS-TicketSystem is a package designed to make creating "tickets" in discord servers easier

Install

npm install --save djs-ticketsystem

Setup

To setup djs-ticketsystem add this code at the top of your index file

const ticketSystem = require('djs-ticketsystem');

For example:

const ticketSystem = require('djs-ticketsystem');
const { Client } = require('discord.js');

const client = new Client();

client.on('ready', () => console.log('Online!'));

client.on('message', message => {
    if (message.content == '-ticket') {
        message.guild.createTicket({ owner: message.author })
            .catch(console.error);
    };
});

client.login('token');

Create a ticket

<guild>.createTicket({ options }); Where <guild> is the guild class (see below if you are unsure)

Options

name This is the name of the ticket. You can use custom variables here (see below) owner REQUIRED This is the owner of the ticket. It must be a user. category This is the category the the ticket it is. It can be either a id, name, or category object. type This is the type of ticket it is. The default is text. nsfw Boolean to show whether the ticket is nsfw or not. bitrate The bitrate. Voice tickets only. userLimit The user limit. Voice tickets only. permissionOverwrites The permission data for the ticket. position The position of the ticket. rateLimitPerUser The slowmode setting of the ticket. reason The reason for opening the ticket. openMessage.text If you want to send a message in the ticket when it opens. openMessage.embed If you want to send an embed in the ticket when it opens.

The default config is

{
    name: 'ticket-{OWNER.USERNAME}',
    type: 'text',
    nsfw: false,
    permissionOverwrites: [
        {
            id: '{OWNER.ID}',
            allow: ['CREATE_INSTANT_INVITE', 'KICK_MEMBERS', 'BAN_MEMBERS', 'ADMINISTRATOR', 'MANAGE_CHANNELS', 'MANAGE_GUILD', 'ADD_REACTIONS', 'VIEW_AUDIT_LOG', 'PRIORITY_SPEAKER', 'STREAM', 'VIEW_CHANNEL', 'SEND_MESSAGES', 'SEND_TTS_MESSAGES', 'MANAGE_MESSAGES', 'EMBED_LINKS', 'ATTACH_FILES', 'READ_MESSAGE_HISTORY', 'MENTION_EVERYONE', 'USE_EXTERNAL_EMOJIS', 'VIEW_GUILD_INSIGHTS', 'CONNECT', 'SPEAK', 'MUTE_MEMBERS', 'DEAFEN_MEMBERS', 'MOVE_MEMBERS', 'USE_VAD', 'CHANGE_NICKNAME', 'MANAGE_NICKNAMES', 'MANAGE_ROLES', 'MANAGE_WEBHOOKS', 'MANAGE_EMOJIS' ]
        },
        {
            id: '{GUILD.ID}',
            deny: ['CREATE_INSTANT_INVITE', 'KICK_MEMBERS', 'BAN_MEMBERS', 'ADMINISTRATOR', 'MANAGE_CHANNELS', 'MANAGE_GUILD', 'ADD_REACTIONS', 'VIEW_AUDIT_LOG', 'PRIORITY_SPEAKER', 'STREAM', 'VIEW_CHANNEL', 'SEND_MESSAGES', 'SEND_TTS_MESSAGES', 'MANAGE_MESSAGES', 'EMBED_LINKS', 'ATTACH_FILES', 'READ_MESSAGE_HISTORY', 'MENTION_EVERYONE', 'USE_EXTERNAL_EMOJIS', 'VIEW_GUILD_INSIGHTS', 'CONNECT', 'SPEAK', 'MUTE_MEMBERS', 'DEAFEN_MEMBERS', 'MOVE_MEMBERS', 'USE_VAD', 'CHANGE_NICKNAME', 'MANAGE_NICKNAMES', 'MANAGE_ROLES', 'MANAGE_WEBHOOKS', 'MANAGE_EMOJIS' ]
            }
    ],
    openMessage: {
        embed: new MessageEmbed().setColor('RANDOM').setDescription('Welcome to your ticket {OWNER}')
    },
}

Custom variables

There are custom variables built in that allow for easily including data in messages. You are able to use them on permissionOverwrites id as seen above, and in the openingMessage embed and/or text. {OWNER} Used if you want to mention the owner {OWNER.USERNAME} Used if you want to display the owner's username {OWNER.TAG} Used if you want to display the owner's tag {OWNER.DISCRIMINATOR} Used if you want to display the owner's discriminator {OWNER.ID} Used if you want to display the owner's id {GUILD} Used if you want to display the guild {GUILD.ID} Used if you want to display the guild's id {GUILD.NAME} Used if you want to display the guild's name

Examples of where to create a ticket

client.on('message', message => {
    if (message.content == '-ticket') {
        message.guild.createTicket({ owner: message.author })
            .catch(console.error);
    };
});

Other Methods

<channel>.isTicket() For Example

client.on('message', message => {
    if (message.content == 'close' && message.channel.isTicket()) {
        console.log('Closed a ticket channel!');
        message.channel.delete();
    }
});

ticketSystem.defaults({ options }) You are able to edit the default options using this method For Example

const ticketSystem = require('djs-ticketsystem');

ticketSystem.defaults({
    name: 'ticket-{OWNER.USERNAME}-{OWNER.DISCRIMINATOR}'
});

Support

You can message me on discord: GHOST#7524 or create a issue on the github

2.1.1

3 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago