Skip to content

Commit

Permalink
Merge pull request #3 from FnrDev/dev
Browse files Browse the repository at this point in the history
New ticket update 💃
  • Loading branch information
FnrDev authored Nov 21, 2021
2 parents b65a7ad + 83b380f commit 8598559
Show file tree
Hide file tree
Showing 9 changed files with 242 additions and 148 deletions.
209 changes: 120 additions & 89 deletions commands/info/help.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { MessageEmbed, MessageActionRow, MessageSelectMenu } = require('discord.js');
const { MessageEmbed, MessageActionRow, MessageSelectMenu, MessageButton } = require('discord.js');
const humanizeDuration = require("humanize-duration");

module.exports = {
Expand All @@ -14,8 +14,9 @@ module.exports = {
usage: "/ping",
category: "info",
run: async(interaction, client) => {
const command = interaction.options.getString('command');
if (command) {
try {
const command = interaction.options.getString('command');
if (command) {
const cmd = client.commands.get(command.toLowerCase());
if (!cmd) {
return interaction.reply({ content: `I can\'t find \`${cmd}\` command`, ephemeral: true })
Expand All @@ -37,92 +38,122 @@ module.exports = {
return interaction.reply({ embeds: [embed] })
}
// await interaction.deferReply();
const row = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('help_menu')
.setPlaceholder('Select Command Category.')
.setMinValues(1)
.setMaxValues(1)
.addOptions([
{
label: "General",
emoji: "⚙",
description: "Show all commands in general category.",
value: "general"
},
{
label: "Info",
description: "Show all commands in info category.",
emoji: "ℹ",
value: "info"
},
{
label: "Ticket",
description: "Show all commands in ticket category.",
emoji: "📃",
value: "ticket"
const row = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('help_menu')
.setPlaceholder('Select Command Category.')
.setMinValues(1)
.setMaxValues(1)
.addOptions([
{
label: "General",
emoji: "⚙",
description: "Show all commands in general category.",
value: "general"
},
{
label: "Info",
description: "Show all commands in info category.",
emoji: "ℹ",
value: "info"
},
{
label: "Ticket",
description: "Show all commands in ticket category.",
emoji: "📃",
value: "ticket"
}
])
)
interaction.reply({ content: "**👋 Select Category You Need Help For**", components: [row] });
const filter = i => i.customId === 'help_menu' || 'selected_command' && i.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({ filter: filter, max: 2, componentType: "SELECT_MENU" });
collector.on('collect', async i => {
if (i.values.includes('general')) {
await i.deferUpdate();
const loopArray = [];
if (client.commands.filter(r => r.category === 'general').size === '25') {
loopArray.slice(0, 25)
}
client.commands.filter(r => r.category === "general").forEach(cmd => {
loopArray.push({
label: cmd.name,
value: cmd.name,
description: cmd.description,
emoji: "⚙"
})
})
const commandRow = row.setComponents(
new MessageSelectMenu()
.setCustomId('general_cmd')
.setPlaceholder('General Commands')
.setMinValues(1)
.setMaxValues(1)
.addOptions(loopArray)
)
return i.editReply({
content: "**Select what command you need help for.**",
components: [commandRow]
})
}
])
)
interaction.reply({ content: "**👋 Select Category You Need Help For**", components: [row] });
const filter = i => i.customId === 'help_menu' && i.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({ filter: filter, max: 1 });
collector.on('collect', async i => {
if (i.values.includes('general')) {
await i.deferUpdate();
let loopGeneralCommands = '';
client.commands.filter(r => r.category === 'general').forEach(cmd => {
if (!cmd.description) return;
loopGeneralCommands += `**\`/${cmd.name}\`** - ${cmd.description}\n`
});
const embed = new MessageEmbed()
.setTitle('General Commnads:')
.setDescription(loopGeneralCommands)
.setColor(interaction.guild.me.displayHexColor)
.setFooter(`Requested by ${interaction.user.tag}`, interaction.user.displayAvatarURL({ dynamic: true }))
return i.editReply({
embeds: [embed],
content: null,
components: []
});
}
if (i.values.includes('info')) {
await i.deferUpdate();
let loopInfoCommands = '';
client.commands.filter(r => r.category === 'info').forEach(cmd => {
if (!cmd.description) return;
loopInfoCommands += `**\`/${cmd.name}\`** - ${cmd.description}\n`
});
const embed = new MessageEmbed()
.setTitle('Info Commnads:')
.setDescription(loopInfoCommands)
.setColor(interaction.guild.me.displayHexColor)
.setFooter(`Requested by ${interaction.user.tag}`, interaction.user.displayAvatarURL({ dynamic: true }))
return i.editReply({
embeds: [embed],
content: null,
components: []
});
}
if (i.values.includes('ticket')) {
await i.deferUpdate();
let loopTicketCategory = '';
client.commands.filter(r => r.category === 'ticket').forEach(cmd => {
if (!cmd.description) return;
loopTicketCategory += `**\`/${cmd.name}\`** - ${cmd.description}\n`;
});
const embed = new MessageEmbed()
.setTitle('Ticket Commands:')
.setDescription(loopTicketCategory)
.setColor(interaction.guild.me.displayHexColor)
.setFooter(`Requested by ${interaction.user.tag}`, interaction.user.displayAvatarURL({ dynamic: true }))
return i.editReply({
embeds: [embed],
content: null,
components: []
})
}
})
if (i.values.includes('info')) {
await i.deferUpdate();
const loopArray = [];
if (client.commands.filter(r => r.category === 'info').size === '25') {
loopArray.slice(0, 25)
}
client.commands.filter(r => r.category === "info").forEach(cmd => {
loopArray.push({
label: cmd.name,
value: cmd.name,
description: cmd.description,
emoji: "ℹ"
})
})
const commandRow = row.setComponents(
new MessageSelectMenu()
.setCustomId('info_cmd')
.setPlaceholder('Info Commands')
.setMinValues(1)
.setMaxValues(1)
.addOptions(loopArray)
)
return i.editReply({
content: "**Select what command you need help for.**",
components: [commandRow]
})
}
if (i.values.includes('ticket')) {
await i.deferUpdate();
const loopArray = [];
if (client.commands.filter(r => r.category === 'ticket').size > 25) {
loopArray.slice(0, 25)
}
client.commands.filter(r => r.category === "ticket").forEach(cmd => {
loopArray.push({
label: cmd.name,
value: cmd.name,
description: cmd.description,
emoji: "📃"
})
})
const commandRow = row.setComponents(
new MessageSelectMenu()
.setCustomId('ticket_cmd')
.setPlaceholder('Ticket Commands')
.setMinValues(1)
.setMaxValues(1)
.addOptions(loopArray)
)
return i.editReply({
content: "**Select what command you need help for.**",
components: [commandRow]
})
}
})
} catch (e) {
return false;
}
}
}
1 change: 1 addition & 0 deletions commands/ticket/addUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
}
],
category: "ticket",
usage: "/add **user:**Fnr#0017",
timeout: 3000,
modOnly: true,
ticketOnly: true,
Expand Down
25 changes: 25 additions & 0 deletions commands/ticket/close.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const Discord = require('discord.js');
const config = require('../../settings.json')

module.exports = {
name: "close",
description: "Close a ticket.",
ticketOnly: true,
modOnly: true,
category: "ticket",
usage: "/close",
run: async(interaction) => {
await interaction.channel.permissionOverwrites.set([
{
id: interaction.guild.id,
deny: ['VIEW_CHANNEL', 'SEND_MESSAGES']
}
])
const embed = new Discord.MessageEmbed()
.setDescription(`**🔒 Ticket has been closed**`)
.setColor(config.embedColor)
interaction.reply({
embeds: [embed]
})
}
}
1 change: 1 addition & 0 deletions commands/ticket/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
modOnly: true,
ticketOnly: true,
category: "ticket",
usage: "/delete",
run: async(interaction, client) => {
const row = new MessageActionRow()
.addComponents(
Expand Down
1 change: 1 addition & 0 deletions commands/ticket/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
description: "Create a new ticket",
timeout: 10000,
category: "ticket",
usage: "/new",
run: async(interaction, client) => {
const ticketCatgory = interaction.guild.channels.cache.find(r => r.type === 'GUILD_CATEGORY' && r.name === 'tickets');
if (!ticketCatgory) {
Expand Down
1 change: 1 addition & 0 deletions commands/ticket/removeUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
timeout: 3000,
ticketOnly: true,
modOnly: true,
usage: "/remove **user:**Fnr#0017",
category: "ticket",
run: async(interaction) => {
const member = interaction.options.getMember('user');
Expand Down
1 change: 1 addition & 0 deletions commands/ticket/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
modOnly: true,
ticketOnly: true,
category: "ticket",
usage: "/rename **new_name:**Premium",
run: async(interaction) => {
const name = interaction.options.getString('new_name');
try {
Expand Down
1 change: 1 addition & 0 deletions commands/ticket/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
description: "Setup ticket category in your server",
permission: "ADMINISTRATOR",
category: "ticket",
usage: "/setup",
run: async(interaction, client) => {
const checkTicketCategory = interaction.guild.channels.cache.find(r => r.type === 'GUILD_CATEGORY' && r.name === 'tickets');
if (checkTicketCategory) {
Expand Down
Loading

0 comments on commit 8598559

Please sign in to comment.