This repository has been archived by the owner on Nov 13, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 Terminado de implementar comandos (no botones)
Implementado también try/catch por las dudas
- Loading branch information
1 parent
8b21518
commit ab1262d
Showing
7 changed files
with
325 additions
and
77 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
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 |
---|---|---|
@@ -1,4 +1,64 @@ | ||
exports.run = (client, message, args) => { | ||
// 🦄 Content of the command | ||
message.reply("**Give us nuggots for the confederatiowon!** <:nuggots:864676232737718292><:theiStonks:905161849459314789>"); | ||
// Data | ||
const config = require('../data/config.json'); | ||
const { template, footer } = require('../data/embeds.json'); | ||
const { isTicket, getUserCreator, updateToClosed, getCurTicketId, getTicketCategory } = require('../functions.js'); | ||
|
||
// DiscordJs | ||
const { MessageActionRow, MessageButton } = require('discord.js'); | ||
|
||
// This thing... | ||
const wait = require('node:timers/promises').setTimeout; | ||
|
||
exports.run = async (client, message, args) => { | ||
try { | ||
const guildId = message.guildId; | ||
const channelId = message.channelId; | ||
|
||
if(!isTicket(channelId, guildId)) { | ||
return; | ||
} | ||
|
||
const embed_closed = [{ | ||
color: 0xcc3366, | ||
title: template.closed.title, | ||
description: template.closed.description.replaceAll('{prefix_mention}', config.bot.prefix), | ||
footer: footer | ||
}]; | ||
|
||
const btns_ticket_closed = new MessageActionRow() | ||
.addComponents( | ||
new MessageButton().setCustomId('reopen').setLabel('Reabrir Ticket').setStyle('SUCCESS'), | ||
new MessageButton().setCustomId('delete').setLabel('Eliminar Ticket').setStyle('DANGER') | ||
); | ||
message.reply({ embeds: embed_closed, components: [ btns_ticket_closed ] }); | ||
|
||
updateToClosed(guildId, channelId); | ||
|
||
message.guild.channels.fetch(channelId).then( (channelEdit) => { | ||
var userCreator = getUserCreator(guildId, channelId); | ||
var menu_id = getTicketCategory(guildId, channelId); | ||
var category_info = Object.values(config.guilds[guildId]).flat().find(r => r.id === menu_id); | ||
|
||
if(category_info.allowed_staff.length > 0) { | ||
var allowed_staff = [ | ||
{ id: message.guild.roles.everyone.id, deny: [ 'VIEW_CHANNEL' ] }, | ||
{ id: message.guild.members.cache.get(userCreator), deny: [ 'VIEW_CHANNEL', 'SEND_MESSAGES' ] }, | ||
{ id: category_info.allowed_staff, allow: [ 'VIEW_CHANNEL', 'SEND_MESSAGES' ] } | ||
]; | ||
} else { | ||
var allowed_staff = [ | ||
{ id: message.guild.roles.everyone.id, deny: [ 'VIEW_CHANNEL' ] }, | ||
{ id: message.guild.members.cache.get(userCreator), deny: [ 'VIEW_CHANNEL', 'SEND_MESSAGES' ] } | ||
]; | ||
} | ||
|
||
console.log(channelEdit); | ||
|
||
channelEdit.edit({ | ||
permissionOverwrites: allowed_staff | ||
}); | ||
}); | ||
} catch(error) { | ||
console.log(error); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,41 @@ | ||
exports.run = (client, message, args) => { | ||
// 🦄 Content of the command | ||
message.reply("**Give us nuggots for the confederatiowon!** <:nuggots:864676232737718292><:theiStonks:905161849459314789>"); | ||
// Data | ||
const config = require('../data/config.json'); | ||
const { template, footer } = require('../data/embeds.json'); | ||
const { isTicket, updateToDeleted } = require('../functions.js'); | ||
|
||
// message.channel.delete(); | ||
// DiscordJs | ||
const { MessageActionRow, MessageButton } = require('discord.js'); | ||
|
||
// This thing... | ||
const wait = require('node:timers/promises').setTimeout; | ||
|
||
exports.run = async (client, message, args) => { | ||
try { | ||
const guildId = message.guildId; | ||
const channelId = message.channelId; | ||
|
||
if(!isTicket(channelId, guildId)) { | ||
return; | ||
} | ||
|
||
const sec = config.bot.secDelTicket; | ||
|
||
const embed_delete = [{ | ||
color: 0xcc3366, | ||
title: template.delete.title, | ||
description: template.delete.description.replaceAll('{seconds}', sec), | ||
footer: footer | ||
}]; | ||
message.reply({ embeds: embed_delete }); | ||
|
||
await wait(sec * 1000); | ||
|
||
const toDelete = message.guild.channels.cache.get(channelId); | ||
|
||
updateToDeleted(toDelete.guildId, toDelete.id); | ||
|
||
toDelete.delete(); | ||
} catch(error) { | ||
console.log(error); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,4 +1,90 @@ | ||
const config = require('../data/config.json'); | ||
const embed = require('../data/embeds.json'); | ||
|
||
const { Client, Intents } = require("discord.js"); | ||
const Discord = require("discord.js"); | ||
const cpuStat = require("cpu-stat"); | ||
const os = require("os"); | ||
|
||
const cli = new Client({ intents: [Intents.FLAGS.GUILDS] }); | ||
cli.login(config.bot.token); | ||
cli.once('ready', () => {}); | ||
|
||
exports.run = (client, message, args) => { | ||
// 🦄 Content of the command | ||
message.reply("**Give us nuggots for the confederatiowon!** <:nuggots:864676232737718292><:theiStonks:905161849459314789>"); | ||
try { | ||
cpuStat.usagePercent(function (e, percent, seconds) { | ||
try { | ||
if(e) { return console.log(e.stack); } | ||
message.reply({ embeds: [{ | ||
color: 0x62d1f0, | ||
title: '💻 Información del bot y estado del servidor', | ||
fields: [ | ||
{ name: '🤖 NodeJS', value: "```"+process.version+"```" }, | ||
{ name: '👾 Discord.JS', value: "```v"+Discord.version+"```" }, | ||
{ name: '🏸 API Latency', value: "```"+cli.ws.ping+"ms```" }, | ||
{ name: '⌚️ Uptime', value: "```"+duration(cli.uptime).map(i=>i).join(", ")+"```" }, | ||
{ name: '🧮 Consumo Memoria', value: "```"+(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)+" de "+(os.totalmem() / 1024 / 1024).toFixed(2)+"Mb```" }, | ||
{ name: '🤖 Consumo CPU', value: "```"+percent.toFixed(2)+"%```" }, | ||
{ name: '💻 Sistema Operativo', value: "```"+os.platform()+" ("+os.arch()+")```" }, | ||
], | ||
thumbnail: embed.footer | ||
}] }); | ||
} catch (e) { | ||
console.log(e); | ||
message.reply({ embeds: [{ | ||
color: 0x62d1f0, | ||
title: '💻 Información del bot y estado del servidor', | ||
fields: [ | ||
{ name: '🤖 NodeJS', value: "```"+process.version+"```" }, | ||
{ name: '👾 Discord.JS', value: "```v"+Discord.version+"```" }, | ||
{ name: '🏸 API Latency', value: "```"+cli.ws.ping+"ms```" }, | ||
{ name: '⌚️ Uptime', value: "```"+duration(cli.uptime).map(i=>i).join(", ")+"```" }, | ||
{ name: '🧮 Consumo Memoria', value: "```"+(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)+" de "+(os.totalmem() / 1024 / 1024).toFixed(2)+"Mb```" }, | ||
{ name: '🤖 Consumo CPU', value: "```"+percent.toFixed(2)+"%```" }, | ||
{ name: '💻 Sistema Operativo', value: "```"+os.platform()+" ("+os.arch()+")```" }, | ||
], | ||
thumbnail: embed.footer | ||
}] }); | ||
} | ||
}); | ||
|
||
function duration(duration, useMilli = false) { | ||
let remain = duration; | ||
let days = Math.floor(remain / (1000 * 60 * 60 * 24)); | ||
remain = remain % (1000 * 60 * 60 * 24); | ||
let hours = Math.floor(remain / (1000 * 60 * 60)); | ||
remain = remain % (1000 * 60 * 60); | ||
let minutes = Math.floor(remain / (1000 * 60)); | ||
remain = remain % (1000 * 60); | ||
let seconds = Math.floor(remain / (1000)); | ||
remain = remain % (1000); | ||
let milliseconds = remain; | ||
let time = { days, hours, minutes, seconds, milliseconds }; | ||
let parts = [] | ||
|
||
if(time.days) { | ||
parts.push(time.days + ' Día'+(time.days !== 1 ? 's' : '')); | ||
} | ||
if(time.hours) { | ||
parts.push(time.hours + ' H'+(time.hours !== 1 ? 's' : '')); | ||
} | ||
if(time.minutes) { | ||
parts.push(time.minutes + ' Min'+(time.minutes !== 1 ? 's' : '')); | ||
} | ||
if(time.seconds) { | ||
parts.push(time.seconds + ' Seg'+(time.seconds !== 1 ? 's' : '')); | ||
} | ||
if(useMilli && time.milliseconds) { | ||
parts.push(time.milliseconds + ' ms'); | ||
} | ||
|
||
if(parts.length === 0) { | ||
return ['instantly'] | ||
} else { | ||
return parts | ||
} | ||
} | ||
} catch(error) { | ||
console.log(error); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,63 @@ | ||
exports.run = (client, message, args) => { | ||
// 🦄 Content of the command | ||
message.reply("**Give us nuggots for the confederatiowon!** <:nuggots:864676232737718292><:theiStonks:905161849459314789>"); | ||
// Data | ||
const config = require('../data/config.json'); | ||
const { template, footer } = require('../data/embeds.json'); | ||
const { isTicket, getUserCreator, updateToOpen, getCurTicketId, getTicketCategory } = require('../functions.js'); | ||
|
||
// DiscordJs | ||
const { MessageActionRow, MessageButton } = require('discord.js'); | ||
|
||
// This thing... | ||
const wait = require('node:timers/promises').setTimeout; | ||
|
||
exports.run = async (client, message, args) => { | ||
try { | ||
const guildId = message.guildId; | ||
const channelId = message.channelId; | ||
|
||
if(!isTicket(channelId, guildId)) { | ||
return; | ||
} | ||
|
||
const embed_reopen = [{ | ||
color: 0xcc3366, | ||
title: template.reopened.title, | ||
description: template.reopened.description, | ||
footer: footer | ||
}]; | ||
|
||
const btns_ticket_reopen = new MessageActionRow() | ||
.addComponents( | ||
new MessageButton().setCustomId('close').setLabel('Cerrar Ticket').setStyle('DANGER') | ||
); | ||
message.reply({ embeds: embed_reopen, components: [ btns_ticket_reopen ] }); | ||
|
||
updateToOpen(guildId, channelId); | ||
|
||
await wait(750); | ||
|
||
message.guild.channels.fetch(channelId).then( (channelEdit) => { | ||
var userCreator = getUserCreator(guildId, channelId); | ||
var menu_id = getTicketCategory(guildId, channelId); | ||
var category_info = Object.values(config.guilds[guildId]).flat().find(r => r.id === menu_id); | ||
|
||
if(category_info.allowed_staff.length > 0) { | ||
var allowed_staff = [ | ||
{ id: message.guild.roles.everyone.id, deny: [ 'VIEW_CHANNEL' ] }, | ||
{ id: message.guild.members.cache.get(userCreator), allow: [ 'VIEW_CHANNEL', 'SEND_MESSAGES' ] }, | ||
{ id: category_info.allowed_staff, allow: [ 'VIEW_CHANNEL', 'SEND_MESSAGES' ] } | ||
]; | ||
} else { | ||
var allowed_staff = [ | ||
{ id: message.guild.roles.everyone.id, deny: [ 'VIEW_CHANNEL' ] }, | ||
{ id: message.guild.members.cache.get(userCreator), allow: [ 'VIEW_CHANNEL', 'SEND_MESSAGES' ] } | ||
]; | ||
} | ||
|
||
message.guild.channels.fetch(channelId).edit({ | ||
permissionOverwrites: allowed_staff | ||
}); | ||
}); | ||
} catch(error) { | ||
console.log(error); | ||
} | ||
} |
Oops, something went wrong.