-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,674 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const { | ||
ActionRowBuilder, | ||
ApplicationCommandType, | ||
ButtonBuilder, | ||
ButtonStyle, | ||
Colors, | ||
PermissionsBitField | ||
} = require('discord.js'); | ||
|
||
module.exports = { | ||
name: 'ticket', | ||
description: '(🔧) Permet d\'envoyer le système de ticket.', | ||
type: ApplicationCommandType.ChatInput, | ||
execute: async (client, interaction, args) => { | ||
|
||
if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) return interaction.reply({ | ||
cotent: `Vous n'avez pas la permissions d'éxécuter cette commande !` | ||
}) | ||
|
||
interaction.channel.send({ | ||
embeds: [{ | ||
title: "Open Ticket", | ||
description: `**__How Top Open A Ticket :__**\nPlease choose the type of ticket you wish to open.`, | ||
footer: { | ||
text: "Ticket Support" | ||
}, | ||
color: Colors.Blurple | ||
}], | ||
components: [ | ||
new ActionRowBuilder() | ||
.addComponents( | ||
new ButtonBuilder().setCustomId('staff').setLabel(' |Contact the staff').setEmoji('🎓').setStyle(ButtonStyle.Primary), | ||
new ButtonBuilder().setCustomId('answer').setLabel(' | Answer a question').setEmoji('⁉').setStyle(ButtonStyle.Secondary), | ||
new ButtonBuilder().setCustomId('other').setLabel(' | Other').setEmoji('🔧').setStyle(ButtonStyle.Success) | ||
) | ||
] | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"token": "", | ||
"parent": "", | ||
"roleStaffId": "", | ||
"logChannel": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module.exports = { | ||
name: 'interactionCreate', | ||
once: false, | ||
execute: async (interaction, client) => { | ||
await slashCommands(); | ||
|
||
async function slashCommands() { | ||
if(interaction.isChatInputCommand()) { | ||
|
||
const cmd = client.slashCommands.get(interaction.commandName); | ||
if(!cmd) { | ||
return interaction.channel.send({ content: `\`[⌛]\` ${interaction.member}, an error has occured.` }) | ||
} | ||
|
||
const args = []; | ||
|
||
for (let option of interaction.options.data) { | ||
if (option.type === "SUB_COMMAND") { | ||
if (option.name) args.push(option.name); | ||
option.options?.forEach((x) => { | ||
if (x.value) args.push(x.value); | ||
}); | ||
} else if (option.value) args.push(option.value); | ||
} | ||
interaction.member = interaction.guild.members.cache.get(interaction.user.id); | ||
|
||
//console.log(db.get(`guild_${interaction.guild.id}_settings`)) | ||
console.log(`[SLASH COMMANDS] `.bold.red + `/${cmd.name}`.bold.blue + ` has been executed`.bold.white) | ||
cmd.execute(client, interaction, args); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const colors = require('colors'); | ||
const { | ||
ActivityType | ||
} = require('discord.js'); | ||
|
||
module.exports = { | ||
name: 'ready', | ||
once: false, | ||
execute: async (client) => { | ||
|
||
console.log('[API] '.bold.green + `Connected to Discord.`.bold.white) | ||
|
||
let statuses = ['🎫 | Ticket Manager', `${client.guilds.cache.size} guilds`] | ||
setInterval(function () { | ||
let status = statuses[Math.floor(Math.random() * statuses.length)]; | ||
client.user.setPresence({ | ||
activities: [{ | ||
name: status, | ||
type: ActivityType.Watching | ||
}], | ||
status: "idle" | ||
}) | ||
}, 10000) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
const { | ||
ActionRowBuilder, | ||
ButtonBuilder, | ||
ButtonStyle, | ||
ChannelType, | ||
Colors, | ||
PermissionFlagsBits | ||
} = require('discord.js'); | ||
const transcript = require('discord-html-transcripts'); | ||
const config = require('../../config.json'); | ||
|
||
module.exports = { | ||
name: 'interactionCreate', | ||
once: false, | ||
execute: async (interaction, client) => { | ||
if (!interaction.isButton()) return; | ||
|
||
const row = new ActionRowBuilder() | ||
.addComponents( | ||
new ButtonBuilder().setCustomId('claim').setLabel(' | Claim').setEmoji('📩').setStyle(ButtonStyle.Secondary), | ||
new ButtonBuilder().setCustomId('close').setLabel(' | Close').setEmoji('🗑').setStyle(ButtonStyle.Danger), | ||
new ButtonBuilder().setCustomId('transcript').setLabel(' | Transcript').setEmoji('📁').setStyle(ButtonStyle.Primary) | ||
) | ||
|
||
|
||
let category = config.parent; | ||
let roleStaff = interaction.guild.roles.cache.get(config.roleStaffId); | ||
let LogChannel = config.logChannel; | ||
|
||
let AlreadyAChannel = interaction.guild.channels.cache.find(c => c.topic == interaction.user.id); | ||
if (AlreadyAChannel) return interaction.rely({ | ||
content: ":x: | You already have an open ticket on the server", | ||
ephemeral: true | ||
}); | ||
|
||
if (interaction.customId === "close") { | ||
let channel = interaction.channel; | ||
channel.delete() | ||
} else if (interaction.customId === "claim") { | ||
interaction.reply({ | ||
embeds: [{ | ||
description: `Your salon has been taken care of by ${interaction.user}`, | ||
footer: { | ||
text: "Ticket Support" | ||
}, | ||
color: Colors.Blurple | ||
}] | ||
}) | ||
} else if (interaction.customId === "transcript") { | ||
interaction.reply({ | ||
embeds: [{ | ||
description: `📁 | The transcript has been completed`, | ||
footer: { | ||
text: "Ticket Support" | ||
}, | ||
color: Colors.Blurple | ||
}] | ||
}) | ||
|
||
client.channels.cache.get(config.logChannel).send({ | ||
embeds: [{ | ||
description: `📁 | Transcript of ${interaction.channel}`, | ||
footer: { | ||
text: "Ticket Support" | ||
}, | ||
color: Colors.Blurple | ||
}], | ||
files: [await transcript.createTranscript(interaction.channel)] | ||
}) | ||
} else if (interaction.customId === "staff") { | ||
interaction.guild.channels.create({ | ||
name: `ticket of ${interaction.user.username}`, | ||
type: ChannelType.GuildText, | ||
permissionOverwrites: [{ | ||
id: interaction.user.id, | ||
allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.SendMessages], | ||
deny: [PermissionFlagsBits.MentionEveryone] | ||
}, | ||
{ | ||
id: interaction.guild.id, | ||
deny: [PermissionFlagsBits.ViewChannel] | ||
}, | ||
{ | ||
id: roleStaff, | ||
allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.SendMessages], | ||
deny: [PermissionFlagsBits.MentionEveryone] | ||
} | ||
] | ||
}).then((c) => { | ||
c.send({ | ||
content: `||${interaction.user}||`, | ||
embeds: [{ | ||
title: "Staff contact ticket", | ||
description: "Please detail your request so that a staff can answer you as precisely as possible.", | ||
footer: { | ||
text: "Ticket Support", | ||
}, | ||
color: Colors.Blurple | ||
}], | ||
components: [ | ||
row | ||
] | ||
}) | ||
interaction.reply({ | ||
content: `✅ Your ticket has been successfully opened. <#${c.id}>`, | ||
ephemeral: true | ||
}) | ||
}) | ||
|
||
} else if (interacion.customId === "answer") { | ||
interaction.guild.channels.create({ | ||
name: `ticket of ${interaction.user.username}`, | ||
type: ChannelType.GuildText, | ||
permissionOverwrites: [{ | ||
id: interaction.user.id, | ||
allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.SendMessages], | ||
deny: [PermissionFlagsBits.MentionEveryone] | ||
}, | ||
{ | ||
id: interaction.guild.id, | ||
deny: [PermissionFlagsBits.ViewChannel] | ||
}, | ||
{ | ||
id: roleStaff, | ||
allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.SendMessages], | ||
deny: [PermissionFlagsBits.MentionEveryone] | ||
} | ||
] | ||
}).then((c) => { | ||
c.send({ | ||
content: `||${interaction.user}||`, | ||
embeds: [{ | ||
title: "What is your question", | ||
description: "Please detail your request so that a staff can answer you as precisely as possible.", | ||
footer: { | ||
text: "Ticket Support", | ||
}, | ||
color: Colors.Blurple | ||
}], | ||
components: [ | ||
row | ||
] | ||
}) | ||
interaction.reply({ | ||
content: `✅ Your ticket has been successfully opened. <#${c.id}>`, | ||
ephemeral: true | ||
}) | ||
}) | ||
} else if (interacion.customId === "answer") { | ||
interaction.guild.channels.create({ | ||
name: `ticket of ${interaction.user.username}`, | ||
type: ChannelType.GuildText, | ||
permissionOverwrites: [{ | ||
id: interaction.user.id, | ||
allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.SendMessages], | ||
deny: [PermissionFlagsBits.MentionEveryone] | ||
}, | ||
{ | ||
id: interaction.guild.id, | ||
deny: [PermissionFlagsBits.ViewChannel] | ||
}, | ||
{ | ||
id: roleStaff, | ||
allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.SendMessages], | ||
deny: [PermissionFlagsBits.MentionEveryone] | ||
} | ||
] | ||
}).then((c) => { | ||
c.send({ | ||
content: `||${interaction.user}||`, | ||
embeds: [{ | ||
title: "What is your problem ?", | ||
description: "Please detail your request so that a staff can answer you as precisely as possible.", | ||
footer: { | ||
text: "Ticket Support", | ||
}, | ||
color: Colors.Blurple | ||
}], | ||
components: [ | ||
row | ||
] | ||
}) | ||
interaction.reply({ | ||
content: `✅ Your ticket has been successfully opened. <#${c.id}>`, | ||
ephemeral: true | ||
}) | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const { | ||
Routes | ||
} = require('discord-api-types/v9'); | ||
const { | ||
REST | ||
} = require('@discordjs/rest') | ||
const { | ||
readdirSync | ||
} = require('fs'); | ||
const colors = require('colors'); | ||
|
||
module.exports = (client) => { | ||
// # slashCommands | ||
const arrayOfSlashCommands = []; | ||
|
||
const loadSlashCommands = (dir = "./commands/") => { | ||
readdirSync(dir).forEach(dirs => { | ||
const commands = readdirSync(`${dir}/${dirs}/`).filter(files => files.endsWith(".js")); | ||
|
||
for (const files of commands) { | ||
const getFileName = require(`../${dir}/${dirs}/${files}`); | ||
client.slashCommands.set(getFileName.name, getFileName); | ||
console.log(`[SLASH COMMANDS]`.bold.red + ` Loading command :`.bold.white + ` ${getFileName.name}`.bold.red); | ||
arrayOfSlashCommands.push(getFileName); | ||
} | ||
}) | ||
|
||
setTimeout(async () => { | ||
console.log(`API >`.bold.white + ` Synchronize all commands with Discord API.`.bold.green) | ||
await client.application.commands.set(arrayOfSlashCommands); | ||
}, 5000) | ||
} | ||
loadSlashCommands(); | ||
|
||
console.log(`•----------•`.bold.black) | ||
|
||
// # events | ||
const loadEvents = (dir = "./events/") => { | ||
readdirSync(dir).forEach(dirs => { | ||
const events = readdirSync(`${dir}/${dirs}`).filter(files => files.endsWith(".js")); | ||
|
||
for (const files of events) { | ||
const getFileName = require(`../${dir}/${dirs}/${files}`) | ||
client.on(getFileName.name, (...args) => getFileName.execute(...args, client)) | ||
console.log(`[EVENTS]`.bold.red + ` Loading event :`.bold.white + ` ${getFileName.name}`.bold.red); | ||
if (!events) return console.log(`[EVENTS]`.bold.red + `Nothing event in : `.bold.yellow + `${files}`.bold.red) | ||
} | ||
}) | ||
} | ||
loadEvents(); | ||
console.log(`•----------•`.bold.black) | ||
} |
Oops, something went wrong.