Finish up commands and update package.json
This commit is contained in:
Eartharoid 2019-05-05 20:19:29 +01:00
parent 883675e8f1
commit 9ef0c3d04e
6 changed files with 116 additions and 17 deletions

View File

@ -7,16 +7,68 @@ module.exports = {
usage: '<@member>', usage: '<@member>',
aliases: ['adduser'], aliases: ['adduser'],
example: 'add @exampleUser', example: 'add @exampleUser',
args: false, args: true,
cooldown: config.cooldown, cooldown: config.cooldown,
guildOnly: true, guildOnly: true,
execute(message, args) { execute(message, args) {
const client = message.client; const client = message.client;
// command starts here // command starts here
message.delete(); message.delete();
if(!message.channel.name.startsWith('ticket-')) {
if(config.useEmbeds) {
const notTicket = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: **This command can only be used within a ticket channel**`)
return message.channel.send(notTicket);
} else {
return message.channel.send(`:x: **This command can only be used within a ticket channel**`)
}
}
let user = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
if(!user) {
if(config.useEmbeds) {
const err1 = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: **Unknown user.** Please mention a valid user.`)
return message.channel.send(err1);
} else {
return message.channel.send(`:x: **Unknown user.** Please mention a valid user.`);
}
}
try {
message.channel.overwritePermissions(user, {
SEND_MESSAGES: true,
READ_MESSAGES: true,
ATTACH_FILES: true
});
if(config.useEmbeds) {
const added = new Discord.RichEmbed()
.setColor(config.colour)
.setDescription(`${user} has been added.`)
message.channel.send(added);
} else {
message.channel.send(`${user} has been added.`);
}
// log
if(config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
.setTitle("User Added")
.setColor(config.colour)
.addField("Username", user, true)
.addField("Added by", message.author, true)
.addField("Channel", message.channel, true)
.setFooter(`DiscordTickets`)
.setTimestamp();
client.channels.get(config.logChannel).send({embed})
} else {
client.channels.get(config.logChannel).send(`User added to a ticket by **${message.author.tag} (${message.author.id})**`);
}
log.info(`${message.author.tag} added a user to a ticket (#${message.channel})`)
} catch(error) {
log.error(error);
}
// command ends here // command ends here
}, },

View File

@ -43,7 +43,7 @@ module.exports = {
log.info(`${message.author.tag} closed a ticket (#${message.channel.name})`) log.info(`${message.author.tag} closed a ticket (#${message.channel.name})`)
} catch(error) { } catch(error) {
console.error(leeks.colours.red(error)); log.error(leeks.colours.red(error));
} }
} }

View File

@ -63,15 +63,14 @@ module.exports = {
} }
const cmd = new Discord.RichEmbed() const cmd = new Discord.RichEmbed()
.setTitle("Commands")
.setColor(config.colour) .setColor(config.colour)
.addField(`Command`,`\`${command.name}\``, true) .addField(`Command`,`\`${command.name}\``, true)
.setFooter(`DiscordTickets by Eartharoid`); .setFooter(`DiscordTickets by Eartharoid`);
if (command.aliases) cmd.addField("Aliases", `\`${command.aliases.join(', ')}\``, true); if (command.aliases) cmd.addField("Aliases", `\`${command.aliases.join(', ')}\``, true);
if (command.description) cmd.addField("Description", `\`${command.description}\``, true); if (command.description) cmd.addField("Description", `\`${command.description}\``, false);
if (command.usage) cmd.addField("Usage", `\`${config.prefix}${command.name} ${command.usage}\``, true) if (command.usage) cmd.addField("Usage", `\`${config.prefix}${command.name} ${command.usage}\``, false)
if (command.example) cmd.addField("Example", `\`${config.prefix}${command.example}\``, true); if (command.example) cmd.addField("Example", `\`${config.prefix}${command.example}\``, false);
message.channel.send(cmd) message.channel.send(cmd)
} }

View File

@ -19,7 +19,6 @@ module.exports = {
.setColor(config.colour) .setColor(config.colour)
.setTimestamp() .setTimestamp()
.addField("API Latency", `${Math.round(message.client.ping)}ms`, true) .addField("API Latency", `${Math.round(message.client.ping)}ms`, true)
.setFooter(`DiscordTickets by Eartharoid`);
message.channel.send({embed}) message.channel.send({embed})

View File

@ -7,17 +7,67 @@ module.exports = {
usage: '<@member>', usage: '<@member>',
aliases: ['kick'], aliases: ['kick'],
example: 'remove @exampleUser', example: 'remove @exampleUser',
args: false, args: true,
cooldown: config.cooldown, cooldown: config.cooldown,
guildOnly: true, guildOnly: true,
execute(message, args) { execute(message, args) {
const client = message.client; const client = message.client;
// command starts here // command starts here
message.delete(); message.delete();
if(!message.channel.name.startsWith('ticket-')) {
if(config.useEmbeds) {
const notTicket = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: **This command can only be used within a ticket channel**`)
return message.channel.send(notTicket);
} else {
return message.channel.send(`:x: **This command can only be used within a ticket channel**`)
}
}
let user = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
if(!user) {
if(config.useEmbeds) {
const err1 = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: **Unknown user.** Please mention a valid user.`)
return message.channel.send(err1);
} else {
return message.channel.send(`:x: **Unknown user.** Please mention a valid user.`);
}
}
try {
message.channel.overwritePermissions(user, {
SEND_MESSAGES: false,
READ_MESSAGES: false
});
if(config.useEmbeds) {
const removed = new Discord.RichEmbed()
.setColor(config.colour)
.setDescription(`${user} has been removed.`)
message.channel.send(removed);
} else {
message.channel.send(`${user} has been removed.`);
}
// log
if(config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
.setTitle("User Removed")
.setColor(config.colour)
.addField("Username", user, true)
.addField("Removed by", message.author, true)
.addField("Channel", message.channel, true)
.setFooter(`DiscordTickets`)
.setTimestamp();
client.channels.get(config.logChannel).send({embed})
} else {
client.channels.get(config.logChannel).send(`User removed to a ticket by **${message.author.tag} (${message.author.id})**`);
}
log.info(`${message.author.tag} removed a user to a ticket (#${message.channel})`)
} catch(error) {
log.error(error);
}
// command ends here // command ends here
}, },
}; };

View File

@ -1,12 +1,11 @@
{ {
"name": "DiscordTickets", "name": "DiscordTickets",
"version": "1.0.0", "version": "1.1.4",
"description": "A Discord ticket/support - an open-source & self-host alternative to TicketManager (name tbd)", "description": "A Discord ticket/support - an open-source & self-host alternative to TicketManager (name tbd)",
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {
"discord.js": "^11.4.2", "discord.js": "^11.4.2",
"leeks.js": "^0.0.1", "leeks.js": "^0.0.1"
"random-string": "^0.2.0"
}, },
"devDependencies": {}, "devDependencies": {},
"scripts": { "scripts": {