mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-22 15:53:08 +02:00
update
This commit is contained in:
parent
f9a725d81a
commit
d005cc48d1
22
commands/add.js
Normal file
22
commands/add.js
Normal file
@ -0,0 +1,22 @@
|
||||
const Discord = require('discord.js');
|
||||
const config = require('../config.json');
|
||||
module.exports = {
|
||||
name: 'add',
|
||||
description: 'Add a member to a ticket channel',
|
||||
usage: '<@member>',
|
||||
aliases: ['adduser'],
|
||||
example: 'add @exampleUser',
|
||||
args: false,
|
||||
cooldown: config.cooldown,
|
||||
guildOnly: true,
|
||||
execute(message, args) {
|
||||
const client = message.client;
|
||||
// command starts here
|
||||
message.delete();
|
||||
|
||||
|
||||
|
||||
|
||||
// command ends here
|
||||
},
|
||||
};
|
22
commands/close.js
Normal file
22
commands/close.js
Normal file
@ -0,0 +1,22 @@
|
||||
const Discord = require('discord.js');
|
||||
const config = require('../config.json');
|
||||
module.exports = {
|
||||
name: 'close',
|
||||
description: 'Close a ticket',
|
||||
usage: '',
|
||||
aliases: ['none'],
|
||||
example: '',
|
||||
args: false,
|
||||
cooldown: config.cooldown,
|
||||
guildOnly: true,
|
||||
execute(message, args) {
|
||||
const client = message.client;
|
||||
// command starts here
|
||||
message.delete();
|
||||
|
||||
|
||||
|
||||
|
||||
// command ends here
|
||||
},
|
||||
};
|
@ -4,10 +4,11 @@ module.exports = {
|
||||
name: 'example-command',
|
||||
description: 'An example command',
|
||||
usage: '[args]',
|
||||
aliases: ['command', 'commands'],
|
||||
aliases: ['none'],
|
||||
example: 'example-command',
|
||||
args: false,
|
||||
cooldown: config.cooldown,
|
||||
guildOnly: true,
|
||||
execute(message, args) {
|
||||
const client = message.client;
|
||||
// command starts here
|
||||
|
@ -9,6 +9,7 @@ module.exports = {
|
||||
example: 'help new',
|
||||
args: false,
|
||||
cooldown: config.cooldown,
|
||||
guildOnly: true,
|
||||
execute(message, args) {
|
||||
const client = message.client;
|
||||
// command starts here
|
||||
@ -65,6 +66,7 @@ module.exports = {
|
||||
const cmd = new Discord.RichEmbed()
|
||||
.setAuthor(`${client.user.username} / Commands`, client.user.avatarURL)
|
||||
.setColor(config.colour)
|
||||
.addField(`Command`,`\`${command.name}\``, true)
|
||||
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
|
||||
|
||||
if (command.aliases) cmd.addField("Aliases", `\`${command.aliases.join(', ')}\``, true);
|
||||
|
@ -1,5 +1,6 @@
|
||||
const Discord = require('discord.js');
|
||||
const config = require('../config.json');
|
||||
const randomString = require('random-string');
|
||||
module.exports = {
|
||||
name: 'new',
|
||||
description: 'Create a new ticket',
|
||||
@ -8,11 +9,22 @@ module.exports = {
|
||||
example: 'new I found an error',
|
||||
args: true,
|
||||
cooldown: config.cooldown,
|
||||
guildOnly: true,
|
||||
execute(message, args) {
|
||||
const client = message.client;
|
||||
// command starts here
|
||||
message.delete();
|
||||
const ticketChannel = "channel";
|
||||
let topic = args.join(" ");
|
||||
|
||||
function num(){
|
||||
return randomString({
|
||||
length: 4,
|
||||
numeric: true,
|
||||
letters: false,
|
||||
special: false,
|
||||
})
|
||||
};
|
||||
|
||||
// log
|
||||
if(config.useEmbeds) {
|
||||
|
29
commands/ping.js
Normal file
29
commands/ping.js
Normal file
@ -0,0 +1,29 @@
|
||||
const Discord = require('discord.js');
|
||||
const config = require('../config.json');
|
||||
module.exports = {
|
||||
name: 'ping',
|
||||
description: 'Calculate latency',
|
||||
usage: '',
|
||||
aliases: ['none'],
|
||||
example: '',
|
||||
args: false,
|
||||
cooldown: config.cooldown,
|
||||
guildOnly: true,
|
||||
execute(message, args) {
|
||||
const client = message.client;
|
||||
// command starts here
|
||||
message.delete();
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setAuthor(`${client.user.username} / Pong!`, client.user.avatarURL)
|
||||
.setColor(config.colour)
|
||||
.setTimestamp()
|
||||
.addField("API Latency", `${Math.round(message.client.ping)}ms`, true)
|
||||
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
|
||||
message.channel.send({embed})
|
||||
|
||||
|
||||
|
||||
|
||||
// command ends here
|
||||
},
|
||||
};
|
22
commands/remove.js
Normal file
22
commands/remove.js
Normal file
@ -0,0 +1,22 @@
|
||||
const Discord = require('discord.js');
|
||||
const config = require('../config.json');
|
||||
module.exports = {
|
||||
name: 'remove',
|
||||
description: 'Remove a member from a ticket',
|
||||
usage: '<@member>',
|
||||
aliases: ['kick'],
|
||||
example: 'remove @exampleUser',
|
||||
args: false,
|
||||
cooldown: config.cooldown,
|
||||
guildOnly: true,
|
||||
execute(message, args) {
|
||||
const client = message.client;
|
||||
// command starts here
|
||||
message.delete();
|
||||
|
||||
|
||||
|
||||
|
||||
// command ends here
|
||||
},
|
||||
};
|
14
index.js
14
index.js
@ -1,6 +1,6 @@
|
||||
/*
|
||||
###############################################################################################
|
||||
____ _ _____ _ _ _
|
||||
____ _ _____ _ _
|
||||
| _ \ (_) ___ ___ ___ _ __ __| | |_ _| (_) ___ | | __ ___ | |_ ___
|
||||
| | | | | | / __| / __| / _ \ | '__| / _` | | | | | / __| | |/ / / _ \ | __| / __|
|
||||
| |_| | | | \__ \ | (__ | (_) | | | | (_| | | | | | | (__ | < | __/ | |_ \__ \
|
||||
@ -138,12 +138,12 @@ client.once('ready', () => { // after bot has logged in
|
||||
|
||||
});
|
||||
|
||||
client.on('message', message => {
|
||||
client.on('message', async message => {
|
||||
// if (!message.content.startsWith(config.prefix) || message.author.bot) return;
|
||||
if (message.author.bot) return;
|
||||
if (message.channel.type === "dm") {
|
||||
if (message.author.id === client.user.id) return;
|
||||
message.channel.send(`Sorry, commands can only be used on the server.`)
|
||||
// message.channel.send(`Sorry, commands can only be used on the server.`)
|
||||
if (config.logDMs) {
|
||||
if (config.useEmbeds) {
|
||||
const embed = new Discord.RichEmbed()
|
||||
@ -167,9 +167,9 @@ client.on('message', message => {
|
||||
|
||||
// const args = message.content.slice(config.prefix.length).split(/ +/);
|
||||
|
||||
|
||||
const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|\\${config.prefix})\\s*`);
|
||||
if (!prefixRegex.test(message.content)) return;
|
||||
|
||||
const [, matchedPrefix] = message.content.match(prefixRegex);
|
||||
const args = message.content.slice(matchedPrefix.length).trim().split(/ +/);
|
||||
const commandName = args.shift().toLowerCase();
|
||||
@ -180,6 +180,10 @@ client.on('message', message => {
|
||||
|
||||
if (!command) return;
|
||||
|
||||
if (command.guildOnly && message.channel.type !== 'text') {
|
||||
return message.channel.send(`Sorry, this command can only be used on the server.`)
|
||||
}
|
||||
|
||||
if (command.args && !args.length) {
|
||||
// let reply = `:x: **Arguments were expected but none were provided.**`;
|
||||
//
|
||||
@ -238,7 +242,7 @@ client.on('message', message => {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.channel.send(`:x: **Oof!** An error occured whilst executing that command.\nThe issue has been reported.`);
|
||||
console.log(leeks.colors.red(`[ERROR] An unknown error occured whilst executing '${command}' command`));
|
||||
console.log(leeks.colors.red(`[ERROR] An unknown error occured whilst executing the '${command.name}' command`));
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -5,7 +5,8 @@
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"discord.js": "^11.4.2",
|
||||
"leeks.js": "^0.0.1"
|
||||
"leeks.js": "^0.0.1",
|
||||
"random-string": "^0.2.0"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
|
Loading…
Reference in New Issue
Block a user