Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ghostdevv/djs-ticketsystem

DJS-TicketSystem is an extension to discord.js designed to make creating "tickets" in discord servers easier
https://github.com/ghostdevv/djs-ticketsystem

discord-tickets

Last synced: 2 months ago
JSON representation

DJS-TicketSystem is an extension to discord.js designed to make creating "tickets" in discord servers easier

Awesome Lists containing this project

README

        

# DJS-TicketSystem
[![](https://img.shields.io/npm/v/djs-ticketsystem?label=Latest%20Version&style=for-the-badge&logo=npm&color=informational)](https://www.npmjs.com/package/dashargs)
[![](https://img.shields.io/static/v1?label=Author&message=GHOST&color=informational&style=for-the-badge)](https://ghostdev.xyz)

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
```js
const ticketSystem = require('djs-ticketsystem');
```
For example:
```js
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
`.createTicket({ options });`

Where `` 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
```js
{
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
```js
client.on('message', message => {
if (message.content == '-ticket') {
message.guild.createTicket({ owner: message.author })
.catch(console.error);
};
});
```

## Other Methods
`.isTicket()`

For Example
```js
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
```js
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](https://github.com/ghostdevv/djs-ticketsystem)