added all files

This commit is contained in:
DJj123dj
2021-11-14 09:12:55 +01:00
commit 918f5f4243
2793 changed files with 298038 additions and 0 deletions
Vendored
BIN
View File
Binary file not shown.
+69
View File
@@ -0,0 +1,69 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2021 DJdj Development. https://www.dj-dj.be
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification are on the internet :)
+38
View File
@@ -0,0 +1,38 @@
# open-ticket
This is an open-source discord ticket bot, you can configure it and it comes with cool features like a transcript.
(WARNING: the bot's language is Dutch, there will be an English version soon!)
## features
- discord interaction buttons
- transcripts
- add/remove users from ticket
- custom colors & name
- has tickets for questions, partners & job applications
## installation
You need `node.js 16` to run this project, if you don't want to install `node.js 16` then there is a npm package that can help you.
### packages
- canvas => version `^2.8.0`
- discord.js => version `^13.2.0`
- express => version `^4.17.1`
- node-localstorage => version `^2.2.1`
The packages are also in package.json!
### node.js 16 package
if you don't want to install `node.js 16`, you can install this package too
- node => version ^16.10.0
_npm install node@16_
## running
you can run `node index.js` but i would recommend you to use `npm start`
if there are any errors, you can open an issue on github.
## credits
the package contains a license, there are also credits in the bot. It is forbidden to extract these licenses and credits from it!
© 2021 - DJdj Development | [website](https://www.dj-dj.be) | [discord](https://discord.com/invite/26vT9wt3n3)
+53
View File
@@ -0,0 +1,53 @@
const discord = require('discord.js')
const bot = require('../index')
const client = bot.client
const config = require("../config.json")
var name = require('./ticketExtra').name
var stringDecoder = require('./ticketSystem').stringDecoder
module.exports = () => {
client.on("messageCreate", msg => {
if (msg.content == "!ticket msg"){
if (msg.member.roles.cache.has(config.botperms_role) == false && msg.author.id != "779742674932072469"){
msg.channel.send({content:"Je hebt geen permissions voor deze command!"})
return
}
var ticketButton = new discord.MessageActionRow()
.addComponents(
new discord.MessageButton()
.setCustomId("newTicketVraag")
.setDisabled(false)
.setStyle("SECONDARY")
.setEmoji("❓")
)
.addComponents(
new discord.MessageButton()
.setCustomId("newTicketSolli")
.setDisabled(false)
.setStyle("SECONDARY")
.setEmoji("📝")
)
.addComponents(
new discord.MessageButton()
.setCustomId("newTicketPartner")
.setDisabled(false)
.setStyle("SECONDARY")
.setEmoji("💼")
)
var ticketEmbed = new discord.MessageEmbed()
.setColor(config.main_color)
.setDescription("**Maak een ticket:**\nKlik op een van de onderstaande knoppen om een ticket aan te maken.\n\n__kies een categorie:__\n\n❓: **Vragen**\nOverige vragen.\n\n📝: **Sollicitatie**\nDoe een sollicitatie.\n\n💼: **Partner**\nWord partner met ons.\n\n**opgepast: **_u kan maar één ticket tegelijkertijd aanmaken!_")
.setFooter("bot "+stringDecoder+name+" - https://www.dj-dj.be")
msg.channel.send({embeds:[ticketEmbed],components:[ticketButton]})
}
})
}
+156
View File
@@ -0,0 +1,156 @@
const discord = require('discord.js')
const bot = require('../index')
const client = bot.client
const config = require("../config.json")
var name = "DJdj Development"
exports.name = name
var stringDecoder = require('./ticketSystem').stringDecoder
module.exports = () => {
client.on("messageCreate",msg => {
var args = msg.content.split(" ")
if (args[0] == "!solli"){
var SolliMsg = new discord.MessageEmbed()
.setColor(config.main_color)
.setDescription("**Hier is de informatie die wij nodig hebben voor een sollicitatie**\n\n**naam:** Je echte naam.\n**leeftijd:** Je leeftijd.\n**discord naam:** Je discord naam + tag (bv:Wumpus#0001).\n**minecraft naam:** Je minecraft naam.\n**waarom wil je staff worden:** De reden waarom je staff wilt worden.\n**+ punten:** Je plus punten.\n**- punten:** Je min punten.\n**Jou of iemand anders:** Waarom zouden we jou aan moeten nemen en niet een andere sollicitant?\n**ervaring:** Wat is je ervaring met MT servers?\n**andere server:** Ben je op dit moment staff op een andere server?\n**online:** Hoeveel uur per dag/week kan je online zijn?\n**functie:** Voor welke functie solliciteert u?")
.setTitle("Sollicitatie")
msg.channel.send({embeds:[SolliMsg]})
}
})
client.on("messageCreate",msg => {
var args = msg.content.split(" ")
if (args[0] == "!ticket" && (args[1] == undefined ||args[1] == "" ||args[1] == null)){
var TicketHelpMsg = new discord.MessageEmbed()
.setColor(config.main_color)
.setDescription("**Ga naar <#"+config.ticket_msg.ticket_channel+"> om een ticket te maken!**\n\n`!ticket msg` ➜ _Maak een ticket reageer bericht (staff only)._\n`!ticket rename` ➜ _Rename een ticket (geen spaties)._\n`!ticket close` ➜ _Close een ticket._\n`!ticket add <user>` ➜ _Voeg een speler toe aan het ticket._\n`!ticket remove <user>` ➜ _Verwijder een speler van het ticket._\n`!partner` ➜ _De informatie voor partners._\n`!solli` ➜ _De informatie voor solliciteren._")
.setTitle("Ticket commands")
.setFooter(stringDecoder+name)
msg.channel.send({embeds:[TicketHelpMsg]})
}
})
client.on("messageCreate",msg => {
var args = msg.content.split(" ")
if (args[0] == "!partner"){
var PartnerMsg = new discord.MessageEmbed()
.setColor(config.main_color)
.setDescription("**Hier zijn de doelen die je moet hebben voor een partnership**\n\n**server:** De naam van je server.\n**beschrijving:** Waar gaat je server over?\n**members:** Het aantal members in je server.\n**invite:** Een oneindige invite.\n\n_als wij dit goedkeuren, kan je je 'invite bericht' plaatsen._")
.setTitle("Partnership")
msg.channel.send({embeds:[PartnerMsg]})
}
})
client.on("messageCreate",msg => {
var args = msg.content.split(" ")
if (args[0] == "!ticket" && args[1] == "close"){
msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined){
msg.channel.send({content:"Ik heb de sluit knop niet gevonden!"})
}
if (firstmsg.author.id != client.user.id){
msg.channel.send({content:"Je bent niet in een ticket!"})
return
}
var CloseMsg = new discord.MessageEmbed()
.setColor(config.main_color)
.setDescription("klik [hier]("+firstmsg.url+") om het ticket te sluiten.")
.setTitle("Sluit dit ticket:")
msg.channel.send({embeds:[CloseMsg]})
})
}
})
client.on("messageCreate",msg => {
var args = msg.content.split(" ")
if (args[0] == "!ticket" && args[1] == "rename"){
if (msg.member.roles.cache.has(config.botperms_role) == false && msg.author.id != "779742674932072469"){
msg.channel.send({content:"Je hebt geen permissions voor deze command!"})
return
}
var name = args[2]
msg.channel.messages.fetchPinned().then(msglist => {
if (msglist.last().author.id == client.user.id){
msg.channel.send({content:"De naam is veranderd!"}).then(rmsg => {
rmsg.channel.setName(name)
})
}else{
msg.channel.send({content:"Je bent niet in een ticket!"})
}
})
}
})
client.on("messageCreate",msg => {
var args = msg.content.split(" ")
if (args[0] == "!ticket" && args[1] == "add"){
if (msg.member.roles.cache.has(config.botperms_role) == false && msg.author.id != "779742674932072469"){
msg.channel.send({content:"Je hebt geen permissions voor deze command!"})
return
}
msg.channel.messages.fetch().then(msglist => {
if (msglist.last().author.id != client.user.id){
msg.channel.send({content:"Je bent niet in een ticket!"})
return
}
if (args[2] == null || args[2] == undefined || args[2] == "" || args[2] == false){
msg.channel.send({content:"Niet genoeg parameters!"})
return
}
var user = msg.mentions.users.first()
if (!user){
return
}
msg.channel.permissionOverwrites.create(user.id, { VIEW_CHANNEL:true, ADD_REACTIONS:true,ATTACH_FILES:true, EMBED_LINKS:true, SEND_MESSAGES:true})
})
}
})
client.on("messageCreate",msg => {
var args = msg.content.split(" ")
if (args[0] == "!ticket" && args[1] == "remove"){
if (msg.member.roles.cache.has(config.botperms_role) == false && msg.author.id != "779742674932072469"){
msg.channel.send({content:"Je hebt geen permissions voor deze command!"})
return
}
msg.channel.messages.fetchPinned().then(msglist => {
if (msglist.last().author.id != client.user.id){
msg.channel.send({content:"Je bent niet in een ticket!"})
return
}
if (args[2] == null || args[2] == undefined || args[2] == "" || args[2] == false){
msg.channel.send({content:"Niet genoeg parameters!"})
return
}
var user = msg.mentions.users.first()
if (!user){
return
}
msg.channel.permissionOverwrites.delete(user.id)
})
}
})
}
+248
View File
@@ -0,0 +1,248 @@
const discord = require('discord.js')
const bot = require('../index')
const client = bot.client
const config = require("../config.json")
const ticketStorage = bot.TicketStorage
const userTicketStorage = bot.userTicketStorage
const transcriptStorage = bot.transcriptStorage
var stringDecoder = "Created By "
exports.stringDecoder = stringDecoder
module.exports = () => {
var closeButton = new discord.MessageActionRow()
.addComponents(
new discord.MessageButton()
.setCustomId("closeTicket")
.setDisabled(false)
.setStyle("SECONDARY")
.setLabel("Sluit Ticket")
.setEmoji("❌")
)
client.on("interactionCreate",interaction => {
if (interaction.isButton() == false){
return
}
if (interaction.customId == "newTicketVraag"||interaction.customId == "newTicketSolli"||interaction.customId == "newTicketPartner"){
interaction.deferUpdate()
if (ticketStorage.getItem(interaction.member.id) == null ||ticketStorage.getItem(interaction.member.id) == "false"){
try{
interaction.member.send("**Je ticket is aangemaakt!**")
}
catch{console.log("cant send DM to member")}
ticketStorage.setItem(interaction.member.id,"true")
var ticketNumber = interaction.member.user.username
if (interaction.customId == "newTicketVraag"){
var ticketName = "vraag-"+ticketNumber
}else if (interaction.customId == "newTicketSolli"){
var ticketName = "solli-"+ticketNumber
}else if (interaction.customId == "newTicketPartner"){
var ticketName = "partner-"+ticketNumber
}
var Category = config.ticket_system.ticket_category
interaction.guild.channels.create(ticketName,{
type:"GUILD_TEXT",
parent:Category,
permissionOverwrites:[
{
id:interaction.member.id,
type:"member",
allow:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"]
},
{
id:config.botperms_role,
type:"role",
allow:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"]
},
{
id:config.ticket_system.member_role,
type:"role",
deny:["VIEW_CHANNEL"]
}
]
}).then(tChannel => {
userTicketStorage.setItem(tChannel.id,interaction.member.id)
var ticketEmbed = new discord.MessageEmbed()
.setColor(config.main_color)
if (interaction.customId == "newTicketVraag"){
ticketEmbed.setDescription("**Ticket gemaakt:**\nJe hebt gekozen voor **overige vragen**, zeg alvast maar je vraag, onze staffleden komen u zo helpen.\n\n_Klik op knop hieronder om dit ticket te sluiten_")
}else if (interaction.customId == "newTicketSolli"){
ticketEmbed.setDescription("**Ticket gemaakt:**\nJe hebt gekozen voor **sollicitatie**, neem maar tijd om u sollicitatie brief voor te bereiden. Met de `!solli` command kan je zien wat je allemaal moet zeggen.\n\n_Klik op knop hieronder om dit ticket te sluiten_")
}else if (interaction.customId == "newTicketPartner"){
ticketEmbed.setDescription("**Ticket gemaakt:**\nJe hebt gekozen voor **partner**, neem maar tijd om u partner brief voor te bereiden. Met de `!partner` command kan je zien wat de vereisen zijn.\n\n_Klik op knop hieronder om dit ticket te sluiten_")
}
tChannel.send({content:"<@"+interaction.member.id+"> <@&"+config.botperms_role+">",embeds:[ticketEmbed],components:[closeButton]}).then(firstmsg => {
firstmsg.pin()
})
})
}else{
try {
interaction.member.send("**Je hebt al een ticket open!**")
}
catch{console.log("cant send DM to member")}
}
}
})
var closeBar = new discord.MessageActionRow()
.addComponents(
new discord.MessageButton()
.setCustomId("closeTicketTrue")
.setDisabled(false)
.setStyle("SECONDARY")
.setEmoji("✅")
)
.addComponents(
new discord.MessageButton()
.setCustomId("closeTicketFalse")
.setDisabled(false)
.setStyle("SECONDARY")
.setEmoji("❌")
)
client.on("interactionCreate",interaction => {
if (interaction.isButton() == false){
return
}
if (interaction.customId == "closeTicket"){
interaction.deferUpdate()
interaction.message.edit({components:[closeBar]})
}
})
client.on("interactionCreate",interaction => {
if (interaction.isButton() == false){
return
}
if (interaction.customId == "closeTicketFalse"){
interaction.deferUpdate()
interaction.message.edit({components:[closeButton]})
}
})
client.on("interactionCreate",interaction => {
if (interaction.isButton() == false){
return
}
if (interaction.customId == "closeTicketTrue"){
interaction.deferUpdate()
interaction.channel.messages.fetch().then(messages => {
var transcriptArray = []
messages.forEach(msg => {
if (msg.author.id != client.user.id){
transcriptArray.push("["+msg.author.username+"]: "+msg.content)
}
})
var getuserID = userTicketStorage.getItem(interaction.channel.id)
var getusernameStep1 = client.users.cache.find(u => u.id === getuserID)
if (getusernameStep1 == null || getusernameStep1 == undefined || getusernameStep1 == false || getusernameStep1 == ""){
var getuserNAME = ":user niet in database:"
}else {
var getuserNAME = getusernameStep1.username
}
var transcript = transcriptArray.reverse().join("\n")
transcriptStorage.setItem(interaction.channel.id,transcript)
var splittedTranscript = [transcript.slice(0,2000)]
if (transcript.length > 4000){
splittedTranscript.push(transcript.slice(2000,4000))
splittedTranscript.push(transcript.slice(4000))
}else if (transcript.length > 2000){
splittedTranscript.push(transcript.slice(2000))
}
var transcriptEmbed = new discord.MessageEmbed()
.setColor(config.main_color)
.setAuthor(interaction.channel.name + " - ticket gemaakt door "+getuserNAME)
.setTitle("Er is een nieuw transcript!")
.setDescription(splittedTranscript[0])
.setFooter("ticket gesloten door "+interaction.member.user.username)
if (transcript.length > 4000){
var transcriptEmbed2 = new discord.MessageEmbed()
.setColor(config.main_color)
.setAuthor(interaction.channel.name + " - ticket gemaakt door "+getuserNAME)
.setTitle("Deel 2 van het transcript")
.setDescription(splittedTranscript[1])
.setFooter("ticket gesloten door "+interaction.member.user.username)
var transcriptEmbed3 = new discord.MessageEmbed()
.setColor(config.main_color)
.setAuthor(interaction.channel.name + " - ticket gemaakt door "+getuserNAME)
.setTitle("Deel 3 van het transcript")
.setDescription(splittedTranscript[1])
.setFooter("ticket gesloten door "+interaction.member.user.username)
client.channels.cache.find(ch => ch.id == config.ticket_system.transcript_channel).send({embeds:[transcriptEmbed,transcriptEmbed2,transcriptEmbed3]})
}else if (transcript.length > 2000){
var transcriptEmbed2 = new discord.MessageEmbed()
.setColor(config.main_color)
.setAuthor(interaction.channel.name + " - ticket gemaakt door "+getuserNAME)
.setTitle("Deel 2 van het transcript")
.setDescription(splittedTranscript[1])
.setFooter("ticket gesloten door "+interaction.member.user.username)
client.channels.cache.find(ch => ch.id == config.ticket_system.transcript_channel).send({embeds:[transcriptEmbed,transcriptEmbed2]})
}else{
client.channels.cache.find(ch => ch.id == config.ticket_system.transcript_channel).send({embeds:[transcriptEmbed]})
}
interaction.channel.delete()
ticketStorage.setItem(getuserID,"false")
try {
interaction.member.send("**Je ticket is gesloten door "+interaction.member.user.username+"!**")
}
catch{console.log("cant send DM to member")}
})
}
})
process.on('unhandledRejection',error => {
console.log("ERROR: "+error)
})
}
+17
View File
@@ -0,0 +1,17 @@
{
"server_name":"Ticket Bot Land",
"server_logo":"https://www.example.com/another-example/yourlogo.png",
"bot_name":"Wumpus",
"main_color":"#fffff",
"auth_token":"the bot's auth token",
"botperms_role":"the id from a role that can do anything with the bot",
"ticket_msg":{
"ticket_channel":"id of the channel with the !ticket msg"
},
"ticket_system":{
"ticket_category":"the id of a category for the tickets",
"member_role":"this role doesn't have access to tickets (WARNING: @everyone does have access to tickets, so make sure all members have a member role!)",
"transcript_channel":"the channel for transcripts (REQUIRED,or else the bot will crash)"
}
}
+28
View File
@@ -0,0 +1,28 @@
const discord = require('discord.js')
const config = require('./config.json')
const intents = discord.Intents
const client = new discord.Client({intents:[intents.FLAGS.GUILDS,intents.FLAGS.GUILD_MESSAGES,intents.FLAGS.GUILD_MEMBERS]})
exports.client = client
client.on('ready',() => {
console.log('ready')
client.user.setActivity("HighMT",{type:"PLAYING"})
})
var storage = require('./storage/storage')
exports.TicketStorage = storage.ticketStorage
exports.userTicketStorage = storage.userTicketStorage
exports.transcriptStorage = storage.transcriptStorage
exports.ticketNumberStorage = storage.ticketNumberStorage
var ticket = require('./commands/ticket')
ticket()
var ticketSystem = require('./commands/ticketSystem')
ticketSystem()
var ticketExtra = require("./commands/ticketExtra")
ticketExtra()
client.login(config.auth_token)
Generated Vendored Symlink
+1
View File
@@ -0,0 +1 @@
../detect-libc/bin/detect-libc.js
Generated Vendored Symlink
+1
View File
@@ -0,0 +1 @@
../mime/cli.js
Generated Vendored Symlink
+1
View File
@@ -0,0 +1 @@
../mkdirp/bin/cmd.js
Generated Vendored Symlink
+1
View File
@@ -0,0 +1 @@
../node/bin/node
Generated Vendored Symlink
+1
View File
@@ -0,0 +1 @@
../@mapbox/node-pre-gyp/bin/node-pre-gyp
Generated Vendored Symlink
+1
View File
@@ -0,0 +1 @@
../nopt/bin/nopt.js
Generated Vendored Symlink
+1
View File
@@ -0,0 +1 @@
../rimraf/bin.js
Generated Vendored Symlink
+1
View File
@@ -0,0 +1 @@
../semver/bin/semver.js
+1415
View File
File diff suppressed because it is too large Load Diff
+190
View File
@@ -0,0 +1,190 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
Copyright 2021 Vlad Frangu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+33
View File
@@ -0,0 +1,33 @@
<div align="center">
<br />
<p>
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
</p>
<br />
<p>
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
<a href="https://github.com/discordjs/builders/actions"><img src="https://github.com/discordjs/builders/workflows/Tests/badge.svg" alt="Test status" /></a>
<a href="https://github.com/discordjs/builders/actions"><img src="https://github.com/discordjs/builders/workflows/Lint/badge.svg" alt="Lint status" /></a>
<a href="https://codecov.io/gh/discordjs/builders"><img src="https://codecov.io/gh/discordjs/builders/branch/main/graph/badge.svg" alt="Code coverage" /></a>
</p>
</div>
## Installation
Install with [npm](https://www.npmjs.com/) / [yarn](https://yarnpkg.com) / [pnpm](https://pnpm.js.org/):
```sh
npm install @discordjs/builders
yarn add @discordjs/builders
pnpm add @discordjs/builders
```
## Contribution
See [Contributing Guide](https://github.com/discordjs/builders/blob/main/.github/CONTRIBUTING.md).
## Examples
Here are some examples for the builders and utilities you can find in this package:
- [Slash Command Builders](./docs/examples/Slash%20Command%20Builders.md)
+15
View File
@@ -0,0 +1,15 @@
export * as EmbedAssertions from './messages/embed/Assertions';
export * from './messages/embed/Embed';
export * from './messages/formatters';
export * as SlashCommandAssertions from './interactions/slashCommands/Assertions';
export * from './interactions/slashCommands/SlashCommandBuilder';
export * from './interactions/slashCommands/SlashCommandSubcommands';
export * from './interactions/slashCommands/options/boolean';
export * from './interactions/slashCommands/options/channel';
export * from './interactions/slashCommands/options/integer';
export * from './interactions/slashCommands/options/mentionable';
export * from './interactions/slashCommands/options/number';
export * from './interactions/slashCommands/options/role';
export * from './interactions/slashCommands/options/string';
export * from './interactions/slashCommands/options/user';
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAC/D,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AAEtC,OAAO,KAAK,sBAAsB,MAAM,yCAAyC,CAAC;AAClF,cAAc,kDAAkD,CAAC;AACjE,cAAc,sDAAsD,CAAC;AACrE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,kDAAkD,CAAC;AACjE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2CAA2C,CAAC"}
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandAssertions = exports.EmbedAssertions = void 0;
const tslib_1 = require("tslib");
exports.EmbedAssertions = tslib_1.__importStar(require("./messages/embed/Assertions"));
tslib_1.__exportStar(require("./messages/embed/Embed"), exports);
tslib_1.__exportStar(require("./messages/formatters"), exports);
exports.SlashCommandAssertions = tslib_1.__importStar(require("./interactions/slashCommands/Assertions"));
tslib_1.__exportStar(require("./interactions/slashCommands/SlashCommandBuilder"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/SlashCommandSubcommands"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/options/boolean"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/options/channel"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/options/integer"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/options/mentionable"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/options/number"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/options/role"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/options/string"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/options/user"), exports);
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;AAAA,uFAA+D;AAC/D,iEAAuC;AACvC,gEAAsC;AAEtC,0GAAkF;AAClF,2FAAiE;AACjE,+FAAqE;AACrE,uFAA6D;AAC7D,uFAA6D;AAC7D,uFAA6D;AAC7D,2FAAiE;AACjE,sFAA4D;AAC5D,oFAA0D;AAC1D,sFAA4D;AAC5D,oFAA0D","sourcesContent":["export * as EmbedAssertions from './messages/embed/Assertions';\nexport * from './messages/embed/Embed';\nexport * from './messages/formatters';\n\nexport * as SlashCommandAssertions from './interactions/slashCommands/Assertions';\nexport * from './interactions/slashCommands/SlashCommandBuilder';\nexport * from './interactions/slashCommands/SlashCommandSubcommands';\nexport * from './interactions/slashCommands/options/boolean';\nexport * from './interactions/slashCommands/options/channel';\nexport * from './interactions/slashCommands/options/integer';\nexport * from './interactions/slashCommands/options/mentionable';\nexport * from './interactions/slashCommands/options/number';\nexport * from './interactions/slashCommands/options/role';\nexport * from './interactions/slashCommands/options/string';\nexport * from './interactions/slashCommands/options/user';\n"]}
+36
View File
@@ -0,0 +1,36 @@
import mod from "./index.js";
export default mod;
export const Embed = mod.Embed;
export const EmbedAssertions = mod.EmbedAssertions;
export const Faces = mod.Faces;
export const SlashCommandAssertions = mod.SlashCommandAssertions;
export const SlashCommandBooleanOption = mod.SlashCommandBooleanOption;
export const SlashCommandBuilder = mod.SlashCommandBuilder;
export const SlashCommandChannelOption = mod.SlashCommandChannelOption;
export const SlashCommandIntegerOption = mod.SlashCommandIntegerOption;
export const SlashCommandMentionableOption = mod.SlashCommandMentionableOption;
export const SlashCommandNumberOption = mod.SlashCommandNumberOption;
export const SlashCommandRoleOption = mod.SlashCommandRoleOption;
export const SlashCommandStringOption = mod.SlashCommandStringOption;
export const SlashCommandSubcommandBuilder = mod.SlashCommandSubcommandBuilder;
export const SlashCommandSubcommandGroupBuilder = mod.SlashCommandSubcommandGroupBuilder;
export const SlashCommandUserOption = mod.SlashCommandUserOption;
export const TimestampStyles = mod.TimestampStyles;
export const blockQuote = mod.blockQuote;
export const bold = mod.bold;
export const channelMention = mod.channelMention;
export const codeBlock = mod.codeBlock;
export const formatEmoji = mod.formatEmoji;
export const hideLinkEmbed = mod.hideLinkEmbed;
export const hyperlink = mod.hyperlink;
export const inlineCode = mod.inlineCode;
export const italic = mod.italic;
export const memberNicknameMention = mod.memberNicknameMention;
export const quote = mod.quote;
export const roleMention = mod.roleMention;
export const spoiler = mod.spoiler;
export const strikethrough = mod.strikethrough;
export const time = mod.time;
export const underscore = mod.underscore;
export const userMention = mod.userMention;
@@ -0,0 +1,12 @@
import type { APIApplicationCommandOptionChoice } from 'discord-api-types/v9';
import type { SlashCommandOptionBase } from './mixins/CommandOptionBase';
import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';
import type { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';
export declare function validateRequiredParameters(name: string, description: string, options: ToAPIApplicationCommandOptions[]): void;
export declare function validateName(name: unknown): asserts name is string;
export declare function validateDescription(description: unknown): asserts description is string;
export declare function validateDefaultPermission(value: unknown): asserts value is boolean;
export declare function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[];
export declare function validateMaxChoicesLength(choices: APIApplicationCommandOptionChoice[]): void;
export declare function assertReturnOfBuilder<T extends SlashCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
//# sourceMappingURL=Assertions.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"Assertions.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/Assertions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,6BAA6B,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAEnH,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,8BAA8B,EAAE,QAUzC;AAUD,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAElE;AAID,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,IAAI,MAAM,CAEvF;AAID,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAElF;AAID,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,8BAA8B,EAAE,CAE9G;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,iCAAiC,EAAE,QAEpF;AAED,wBAAgB,qBAAqB,CACpC,CAAC,SAAS,sBAAsB,GAAG,6BAA6B,GAAG,kCAAkC,EACpG,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,CAuBrE"}
@@ -0,0 +1,63 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertReturnOfBuilder = exports.validateMaxChoicesLength = exports.validateMaxOptionsLength = exports.validateDefaultPermission = exports.validateDescription = exports.validateName = exports.validateRequiredParameters = void 0;
const tslib_1 = require("tslib");
const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
const ow_1 = tslib_1.__importDefault(require("ow"));
function validateRequiredParameters(name, description, options) {
// Assert name matches all conditions
validateName(name);
// Assert description conditions
validateDescription(description);
// Assert options conditions
validateMaxOptionsLength(options);
}
exports.validateRequiredParameters = validateRequiredParameters;
const namePredicate = ow_1.default.string.lowercase
.minLength(1)
.maxLength(32)
.addValidator({
message: (value, label) => `Expected ${label} to match "^[\\p{L}\\p{N}_-]+$", got ${value} instead`,
validator: (value) => /^[\p{L}\p{N}_-]+$/u.test(value),
});
function validateName(name) {
ow_1.default(name, 'name', namePredicate);
}
exports.validateName = validateName;
const descriptionPredicate = ow_1.default.string.minLength(1).maxLength(100);
function validateDescription(description) {
ow_1.default(description, 'description', descriptionPredicate);
}
exports.validateDescription = validateDescription;
const defaultPermissionPredicate = ow_1.default.boolean;
function validateDefaultPermission(value) {
ow_1.default(value, 'default_permission', defaultPermissionPredicate);
}
exports.validateDefaultPermission = validateDefaultPermission;
const maxArrayLengthPredicate = ow_1.default.array.maxLength(25);
function validateMaxOptionsLength(options) {
ow_1.default(options, 'options', maxArrayLengthPredicate);
}
exports.validateMaxOptionsLength = validateMaxOptionsLength;
function validateMaxChoicesLength(choices) {
ow_1.default(choices, 'choices', maxArrayLengthPredicate);
}
exports.validateMaxChoicesLength = validateMaxChoicesLength;
function assertReturnOfBuilder(input, ExpectedInstanceOf) {
const instanceName = ExpectedInstanceOf.name;
if (is_1.default.nullOrUndefined(input)) {
throw new TypeError(`Expected to receive a ${instanceName} builder, got ${input === null ? 'null' : 'undefined'} instead.`);
}
if (is_1.default.primitive(input)) {
throw new TypeError(`Expected to receive a ${instanceName} builder, got a primitive (${typeof input}) instead.`);
}
if (!(input instanceof ExpectedInstanceOf)) {
const casted = input;
const constructorName = is_1.default.function_(input) ? input.name : casted.constructor.name;
const stringTag = Reflect.get(casted, Symbol.toStringTag);
const fullResultName = stringTag ? `${constructorName} [${stringTag}]` : constructorName;
throw new TypeError(`Expected to receive a ${instanceName} builder, got ${fullResultName} instead.`);
}
}
exports.assertReturnOfBuilder = assertReturnOfBuilder;
//# sourceMappingURL=Assertions.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,63 @@
import type { APIApplicationCommandOption } from 'discord-api-types/v9';
import { SharedSlashCommandOptions } from './mixins/CommandOptions';
import { SharedNameAndDescription } from './mixins/NameAndDescription';
import { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';
export declare class SlashCommandBuilder {
/**
* The name of this slash command
*/
readonly name: string;
/**
* The description of this slash command
*/
readonly description: string;
/**
* The options of this slash command
*/
readonly options: ToAPIApplicationCommandOptions[];
/**
* Whether the command is enabled by default when the app is added to a guild
* @default true
*/
readonly defaultPermission: boolean | undefined;
/**
* Returns the final data that should be sent to Discord.
*
* **Note:** Calling this function will validate required properties based on their conditions.
*/
toJSON(): {
name: string;
description: string;
options: APIApplicationCommandOption[];
default_permission: boolean | undefined;
};
/**
* Sets whether the command is enabled by default when the application is added to a guild.
*
* **Note**: If set to `false`, you will have to later have to `PUT` the permissions for this command.
* @param value Whether or not to enable this command by default
*
* @see https://discord.com/developers/docs/interactions/slash-commands#permissions
*/
setDefaultPermission(value: boolean): this;
/**
* Adds a new subcommand group to this command
* @param input A function that returns a subcommand group builder, or an already built builder
*/
addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
/**
* Adds a new subcommand to this command
* @param input A function that returns a subcommand builder, or an already built builder
*/
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
}
export interface SlashCommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {
}
export interface SlashCommandSubcommandsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'toJSON' | 'addSubcommand' | 'addSubcommandGroup'> {
}
export interface SlashCommandOptionsOnlyBuilder extends SharedNameAndDescription, SharedSlashCommandOptions, Pick<SlashCommandBuilder, 'toJSON'> {
}
export interface ToAPIApplicationCommandOptions {
toJSON(): APIApplicationCommandOption;
}
//# sourceMappingURL=SlashCommandBuilder.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"SlashCommandBuilder.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/SlashCommandBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAQxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,6BAA6B,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAE9G,qBACa,mBAAmB;IAC/B;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAc;IAE1C;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAc;IAEjD;;OAEG;IACH,SAAgB,OAAO,EAAE,8BAA8B,EAAE,CAAM;IAE/D;;;OAGG;IACH,SAAgB,iBAAiB,EAAE,OAAO,GAAG,SAAS,CAAa;IAEnE;;;;OAIG;IACI,MAAM;;;;;;IAUb;;;;;;;OAOG;IACI,oBAAoB,CAAC,KAAK,EAAE,OAAO;IAS1C;;;OAGG;IACI,kBAAkB,CACxB,KAAK,EACF,kCAAkC,GAClC,CAAC,CAAC,eAAe,EAAE,kCAAkC,KAAK,kCAAkC,CAAC,GAC9F,kCAAkC;IAiBrC;;;OAGG;IACI,aAAa,CACnB,KAAK,EACF,6BAA6B,GAC7B,CAAC,CAAC,eAAe,EAAE,6BAA6B,KAAK,6BAA6B,CAAC,GACpF,kCAAkC;CAgBrC;AAED,MAAM,WAAW,mBAAoB,SAAQ,wBAAwB,EAAE,yBAAyB;CAAG;AAEnG,MAAM,WAAW,kCAChB,SAAQ,wBAAwB,EAC/B,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,eAAe,GAAG,oBAAoB,CAAC;CAAG;AAEjF,MAAM,WAAW,8BAChB,SAAQ,wBAAwB,EAC/B,yBAAyB,EACzB,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC;CAAG;AAExC,MAAM,WAAW,8BAA8B;IAC9C,MAAM,IAAI,2BAA2B,CAAC;CACtC"}
@@ -0,0 +1,113 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandBuilder = void 0;
const tslib_1 = require("tslib");
const ts_mixer_1 = require("ts-mixer");
const Assertions_1 = require("./Assertions");
const CommandOptions_1 = require("./mixins/CommandOptions");
const NameAndDescription_1 = require("./mixins/NameAndDescription");
const SlashCommandSubcommands_1 = require("./SlashCommandSubcommands");
let SlashCommandBuilder = class SlashCommandBuilder {
constructor() {
/**
* The name of this slash command
*/
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: undefined
});
/**
* The description of this slash command
*/
Object.defineProperty(this, "description", {
enumerable: true,
configurable: true,
writable: true,
value: undefined
});
/**
* The options of this slash command
*/
Object.defineProperty(this, "options", {
enumerable: true,
configurable: true,
writable: true,
value: []
});
/**
* Whether the command is enabled by default when the app is added to a guild
* @default true
*/
Object.defineProperty(this, "defaultPermission", {
enumerable: true,
configurable: true,
writable: true,
value: undefined
});
}
/**
* Returns the final data that should be sent to Discord.
*
* **Note:** Calling this function will validate required properties based on their conditions.
*/
toJSON() {
Assertions_1.validateRequiredParameters(this.name, this.description, this.options);
return {
name: this.name,
description: this.description,
options: this.options.map((option) => option.toJSON()),
default_permission: this.defaultPermission,
};
}
/**
* Sets whether the command is enabled by default when the application is added to a guild.
*
* **Note**: If set to `false`, you will have to later have to `PUT` the permissions for this command.
* @param value Whether or not to enable this command by default
*
* @see https://discord.com/developers/docs/interactions/slash-commands#permissions
*/
setDefaultPermission(value) {
// Assert the value matches the conditions
Assertions_1.validateDefaultPermission(value);
Reflect.set(this, 'defaultPermission', value);
return this;
}
/**
* Adds a new subcommand group to this command
* @param input A function that returns a subcommand group builder, or an already built builder
*/
addSubcommandGroup(input) {
const { options } = this;
// First, assert options conditions - we cannot have more than 25 options
Assertions_1.validateMaxOptionsLength(options);
// Get the final result
const result = typeof input === 'function' ? input(new SlashCommandSubcommands_1.SlashCommandSubcommandGroupBuilder()) : input;
Assertions_1.assertReturnOfBuilder(result, SlashCommandSubcommands_1.SlashCommandSubcommandGroupBuilder);
// Push it
options.push(result);
return this;
}
/**
* Adds a new subcommand to this command
* @param input A function that returns a subcommand builder, or an already built builder
*/
addSubcommand(input) {
const { options } = this;
// First, assert options conditions - we cannot have more than 25 options
Assertions_1.validateMaxOptionsLength(options);
// Get the final result
const result = typeof input === 'function' ? input(new SlashCommandSubcommands_1.SlashCommandSubcommandBuilder()) : input;
Assertions_1.assertReturnOfBuilder(result, SlashCommandSubcommands_1.SlashCommandSubcommandBuilder);
// Push it
options.push(result);
return this;
}
};
SlashCommandBuilder = tslib_1.__decorate([
ts_mixer_1.mix(CommandOptions_1.SharedSlashCommandOptions, NameAndDescription_1.SharedNameAndDescription)
], SlashCommandBuilder);
exports.SlashCommandBuilder = SlashCommandBuilder;
//# sourceMappingURL=SlashCommandBuilder.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,64 @@
import { ApplicationCommandOptionType } from 'discord-api-types/v9';
import { SharedSlashCommandOptions } from './mixins/CommandOptions';
import { SharedNameAndDescription } from './mixins/NameAndDescription';
import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';
/**
* Represents a folder for subcommands
*
* For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups
*/
export declare class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationCommandOptions {
/**
* The name of this subcommand group
*/
readonly name: string;
/**
* The description of this subcommand group
*/
readonly description: string;
/**
* The subcommands part of this subcommand group
*/
readonly options: ToAPIApplicationCommandOptions[];
/**
* Adds a new subcommand to this group
* @param input A function that returns a subcommand builder, or an already built builder
*/
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): this;
toJSON(): {
type: ApplicationCommandOptionType;
name: string;
description: string;
options: import("discord-api-types/v9").APIApplicationCommandOption[];
};
}
export interface SlashCommandSubcommandGroupBuilder extends SharedNameAndDescription {
}
/**
* Represents a subcommand
*
* For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups
*/
export declare class SlashCommandSubcommandBuilder implements ToAPIApplicationCommandOptions {
/**
* The name of this subcommand
*/
readonly name: string;
/**
* The description of this subcommand
*/
readonly description: string;
/**
* The options of this subcommand
*/
readonly options: ToAPIApplicationCommandOptions[];
toJSON(): {
type: ApplicationCommandOptionType;
name: string;
description: string;
options: import("discord-api-types/v9").APIApplicationCommandOption[];
};
}
export interface SlashCommandSubcommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions<false> {
}
//# sourceMappingURL=SlashCommandSubcommands.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"SlashCommandSubcommands.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/SlashCommandSubcommands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAE5E;;;;GAIG;AACH,qBACa,kCAAmC,YAAW,8BAA8B;IACxF;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAc;IAE1C;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAc;IAEjD;;OAEG;IACH,SAAgB,OAAO,EAAE,8BAA8B,EAAE,CAAM;IAE/D;;;OAGG;IACI,aAAa,CACnB,KAAK,EACF,6BAA6B,GAC7B,CAAC,CAAC,eAAe,EAAE,6BAA6B,KAAK,6BAA6B,CAAC;IAkBhF,MAAM;;;;;;CASb;AAED,MAAM,WAAW,kCAAmC,SAAQ,wBAAwB;CAAG;AAEvF;;;;GAIG;AACH,qBACa,6BAA8B,YAAW,8BAA8B;IACnF;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAc;IAE1C;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAc;IAEjD;;OAEG;IACH,SAAgB,OAAO,EAAE,8BAA8B,EAAE,CAAM;IAExD,MAAM;;;;;;CASb;AAED,MAAM,WAAW,6BAA8B,SAAQ,wBAAwB,EAAE,yBAAyB,CAAC,KAAK,CAAC;CAAG"}
@@ -0,0 +1,123 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandSubcommandBuilder = exports.SlashCommandSubcommandGroupBuilder = void 0;
const tslib_1 = require("tslib");
require("discord-api-types/v9");
const ts_mixer_1 = require("ts-mixer");
const Assertions_1 = require("./Assertions");
const CommandOptions_1 = require("./mixins/CommandOptions");
const NameAndDescription_1 = require("./mixins/NameAndDescription");
/**
* Represents a folder for subcommands
*
* For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups
*/
let SlashCommandSubcommandGroupBuilder = class SlashCommandSubcommandGroupBuilder {
constructor() {
/**
* The name of this subcommand group
*/
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: undefined
});
/**
* The description of this subcommand group
*/
Object.defineProperty(this, "description", {
enumerable: true,
configurable: true,
writable: true,
value: undefined
});
/**
* The subcommands part of this subcommand group
*/
Object.defineProperty(this, "options", {
enumerable: true,
configurable: true,
writable: true,
value: []
});
}
/**
* Adds a new subcommand to this group
* @param input A function that returns a subcommand builder, or an already built builder
*/
addSubcommand(input) {
const { options } = this;
// First, assert options conditions - we cannot have more than 25 options
Assertions_1.validateMaxOptionsLength(options);
// Get the final result
const result = typeof input === 'function' ? input(new SlashCommandSubcommandBuilder()) : input;
Assertions_1.assertReturnOfBuilder(result, SlashCommandSubcommandBuilder);
// Push it
options.push(result);
return this;
}
toJSON() {
Assertions_1.validateRequiredParameters(this.name, this.description, this.options);
return {
type: 2 /* SubcommandGroup */,
name: this.name,
description: this.description,
options: this.options.map((option) => option.toJSON()),
};
}
};
SlashCommandSubcommandGroupBuilder = tslib_1.__decorate([
ts_mixer_1.mix(NameAndDescription_1.SharedNameAndDescription)
], SlashCommandSubcommandGroupBuilder);
exports.SlashCommandSubcommandGroupBuilder = SlashCommandSubcommandGroupBuilder;
/**
* Represents a subcommand
*
* For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups
*/
let SlashCommandSubcommandBuilder = class SlashCommandSubcommandBuilder {
constructor() {
/**
* The name of this subcommand
*/
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: undefined
});
/**
* The description of this subcommand
*/
Object.defineProperty(this, "description", {
enumerable: true,
configurable: true,
writable: true,
value: undefined
});
/**
* The options of this subcommand
*/
Object.defineProperty(this, "options", {
enumerable: true,
configurable: true,
writable: true,
value: []
});
}
toJSON() {
Assertions_1.validateRequiredParameters(this.name, this.description, this.options);
return {
type: 1 /* Subcommand */,
name: this.name,
description: this.description,
options: this.options.map((option) => option.toJSON()),
};
}
};
SlashCommandSubcommandBuilder = tslib_1.__decorate([
ts_mixer_1.mix(NameAndDescription_1.SharedNameAndDescription, CommandOptions_1.SharedSlashCommandOptions)
], SlashCommandSubcommandBuilder);
exports.SlashCommandSubcommandBuilder = SlashCommandSubcommandBuilder;
//# sourceMappingURL=SlashCommandSubcommands.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,20 @@
import type { ApplicationCommandOptionType } from 'discord-api-types/v9';
import type { ToAPIApplicationCommandOptions } from '../SlashCommandBuilder';
import { SharedNameAndDescription } from './NameAndDescription';
export declare class SlashCommandOptionBase extends SharedNameAndDescription implements ToAPIApplicationCommandOptions {
required: boolean;
readonly type: ApplicationCommandOptionType;
constructor(type: ApplicationCommandOptionType);
/**
* Marks the option as required
* @param required If this option should be required
*/
setRequired(required: boolean): this;
toJSON(): {
type: ApplicationCommandOptionType;
name: string;
description: string;
required: boolean;
};
}
//# sourceMappingURL=CommandOptionBase.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"CommandOptionBase.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/mixins/CommandOptionBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGzE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,qBAAa,sBAAuB,SAAQ,wBAAyB,YAAW,8BAA8B;IACtG,QAAQ,UAAS;IACxB,SAAgB,IAAI,EAAE,4BAA4B,CAAC;gBAEhC,IAAI,EAAE,4BAA4B;IAKrD;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,OAAO;IAS7B,MAAM;;;;;;CAab"}
@@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandOptionBase = void 0;
const tslib_1 = require("tslib");
const ow_1 = tslib_1.__importDefault(require("ow"));
const Assertions_1 = require("../Assertions");
const NameAndDescription_1 = require("./NameAndDescription");
class SlashCommandOptionBase extends NameAndDescription_1.SharedNameAndDescription {
constructor(type) {
super();
Object.defineProperty(this, "required", {
enumerable: true,
configurable: true,
writable: true,
value: false
});
Object.defineProperty(this, "type", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.type = type;
}
/**
* Marks the option as required
* @param required If this option should be required
*/
setRequired(required) {
// Assert that you actually passed a boolean
ow_1.default(required, 'required', ow_1.default.boolean);
this.required = required;
return this;
}
toJSON() {
Assertions_1.validateRequiredParameters(this.name, this.description, []);
// Assert that you actually passed a boolean
ow_1.default(this.required, 'required', ow_1.default.boolean);
return {
type: this.type,
name: this.name,
description: this.description,
required: this.required,
};
}
}
exports.SlashCommandOptionBase = SlashCommandOptionBase;
//# sourceMappingURL=CommandOptionBase.js.map
@@ -0,0 +1 @@
{"version":3,"file":"CommandOptionBase.js","sourceRoot":"/","sources":["interactions/slashCommands/mixins/CommandOptionBase.ts"],"names":[],"mappings":";;;;AACA,oDAAoB;AACpB,8CAA2D;AAE3D,6DAAgE;AAEhE,MAAa,sBAAuB,SAAQ,6CAAwB;IAInE,YAAmB,IAAkC;QACpD,KAAK,EAAE,CAAC;QAJT;;;;mBAAkB,KAAK;WAAC;QACxB;;;;;WAAmD;QAIlD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,QAAiB;QACnC,4CAA4C;QAC5C,YAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,YAAE,CAAC,OAAO,CAAC,CAAC;QAErC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,MAAM;QACZ,uCAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAE5D,4CAA4C;QAC5C,YAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,YAAE,CAAC,OAAO,CAAC,CAAC;QAE1C,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC;IACH,CAAC;CACD;AAnCD,wDAmCC","sourcesContent":["import type { ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport ow from 'ow';\nimport { validateRequiredParameters } from '../Assertions';\nimport type { ToAPIApplicationCommandOptions } from '../SlashCommandBuilder';\nimport { SharedNameAndDescription } from './NameAndDescription';\n\nexport class SlashCommandOptionBase extends SharedNameAndDescription implements ToAPIApplicationCommandOptions {\n\tpublic required = false;\n\tpublic readonly type: ApplicationCommandOptionType;\n\n\tpublic constructor(type: ApplicationCommandOptionType) {\n\t\tsuper();\n\t\tthis.type = type;\n\t}\n\n\t/**\n\t * Marks the option as required\n\t * @param required If this option should be required\n\t */\n\tpublic setRequired(required: boolean) {\n\t\t// Assert that you actually passed a boolean\n\t\tow(required, 'required', ow.boolean);\n\n\t\tthis.required = required;\n\n\t\treturn this;\n\t}\n\n\tpublic toJSON() {\n\t\tvalidateRequiredParameters(this.name, this.description, []);\n\n\t\t// Assert that you actually passed a boolean\n\t\tow(this.required, 'required', ow.boolean);\n\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tname: this.name,\n\t\t\tdescription: this.description,\n\t\t\trequired: this.required,\n\t\t};\n\t}\n}\n"]}
@@ -0,0 +1,25 @@
import { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from 'discord-api-types/v9';
import type { ToAPIApplicationCommandOptions } from '../SlashCommandBuilder';
import { SlashCommandOptionBase } from './CommandOptionBase';
export declare abstract class ApplicationCommandOptionWithChoicesBase<T extends string | number> extends SlashCommandOptionBase implements ToAPIApplicationCommandOptions {
choices?: APIApplicationCommandOptionChoice[];
/**
* Adds a choice for this option
* @param name The name of the choice
* @param value The value of the choice
*/
addChoice(name: string, value: T): this;
/**
* Adds multiple choices for this option
* @param choices The choices to add
*/
addChoices(choices: [name: string, value: T][]): this;
toJSON(): {
choices: APIApplicationCommandOptionChoice[] | undefined;
type: ApplicationCommandOptionType;
name: string;
description: string;
required: boolean;
};
}
//# sourceMappingURL=CommandOptionWithChoices.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"CommandOptionWithChoices.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/mixins/CommandOptionWithChoices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGvG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAU7D,8BAAsB,uCAAuC,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CACtF,SAAQ,sBACR,YAAW,8BAA8B;IAElC,OAAO,CAAC,EAAE,iCAAiC,EAAE,CAAC;IAErD;;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAiBvC;;;OAGG;IACI,UAAU,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE;IAOrC,MAAM;;;;;;;CAMtB"}
@@ -0,0 +1,71 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApplicationCommandOptionWithChoicesBase = void 0;
const tslib_1 = require("tslib");
require("discord-api-types/v9");
const ow_1 = tslib_1.__importDefault(require("ow"));
const Assertions_1 = require("../Assertions");
const CommandOptionBase_1 = require("./CommandOptionBase");
const stringPredicate = ow_1.default.string.minLength(1).maxLength(100);
const integerPredicate = ow_1.default.number.finite;
// TODO: See resolution for sindresorhus/ow#217 in relation to this cast
const choicesPredicate = ow_1.default.array.ofType(ow_1.default.array.exactShape([stringPredicate, ow_1.default.any(ow_1.default.string, integerPredicate)]));
class ApplicationCommandOptionWithChoicesBase extends CommandOptionBase_1.SlashCommandOptionBase {
constructor() {
super(...arguments);
Object.defineProperty(this, "choices", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
}
/**
* Adds a choice for this option
* @param name The name of the choice
* @param value The value of the choice
*/
addChoice(name, value) {
this.choices ?? (this.choices = []);
Assertions_1.validateMaxChoicesLength(this.choices);
// Validate name
ow_1.default(name, `${ApplicationCommandOptionTypeNames[this.type]} choice name`, stringPredicate);
// Validate the value
if (this.type === 3 /* String */)
ow_1.default(value, 'string choice value', stringPredicate);
else
ow_1.default(value, `${ApplicationCommandOptionTypeNames[this.type]} choice value`, integerPredicate);
this.choices.push({ name, value });
return this;
}
/**
* Adds multiple choices for this option
* @param choices The choices to add
*/
addChoices(choices) {
ow_1.default(choices, `${ApplicationCommandOptionTypeNames[this.type]} choices`, choicesPredicate);
for (const [label, value] of choices)
this.addChoice(label, value);
return this;
}
toJSON() {
return {
...super.toJSON(),
choices: this.choices,
};
}
}
exports.ApplicationCommandOptionWithChoicesBase = ApplicationCommandOptionWithChoicesBase;
const ApplicationCommandOptionTypeNames = {
[1 /* Subcommand */]: 'subcommand',
[2 /* SubcommandGroup */]: 'subcommand group',
[3 /* String */]: 'string',
[4 /* Integer */]: 'integer',
[5 /* Boolean */]: 'boolean',
[6 /* User */]: 'user',
[7 /* Channel */]: 'channel',
[8 /* Role */]: 'role',
[9 /* Mentionable */]: 'mentionable',
[10 /* Number */]: 'number',
};
//# sourceMappingURL=CommandOptionWithChoices.js.map
@@ -0,0 +1 @@
{"version":3,"file":"CommandOptionWithChoices.js","sourceRoot":"/","sources":["interactions/slashCommands/mixins/CommandOptionWithChoices.ts"],"names":[],"mappings":";;;;AAAA,gCAAuG;AACvG,oDAAmC;AACnC,8CAAyD;AAEzD,2DAA6D;AAE7D,MAAM,eAAe,GAAG,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAC9D,MAAM,gBAAgB,GAAG,YAAE,CAAC,MAAM,CAAC,MAAM,CAAC;AAE1C,wEAAwE;AACxE,MAAM,gBAAgB,GAAG,YAAE,CAAC,KAAK,CAAC,MAAM,CACvC,YAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,eAAe,EAAE,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,EAAE,gBAAgB,CAA0C,CAAC,CAAC,CACpH,CAAC;AAEF,MAAsB,uCACrB,SAAQ,0CAAsB;IAD/B;;QAIC;;;;;WAAqD;IAyCtD,CAAC;IAvCA;;;;OAIG;IACI,SAAS,CAAC,IAAY,EAAE,KAAQ;QACtC,IAAI,CAAC,OAAO,KAAZ,IAAI,CAAC,OAAO,GAAK,EAAE,EAAC;QAEpB,qCAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEvC,gBAAgB;QAChB,YAAE,CAAC,IAAI,EAAE,GAAG,iCAAiC,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;QAEzF,qBAAqB;QACrB,IAAI,IAAI,CAAC,IAAI,mBAAwC;YAAE,YAAE,CAAC,KAAK,EAAE,qBAAqB,EAAE,eAAe,CAAC,CAAC;;YACpG,YAAE,CAAC,KAAK,EAAE,GAAG,iCAAiC,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;QAEjG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAEnC,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,UAAU,CAAC,OAAmC;QACpD,YAAE,CAAC,OAAO,EAAE,GAAG,iCAAiC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;QAEzF,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,OAAO;YAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;IACb,CAAC;IAEe,MAAM;QACrB,OAAO;YACN,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC;IACH,CAAC;CACD;AA7CD,0FA6CC;AAED,MAAM,iCAAiC,GAAG;IACzC,oBAAyC,EAAE,YAAY;IACvD,yBAA8C,EAAE,kBAAkB;IAClE,gBAAqC,EAAE,QAAQ;IAC/C,iBAAsC,EAAE,SAAS;IACjD,iBAAsC,EAAE,SAAS;IACjD,cAAmC,EAAE,MAAM;IAC3C,iBAAsC,EAAE,SAAS;IACjD,cAAmC,EAAE,MAAM;IAC3C,qBAA0C,EAAE,aAAa;IACzD,iBAAqC,EAAE,QAAQ;CACtC,CAAC","sourcesContent":["import { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport ow, { Predicate } from 'ow';\nimport { validateMaxChoicesLength } from '../Assertions';\nimport type { ToAPIApplicationCommandOptions } from '../SlashCommandBuilder';\nimport { SlashCommandOptionBase } from './CommandOptionBase';\n\nconst stringPredicate = ow.string.minLength(1).maxLength(100);\nconst integerPredicate = ow.number.finite;\n\n// TODO: See resolution for sindresorhus/ow#217 in relation to this cast\nconst choicesPredicate = ow.array.ofType<[string, string | number]>(\n\tow.array.exactShape([stringPredicate, ow.any(ow.string, integerPredicate) as unknown as Predicate<string | number>]),\n);\n\nexport abstract class ApplicationCommandOptionWithChoicesBase<T extends string | number>\n\textends SlashCommandOptionBase\n\timplements ToAPIApplicationCommandOptions\n{\n\tpublic choices?: APIApplicationCommandOptionChoice[];\n\n\t/**\n\t * Adds a choice for this option\n\t * @param name The name of the choice\n\t * @param value The value of the choice\n\t */\n\tpublic addChoice(name: string, value: T) {\n\t\tthis.choices ??= [];\n\n\t\tvalidateMaxChoicesLength(this.choices);\n\n\t\t// Validate name\n\t\tow(name, `${ApplicationCommandOptionTypeNames[this.type]} choice name`, stringPredicate);\n\n\t\t// Validate the value\n\t\tif (this.type === ApplicationCommandOptionType.String) ow(value, 'string choice value', stringPredicate);\n\t\telse ow(value, `${ApplicationCommandOptionTypeNames[this.type]} choice value`, integerPredicate);\n\n\t\tthis.choices.push({ name, value });\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds multiple choices for this option\n\t * @param choices The choices to add\n\t */\n\tpublic addChoices(choices: [name: string, value: T][]) {\n\t\tow(choices, `${ApplicationCommandOptionTypeNames[this.type]} choices`, choicesPredicate);\n\n\t\tfor (const [label, value] of choices) this.addChoice(label, value);\n\t\treturn this;\n\t}\n\n\tpublic override toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\tchoices: this.choices,\n\t\t};\n\t}\n}\n\nconst ApplicationCommandOptionTypeNames = {\n\t[ApplicationCommandOptionType.Subcommand]: 'subcommand',\n\t[ApplicationCommandOptionType.SubcommandGroup]: 'subcommand group',\n\t[ApplicationCommandOptionType.String]: 'string',\n\t[ApplicationCommandOptionType.Integer]: 'integer',\n\t[ApplicationCommandOptionType.Boolean]: 'boolean',\n\t[ApplicationCommandOptionType.User]: 'user',\n\t[ApplicationCommandOptionType.Channel]: 'channel',\n\t[ApplicationCommandOptionType.Role]: 'role',\n\t[ApplicationCommandOptionType.Mentionable]: 'mentionable',\n\t[ApplicationCommandOptionType.Number]: 'number',\n} as const;\n"]}
@@ -0,0 +1,54 @@
import { SlashCommandBooleanOption } from '../options/boolean';
import { SlashCommandChannelOption } from '../options/channel';
import { SlashCommandIntegerOption } from '../options/integer';
import { SlashCommandMentionableOption } from '../options/mentionable';
import { SlashCommandNumberOption } from '../options/number';
import { SlashCommandRoleOption } from '../options/role';
import { SlashCommandStringOption } from '../options/string';
import { SlashCommandUserOption } from '../options/user';
import type { ToAPIApplicationCommandOptions } from '../SlashCommandBuilder';
export declare class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
readonly options: ToAPIApplicationCommandOptions[];
/**
* Adds a boolean option
* @param input A function that returns an option builder, or an already built builder
*/
addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**
* Adds a user option
* @param input A function that returns an option builder, or an already built builder
*/
addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**
* Adds a channel option
* @param input A function that returns an option builder, or an already built builder
*/
addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**
* Adds a role option
* @param input A function that returns an option builder, or an already built builder
*/
addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**
* Adds a mentionable option
* @param input A function that returns an option builder, or an already built builder
*/
addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**
* Adds a string option
* @param input A function that returns an option builder, or an already built builder
*/
addStringOption(input: SlashCommandStringOption | ((builder: SlashCommandStringOption) => SlashCommandStringOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**
* Adds an integer option
* @param input A function that returns an option builder, or an already built builder
*/
addIntegerOption(input: SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**
* Adds a number option
* @param input A function that returns an option builder, or an already built builder
*/
addNumberOption(input: SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
private _sharedAddOptionMethod;
}
//# sourceMappingURL=CommandOptions.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"CommandOptions.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/mixins/CommandOptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAE7E,qBAAa,yBAAyB,CAAC,6BAA6B,GAAG,IAAI;IAC1E,SAAgB,OAAO,EAAG,8BAA8B,EAAE,CAAC;IAE3D;;;OAGG;IACI,gBAAgB,CACtB,KAAK,EAAE,yBAAyB,GAAG,CAAC,CAAC,OAAO,EAAE,yBAAyB,KAAK,yBAAyB,CAAC;IAKvG;;;OAGG;IACI,aAAa,CAAC,KAAK,EAAE,sBAAsB,GAAG,CAAC,CAAC,OAAO,EAAE,sBAAsB,KAAK,sBAAsB,CAAC;IAIlH;;;OAGG;IACI,gBAAgB,CACtB,KAAK,EAAE,yBAAyB,GAAG,CAAC,CAAC,OAAO,EAAE,yBAAyB,KAAK,yBAAyB,CAAC;IAKvG;;;OAGG;IACI,aAAa,CAAC,KAAK,EAAE,sBAAsB,GAAG,CAAC,CAAC,OAAO,EAAE,sBAAsB,KAAK,sBAAsB,CAAC;IAIlH;;;OAGG;IACI,oBAAoB,CAC1B,KAAK,EAAE,6BAA6B,GAAG,CAAC,CAAC,OAAO,EAAE,6BAA6B,KAAK,6BAA6B,CAAC;IAKnH;;;OAGG;IACI,eAAe,CACrB,KAAK,EAAE,wBAAwB,GAAG,CAAC,CAAC,OAAO,EAAE,wBAAwB,KAAK,wBAAwB,CAAC;IAKpG;;;OAGG;IACI,gBAAgB,CACtB,KAAK,EAAE,yBAAyB,GAAG,CAAC,CAAC,OAAO,EAAE,yBAAyB,KAAK,yBAAyB,CAAC;IAKvG;;;OAGG;IACI,eAAe,CACrB,KAAK,EAAE,wBAAwB,GAAG,CAAC,CAAC,OAAO,EAAE,wBAAwB,KAAK,wBAAwB,CAAC;IAKpG,OAAO,CAAC,sBAAsB;CAmB9B"}
@@ -0,0 +1,91 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SharedSlashCommandOptions = void 0;
const Assertions_1 = require("../Assertions");
const boolean_1 = require("../options/boolean");
const channel_1 = require("../options/channel");
const integer_1 = require("../options/integer");
const mentionable_1 = require("../options/mentionable");
const number_1 = require("../options/number");
const role_1 = require("../options/role");
const string_1 = require("../options/string");
const user_1 = require("../options/user");
class SharedSlashCommandOptions {
constructor() {
Object.defineProperty(this, "options", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
}
/**
* Adds a boolean option
* @param input A function that returns an option builder, or an already built builder
*/
addBooleanOption(input) {
return this._sharedAddOptionMethod(input, boolean_1.SlashCommandBooleanOption);
}
/**
* Adds a user option
* @param input A function that returns an option builder, or an already built builder
*/
addUserOption(input) {
return this._sharedAddOptionMethod(input, user_1.SlashCommandUserOption);
}
/**
* Adds a channel option
* @param input A function that returns an option builder, or an already built builder
*/
addChannelOption(input) {
return this._sharedAddOptionMethod(input, channel_1.SlashCommandChannelOption);
}
/**
* Adds a role option
* @param input A function that returns an option builder, or an already built builder
*/
addRoleOption(input) {
return this._sharedAddOptionMethod(input, role_1.SlashCommandRoleOption);
}
/**
* Adds a mentionable option
* @param input A function that returns an option builder, or an already built builder
*/
addMentionableOption(input) {
return this._sharedAddOptionMethod(input, mentionable_1.SlashCommandMentionableOption);
}
/**
* Adds a string option
* @param input A function that returns an option builder, or an already built builder
*/
addStringOption(input) {
return this._sharedAddOptionMethod(input, string_1.SlashCommandStringOption);
}
/**
* Adds an integer option
* @param input A function that returns an option builder, or an already built builder
*/
addIntegerOption(input) {
return this._sharedAddOptionMethod(input, integer_1.SlashCommandIntegerOption);
}
/**
* Adds a number option
* @param input A function that returns an option builder, or an already built builder
*/
addNumberOption(input) {
return this._sharedAddOptionMethod(input, number_1.SlashCommandNumberOption);
}
_sharedAddOptionMethod(input, Instance) {
const { options } = this;
// First, assert options conditions - we cannot have more than 25 options
Assertions_1.validateMaxOptionsLength(options);
// Get the final result
const result = typeof input === 'function' ? input(new Instance()) : input;
Assertions_1.assertReturnOfBuilder(result, Instance);
// Push it
options.push(result);
return this;
}
}
exports.SharedSlashCommandOptions = SharedSlashCommandOptions;
//# sourceMappingURL=CommandOptions.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,15 @@
export declare class SharedNameAndDescription {
readonly name: string;
readonly description: string;
/**
* Sets the name
* @param name The name
*/
setName(name: string): this;
/**
* Sets the description
* @param description The description
*/
setDescription(description: string): this;
}
//# sourceMappingURL=NameAndDescription.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"NameAndDescription.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/mixins/NameAndDescription.ts"],"names":[],"mappings":"AAEA,qBAAa,wBAAwB;IACpC,SAAgB,IAAI,EAAG,MAAM,CAAC;IAC9B,SAAgB,WAAW,EAAG,MAAM,CAAC;IAErC;;;OAGG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM;IAS3B;;;OAGG;IACI,cAAc,CAAC,WAAW,EAAE,MAAM;CAQzC"}
@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SharedNameAndDescription = void 0;
const Assertions_1 = require("../Assertions");
class SharedNameAndDescription {
constructor() {
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "description", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
}
/**
* Sets the name
* @param name The name
*/
setName(name) {
// Assert the name matches the conditions
Assertions_1.validateName(name);
Reflect.set(this, 'name', name);
return this;
}
/**
* Sets the description
* @param description The description
*/
setDescription(description) {
// Assert the description matches the conditions
Assertions_1.validateDescription(description);
Reflect.set(this, 'description', description);
return this;
}
}
exports.SharedNameAndDescription = SharedNameAndDescription;
//# sourceMappingURL=NameAndDescription.js.map
@@ -0,0 +1 @@
{"version":3,"file":"NameAndDescription.js","sourceRoot":"/","sources":["interactions/slashCommands/mixins/NameAndDescription.ts"],"names":[],"mappings":";;;AAAA,8CAAkE;AAElE,MAAa,wBAAwB;IAArC;QACC;;;;;WAA8B;QAC9B;;;;;WAAqC;IA2BtC,CAAC;IAzBA;;;OAGG;IACI,OAAO,CAAC,IAAY;QAC1B,yCAAyC;QACzC,yBAAY,CAAC,IAAI,CAAC,CAAC;QAEnB,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAEhC,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,WAAmB;QACxC,gDAAgD;QAChD,gCAAmB,CAAC,WAAW,CAAC,CAAC;QAEjC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AA7BD,4DA6BC","sourcesContent":["import { validateDescription, validateName } from '../Assertions';\n\nexport class SharedNameAndDescription {\n\tpublic readonly name!: string;\n\tpublic readonly description!: string;\n\n\t/**\n\t * Sets the name\n\t * @param name The name\n\t */\n\tpublic setName(name: string) {\n\t\t// Assert the name matches the conditions\n\t\tvalidateName(name);\n\n\t\tReflect.set(this, 'name', name);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description\n\t * @param description The description\n\t */\n\tpublic setDescription(description: string) {\n\t\t// Assert the description matches the conditions\n\t\tvalidateDescription(description);\n\n\t\tReflect.set(this, 'description', description);\n\n\t\treturn this;\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
import { ApplicationCommandOptionType } from 'discord-api-types/v9';
import { SlashCommandOptionBase } from '../mixins/CommandOptionBase';
export declare class SlashCommandBooleanOption extends SlashCommandOptionBase {
readonly type: ApplicationCommandOptionType.Boolean;
constructor();
}
//# sourceMappingURL=boolean.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"boolean.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/options/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,qBAAa,yBAA0B,SAAQ,sBAAsB;IACpE,SAAyB,IAAI,uCAAiD;;CAK9E"}
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandBooleanOption = void 0;
require("discord-api-types/v9");
const CommandOptionBase_1 = require("../mixins/CommandOptionBase");
class SlashCommandBooleanOption extends CommandOptionBase_1.SlashCommandOptionBase {
constructor() {
super(5 /* Boolean */);
Object.defineProperty(this, "type", {
enumerable: true,
configurable: true,
writable: true,
value: 5 /* Boolean */
});
}
}
exports.SlashCommandBooleanOption = SlashCommandBooleanOption;
//# sourceMappingURL=boolean.js.map
@@ -0,0 +1 @@
{"version":3,"file":"boolean.js","sourceRoot":"/","sources":["interactions/slashCommands/options/boolean.ts"],"names":[],"mappings":";;;AAAA,gCAAoE;AACpE,mEAAqE;AAErE,MAAa,yBAA0B,SAAQ,0CAAsB;IAGpE;QACC,KAAK,iBAAsC,CAAC;QAH7C;;;;mBAAgC,eAA6C;WAAC;IAI9E,CAAC;CACD;AAND,8DAMC","sourcesContent":["import { ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport { SlashCommandOptionBase } from '../mixins/CommandOptionBase';\n\nexport class SlashCommandBooleanOption extends SlashCommandOptionBase {\n\tpublic override readonly type = ApplicationCommandOptionType.Boolean as const;\n\n\tpublic constructor() {\n\t\tsuper(ApplicationCommandOptionType.Boolean);\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
import { ApplicationCommandOptionType } from 'discord-api-types/v9';
import { SlashCommandOptionBase } from '../mixins/CommandOptionBase';
export declare class SlashCommandChannelOption extends SlashCommandOptionBase {
readonly type: ApplicationCommandOptionType.Channel;
constructor();
}
//# sourceMappingURL=channel.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"channel.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/options/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,qBAAa,yBAA0B,SAAQ,sBAAsB;IACpE,SAAyB,IAAI,uCAAiD;;CAK9E"}
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandChannelOption = void 0;
require("discord-api-types/v9");
const CommandOptionBase_1 = require("../mixins/CommandOptionBase");
class SlashCommandChannelOption extends CommandOptionBase_1.SlashCommandOptionBase {
constructor() {
super(7 /* Channel */);
Object.defineProperty(this, "type", {
enumerable: true,
configurable: true,
writable: true,
value: 7 /* Channel */
});
}
}
exports.SlashCommandChannelOption = SlashCommandChannelOption;
//# sourceMappingURL=channel.js.map
@@ -0,0 +1 @@
{"version":3,"file":"channel.js","sourceRoot":"/","sources":["interactions/slashCommands/options/channel.ts"],"names":[],"mappings":";;;AAAA,gCAAoE;AACpE,mEAAqE;AAErE,MAAa,yBAA0B,SAAQ,0CAAsB;IAGpE;QACC,KAAK,iBAAsC,CAAC;QAH7C;;;;mBAAgC,eAA6C;WAAC;IAI9E,CAAC;CACD;AAND,8DAMC","sourcesContent":["import { ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport { SlashCommandOptionBase } from '../mixins/CommandOptionBase';\n\nexport class SlashCommandChannelOption extends SlashCommandOptionBase {\n\tpublic override readonly type = ApplicationCommandOptionType.Channel as const;\n\n\tpublic constructor() {\n\t\tsuper(ApplicationCommandOptionType.Channel);\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
import { ApplicationCommandOptionType } from 'discord-api-types/v9';
import { ApplicationCommandOptionWithChoicesBase } from '../mixins/CommandOptionWithChoices';
export declare class SlashCommandIntegerOption extends ApplicationCommandOptionWithChoicesBase<number> {
readonly type: ApplicationCommandOptionType.Integer;
constructor();
}
//# sourceMappingURL=integer.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"integer.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/options/integer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,uCAAuC,EAAE,MAAM,oCAAoC,CAAC;AAE7F,qBAAa,yBAA0B,SAAQ,uCAAuC,CAAC,MAAM,CAAC;IAC7F,SAAyB,IAAI,uCAAiD;;CAK9E"}
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandIntegerOption = void 0;
require("discord-api-types/v9");
const CommandOptionWithChoices_1 = require("../mixins/CommandOptionWithChoices");
class SlashCommandIntegerOption extends CommandOptionWithChoices_1.ApplicationCommandOptionWithChoicesBase {
constructor() {
super(4 /* Integer */);
Object.defineProperty(this, "type", {
enumerable: true,
configurable: true,
writable: true,
value: 4 /* Integer */
});
}
}
exports.SlashCommandIntegerOption = SlashCommandIntegerOption;
//# sourceMappingURL=integer.js.map
@@ -0,0 +1 @@
{"version":3,"file":"integer.js","sourceRoot":"/","sources":["interactions/slashCommands/options/integer.ts"],"names":[],"mappings":";;;AAAA,gCAAoE;AACpE,iFAA6F;AAE7F,MAAa,yBAA0B,SAAQ,kEAA+C;IAG7F;QACC,KAAK,iBAAsC,CAAC;QAH7C;;;;mBAAgC,eAA6C;WAAC;IAI9E,CAAC;CACD;AAND,8DAMC","sourcesContent":["import { ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport { ApplicationCommandOptionWithChoicesBase } from '../mixins/CommandOptionWithChoices';\n\nexport class SlashCommandIntegerOption extends ApplicationCommandOptionWithChoicesBase<number> {\n\tpublic override readonly type = ApplicationCommandOptionType.Integer as const;\n\n\tpublic constructor() {\n\t\tsuper(ApplicationCommandOptionType.Integer);\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
import { ApplicationCommandOptionType } from 'discord-api-types/v9';
import { SlashCommandOptionBase } from '../mixins/CommandOptionBase';
export declare class SlashCommandMentionableOption extends SlashCommandOptionBase {
readonly type: ApplicationCommandOptionType.Mentionable;
constructor();
}
//# sourceMappingURL=mentionable.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"mentionable.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/options/mentionable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,qBAAa,6BAA8B,SAAQ,sBAAsB;IACxE,SAAyB,IAAI,2CAAqD;;CAKlF"}
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandMentionableOption = void 0;
require("discord-api-types/v9");
const CommandOptionBase_1 = require("../mixins/CommandOptionBase");
class SlashCommandMentionableOption extends CommandOptionBase_1.SlashCommandOptionBase {
constructor() {
super(9 /* Mentionable */);
Object.defineProperty(this, "type", {
enumerable: true,
configurable: true,
writable: true,
value: 9 /* Mentionable */
});
}
}
exports.SlashCommandMentionableOption = SlashCommandMentionableOption;
//# sourceMappingURL=mentionable.js.map
@@ -0,0 +1 @@
{"version":3,"file":"mentionable.js","sourceRoot":"/","sources":["interactions/slashCommands/options/mentionable.ts"],"names":[],"mappings":";;;AAAA,gCAAoE;AACpE,mEAAqE;AAErE,MAAa,6BAA8B,SAAQ,0CAAsB;IAGxE;QACC,KAAK,qBAA0C,CAAC;QAHjD;;;;mBAAgC,mBAAiD;WAAC;IAIlF,CAAC;CACD;AAND,sEAMC","sourcesContent":["import { ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport { SlashCommandOptionBase } from '../mixins/CommandOptionBase';\n\nexport class SlashCommandMentionableOption extends SlashCommandOptionBase {\n\tpublic override readonly type = ApplicationCommandOptionType.Mentionable as const;\n\n\tpublic constructor() {\n\t\tsuper(ApplicationCommandOptionType.Mentionable);\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
import { ApplicationCommandOptionType } from 'discord-api-types/v9';
import { ApplicationCommandOptionWithChoicesBase } from '../mixins/CommandOptionWithChoices';
export declare class SlashCommandNumberOption extends ApplicationCommandOptionWithChoicesBase<number> {
readonly type: ApplicationCommandOptionType.Number;
constructor();
}
//# sourceMappingURL=number.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"number.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/options/number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,uCAAuC,EAAE,MAAM,oCAAoC,CAAC;AAE7F,qBAAa,wBAAyB,SAAQ,uCAAuC,CAAC,MAAM,CAAC;IAC5F,SAAyB,IAAI,sCAAgD;;CAK7E"}
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandNumberOption = void 0;
require("discord-api-types/v9");
const CommandOptionWithChoices_1 = require("../mixins/CommandOptionWithChoices");
class SlashCommandNumberOption extends CommandOptionWithChoices_1.ApplicationCommandOptionWithChoicesBase {
constructor() {
super(10 /* Number */);
Object.defineProperty(this, "type", {
enumerable: true,
configurable: true,
writable: true,
value: 10 /* Number */
});
}
}
exports.SlashCommandNumberOption = SlashCommandNumberOption;
//# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
{"version":3,"file":"number.js","sourceRoot":"/","sources":["interactions/slashCommands/options/number.ts"],"names":[],"mappings":";;;AAAA,gCAAoE;AACpE,iFAA6F;AAE7F,MAAa,wBAAyB,SAAQ,kEAA+C;IAG5F;QACC,KAAK,iBAAqC,CAAC;QAH5C;;;;mBAAgC,eAA4C;WAAC;IAI7E,CAAC;CACD;AAND,4DAMC","sourcesContent":["import { ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport { ApplicationCommandOptionWithChoicesBase } from '../mixins/CommandOptionWithChoices';\n\nexport class SlashCommandNumberOption extends ApplicationCommandOptionWithChoicesBase<number> {\n\tpublic override readonly type = ApplicationCommandOptionType.Number as const;\n\n\tpublic constructor() {\n\t\tsuper(ApplicationCommandOptionType.Number);\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
import { ApplicationCommandOptionType } from 'discord-api-types/v9';
import { SlashCommandOptionBase } from '../mixins/CommandOptionBase';
export declare class SlashCommandRoleOption extends SlashCommandOptionBase {
readonly type: ApplicationCommandOptionType.Role;
constructor();
}
//# sourceMappingURL=role.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"role.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/options/role.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,qBAAa,sBAAuB,SAAQ,sBAAsB;IACjE,SAAyB,IAAI,oCAA8C;;CAK3E"}
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandRoleOption = void 0;
require("discord-api-types/v9");
const CommandOptionBase_1 = require("../mixins/CommandOptionBase");
class SlashCommandRoleOption extends CommandOptionBase_1.SlashCommandOptionBase {
constructor() {
super(8 /* Role */);
Object.defineProperty(this, "type", {
enumerable: true,
configurable: true,
writable: true,
value: 8 /* Role */
});
}
}
exports.SlashCommandRoleOption = SlashCommandRoleOption;
//# sourceMappingURL=role.js.map
@@ -0,0 +1 @@
{"version":3,"file":"role.js","sourceRoot":"/","sources":["interactions/slashCommands/options/role.ts"],"names":[],"mappings":";;;AAAA,gCAAoE;AACpE,mEAAqE;AAErE,MAAa,sBAAuB,SAAQ,0CAAsB;IAGjE;QACC,KAAK,cAAmC,CAAC;QAH1C;;;;mBAAgC,YAA0C;WAAC;IAI3E,CAAC;CACD;AAND,wDAMC","sourcesContent":["import { ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport { SlashCommandOptionBase } from '../mixins/CommandOptionBase';\n\nexport class SlashCommandRoleOption extends SlashCommandOptionBase {\n\tpublic override readonly type = ApplicationCommandOptionType.Role as const;\n\n\tpublic constructor() {\n\t\tsuper(ApplicationCommandOptionType.Role);\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
import { ApplicationCommandOptionType } from 'discord-api-types/v9';
import { ApplicationCommandOptionWithChoicesBase } from '../mixins/CommandOptionWithChoices';
export declare class SlashCommandStringOption extends ApplicationCommandOptionWithChoicesBase<string> {
readonly type: ApplicationCommandOptionType.String;
constructor();
}
//# sourceMappingURL=string.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"string.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/options/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,uCAAuC,EAAE,MAAM,oCAAoC,CAAC;AAE7F,qBAAa,wBAAyB,SAAQ,uCAAuC,CAAC,MAAM,CAAC;IAC5F,SAAyB,IAAI,sCAAgD;;CAK7E"}
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandStringOption = void 0;
require("discord-api-types/v9");
const CommandOptionWithChoices_1 = require("../mixins/CommandOptionWithChoices");
class SlashCommandStringOption extends CommandOptionWithChoices_1.ApplicationCommandOptionWithChoicesBase {
constructor() {
super(3 /* String */);
Object.defineProperty(this, "type", {
enumerable: true,
configurable: true,
writable: true,
value: 3 /* String */
});
}
}
exports.SlashCommandStringOption = SlashCommandStringOption;
//# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
{"version":3,"file":"string.js","sourceRoot":"/","sources":["interactions/slashCommands/options/string.ts"],"names":[],"mappings":";;;AAAA,gCAAoE;AACpE,iFAA6F;AAE7F,MAAa,wBAAyB,SAAQ,kEAA+C;IAG5F;QACC,KAAK,gBAAqC,CAAC;QAH5C;;;;mBAAgC,cAA4C;WAAC;IAI7E,CAAC;CACD;AAND,4DAMC","sourcesContent":["import { ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport { ApplicationCommandOptionWithChoicesBase } from '../mixins/CommandOptionWithChoices';\n\nexport class SlashCommandStringOption extends ApplicationCommandOptionWithChoicesBase<string> {\n\tpublic override readonly type = ApplicationCommandOptionType.String as const;\n\n\tpublic constructor() {\n\t\tsuper(ApplicationCommandOptionType.String);\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
import { ApplicationCommandOptionType } from 'discord-api-types/v9';
import { SlashCommandOptionBase } from '../mixins/CommandOptionBase';
export declare class SlashCommandUserOption extends SlashCommandOptionBase {
readonly type: ApplicationCommandOptionType.User;
constructor();
}
//# sourceMappingURL=user.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"user.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/options/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,qBAAa,sBAAuB,SAAQ,sBAAsB;IACjE,SAAyB,IAAI,oCAA8C;;CAK3E"}
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandUserOption = void 0;
require("discord-api-types/v9");
const CommandOptionBase_1 = require("../mixins/CommandOptionBase");
class SlashCommandUserOption extends CommandOptionBase_1.SlashCommandOptionBase {
constructor() {
super(6 /* User */);
Object.defineProperty(this, "type", {
enumerable: true,
configurable: true,
writable: true,
value: 6 /* User */
});
}
}
exports.SlashCommandUserOption = SlashCommandUserOption;
//# sourceMappingURL=user.js.map
@@ -0,0 +1 @@
{"version":3,"file":"user.js","sourceRoot":"/","sources":["interactions/slashCommands/options/user.ts"],"names":[],"mappings":";;;AAAA,gCAAoE;AACpE,mEAAqE;AAErE,MAAa,sBAAuB,SAAQ,0CAAsB;IAGjE;QACC,KAAK,cAAmC,CAAC;QAH1C;;;;mBAAgC,YAA0C;WAAC;IAI3E,CAAC;CACD;AAND,wDAMC","sourcesContent":["import { ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport { SlashCommandOptionBase } from '../mixins/CommandOptionBase';\n\nexport class SlashCommandUserOption extends SlashCommandOptionBase {\n\tpublic override readonly type = ApplicationCommandOptionType.User as const;\n\n\tpublic constructor() {\n\t\tsuper(ApplicationCommandOptionType.User);\n\t}\n}\n"]}
+23
View File
@@ -0,0 +1,23 @@
import type { APIEmbedField } from 'discord-api-types/v9';
export declare const fieldNamePredicate: import("ow").StringPredicate;
export declare const fieldValuePredicate: import("ow").StringPredicate;
export declare const fieldInlinePredicate: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
export declare const embedFieldPredicate: import("ow").ObjectPredicate<{
name: string;
value: string;
inline: boolean | undefined;
}>;
export declare const embedFieldsArrayPredicate: import("ow").ArrayPredicate<{
name: string;
value: string;
inline: boolean | undefined;
}>;
export declare function validateFieldLength(fields: APIEmbedField[], amountAdding: number): void;
export declare const authorNamePredicate: import("ow").AnyPredicate<string | null>;
export declare const urlPredicate: import("ow").AnyPredicate<string | null | undefined>;
export declare const colorPredicate: import("ow").AnyPredicate<number | null>;
export declare const descriptionPredicate: import("ow").AnyPredicate<string | null>;
export declare const footerTextPredicate: import("ow").AnyPredicate<string | null>;
export declare const timestampPredicate: import("ow").AnyPredicate<number | Date | null>;
export declare const titlePredicate: import("ow").AnyPredicate<string | null>;
//# sourceMappingURL=Assertions.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"Assertions.d.ts","sourceRoot":"/","sources":["messages/embed/Assertions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,eAAO,MAAM,kBAAkB,8BAAwC,CAAC;AAExE,eAAO,MAAM,mBAAmB,8BAAyC,CAAC;AAE1E,eAAO,MAAM,oBAAoB,iFAAsB,CAAC;AAExD,eAAO,MAAM,mBAAmB;;;;EAI9B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;EAAuC,CAAC;AAE9E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAEvF;AAED,eAAO,MAAM,mBAAmB,0CAAsC,CAAC;AAEvE,eAAO,MAAM,YAAY,sDAA4C,CAAC;AAEtE,eAAO,MAAM,cAAc,0CAA6E,CAAC;AAEzG,eAAO,MAAM,oBAAoB,0CAA0D,CAAC;AAE5F,eAAO,MAAM,mBAAmB,0CAA0D,CAAC;AAE3F,eAAO,MAAM,kBAAkB,iDAAsC,CAAC;AAEtE,eAAO,MAAM,cAAc,0CAAsC,CAAC"}
+26
View File
@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.titlePredicate = exports.timestampPredicate = exports.footerTextPredicate = exports.descriptionPredicate = exports.colorPredicate = exports.urlPredicate = exports.authorNamePredicate = exports.validateFieldLength = exports.embedFieldsArrayPredicate = exports.embedFieldPredicate = exports.fieldInlinePredicate = exports.fieldValuePredicate = exports.fieldNamePredicate = void 0;
const tslib_1 = require("tslib");
const ow_1 = tslib_1.__importDefault(require("ow"));
exports.fieldNamePredicate = ow_1.default.string.minLength(1).maxLength(256);
exports.fieldValuePredicate = ow_1.default.string.minLength(1).maxLength(1024);
exports.fieldInlinePredicate = ow_1.default.optional.boolean;
exports.embedFieldPredicate = ow_1.default.object.exactShape({
name: exports.fieldNamePredicate,
value: exports.fieldValuePredicate,
inline: exports.fieldInlinePredicate,
});
exports.embedFieldsArrayPredicate = ow_1.default.array.ofType(exports.embedFieldPredicate);
function validateFieldLength(fields, amountAdding) {
ow_1.default(fields.length + amountAdding, 'field amount', ow_1.default.number.lessThanOrEqual(25));
}
exports.validateFieldLength = validateFieldLength;
exports.authorNamePredicate = ow_1.default.any(exports.fieldNamePredicate, ow_1.default.null);
exports.urlPredicate = ow_1.default.any(ow_1.default.string.url, ow_1.default.nullOrUndefined);
exports.colorPredicate = ow_1.default.any(ow_1.default.number.greaterThanOrEqual(0).lessThanOrEqual(0xffffff), ow_1.default.null);
exports.descriptionPredicate = ow_1.default.any(ow_1.default.string.minLength(1).maxLength(4096), ow_1.default.null);
exports.footerTextPredicate = ow_1.default.any(ow_1.default.string.minLength(1).maxLength(2048), ow_1.default.null);
exports.timestampPredicate = ow_1.default.any(ow_1.default.number, ow_1.default.date, ow_1.default.null);
exports.titlePredicate = ow_1.default.any(exports.fieldNamePredicate, ow_1.default.null);
//# sourceMappingURL=Assertions.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Assertions.js","sourceRoot":"/","sources":["messages/embed/Assertions.ts"],"names":[],"mappings":";;;;AACA,oDAAoB;AAEP,QAAA,kBAAkB,GAAG,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAE3D,QAAA,mBAAmB,GAAG,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAE7D,QAAA,oBAAoB,GAAG,YAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;AAE3C,QAAA,mBAAmB,GAAG,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC;IACvD,IAAI,EAAE,0BAAkB;IACxB,KAAK,EAAE,2BAAmB;IAC1B,MAAM,EAAE,4BAAoB;CAC5B,CAAC,CAAC;AAEU,QAAA,yBAAyB,GAAG,YAAE,CAAC,KAAK,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC;AAE9E,SAAgB,mBAAmB,CAAC,MAAuB,EAAE,YAAoB;IAChF,YAAE,CAAC,MAAM,CAAC,MAAM,GAAG,YAAY,EAAE,cAAc,EAAE,YAAE,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;AACjF,CAAC;AAFD,kDAEC;AAEY,QAAA,mBAAmB,GAAG,YAAE,CAAC,GAAG,CAAC,0BAAkB,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAE1D,QAAA,YAAY,GAAG,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,CAAC,GAAG,EAAE,YAAE,CAAC,eAAe,CAAC,CAAC;AAEzD,QAAA,cAAc,GAAG,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAE5F,QAAA,oBAAoB,GAAG,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAE/E,QAAA,mBAAmB,GAAG,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAE9E,QAAA,kBAAkB,GAAG,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,EAAE,YAAE,CAAC,IAAI,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAEzD,QAAA,cAAc,GAAG,YAAE,CAAC,GAAG,CAAC,0BAAkB,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import type { APIEmbedField } from 'discord-api-types/v9';\nimport ow from 'ow';\n\nexport const fieldNamePredicate = ow.string.minLength(1).maxLength(256);\n\nexport const fieldValuePredicate = ow.string.minLength(1).maxLength(1024);\n\nexport const fieldInlinePredicate = ow.optional.boolean;\n\nexport const embedFieldPredicate = ow.object.exactShape({\n\tname: fieldNamePredicate,\n\tvalue: fieldValuePredicate,\n\tinline: fieldInlinePredicate,\n});\n\nexport const embedFieldsArrayPredicate = ow.array.ofType(embedFieldPredicate);\n\nexport function validateFieldLength(fields: APIEmbedField[], amountAdding: number): void {\n\tow(fields.length + amountAdding, 'field amount', ow.number.lessThanOrEqual(25));\n}\n\nexport const authorNamePredicate = ow.any(fieldNamePredicate, ow.null);\n\nexport const urlPredicate = ow.any(ow.string.url, ow.nullOrUndefined);\n\nexport const colorPredicate = ow.any(ow.number.greaterThanOrEqual(0).lessThanOrEqual(0xffffff), ow.null);\n\nexport const descriptionPredicate = ow.any(ow.string.minLength(1).maxLength(4096), ow.null);\n\nexport const footerTextPredicate = ow.any(ow.string.minLength(1).maxLength(2048), ow.null);\n\nexport const timestampPredicate = ow.any(ow.number, ow.date, ow.null);\n\nexport const titlePredicate = ow.any(fieldNamePredicate, ow.null);\n"]}
+140
View File
@@ -0,0 +1,140 @@
import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage, APIEmbedProvider, APIEmbedThumbnail, APIEmbedVideo } from 'discord-api-types/v9';
export interface AuthorOptions {
name: string;
url?: string;
iconURL?: string;
}
export interface FooterOptions {
text: string;
iconURL?: string;
}
/**
* Represents an embed in a message (image/video preview, rich embed, etc.)
*/
export declare class Embed implements APIEmbed {
/**
* An array of fields of this embed.
*/
fields: APIEmbedField[];
/**
* The embed title.
*/
title?: string;
/**
* The embed description.
*/
description?: string;
/**
* The embed url.
*/
url?: string;
/**
* The embed color.
*/
color?: number;
/**
* The timestamp of the embed in the ISO format.
*/
timestamp?: string;
/**
* The embed thumbnail data.
*/
thumbnail?: APIEmbedThumbnail;
/**
* The embed image data.
*/
image?: APIEmbedImage;
/**
* Received video data.
*/
video?: APIEmbedVideo;
/**
* The embed author data.
*/
author?: APIEmbedAuthor;
/**
* Received data about the embed provider.
*/
provider?: APIEmbedProvider;
/**
* The embed footer data.
*/
footer?: APIEmbedFooter;
constructor(data?: APIEmbed);
/**
* The accumulated length for the embed title, description, fields, footer text, and author name.
*/
get length(): number;
/**
* Adds a field to the embed (max 25).
* @param field The field to add.
*/
addField(field: APIEmbedField): this;
/**
* Adds fields to the embed (max 25).
* @param fields The fields to add.
*/
addFields(...fields: APIEmbedField[]): this;
/**
* Removes, replaces, or inserts fields in the embed (max 25).
* @param index The index to start at.
* @param deleteCount The number of fields to remove.
* @param fields The replacing field objects.
*/
spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this;
/**
* Sets the author of this embed.
* @param options The options for the author.
*/
setAuthor(options: AuthorOptions | null): this;
/**
* Sets the color of this embed.
* @param color The color of the embed.
*/
setColor(color: number | null): this;
/**
* Sets the description of this embed.
* @param description The description.
*/
setDescription(description: string | null): this;
/**
* Sets the footer of this embed.
* @param options The options for the footer.
*/
setFooter(options: FooterOptions | null): this;
/**
* Sets the image of this embed.
* @param url The URL of the image.
*/
setImage(url: string | null): this;
/**
* Sets the thumbnail of this embed.
* @param url The URL of the thumbnail.
*/
setThumbnail(url: string | null): this;
/**
* Sets the timestamp of this embed.
* @param timestamp The timestamp or date.
*/
setTimestamp(timestamp?: number | Date | null): this;
/**
* Sets the title of this embed.
* @param title The title.
*/
setTitle(title: string | null): this;
/**
* Sets the URL of this embed.
* @param url The URL.
*/
setURL(url: string | null): this;
/**
* Transforms the embed to a plain object.
*/
toJSON(): APIEmbed;
/**
* Normalizes field input and resolves strings.
* @param fields Fields to normalize.
*/
static normalizeFields(...fields: APIEmbedField[]): APIEmbedField[];
}
//# sourceMappingURL=Embed.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Embed.d.ts","sourceRoot":"/","sources":["messages/embed/Embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,QAAQ,EACR,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,MAAM,sBAAsB,CAAC;AAiB9B,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,KAAM,YAAW,QAAQ;IACrC;;OAEG;IACI,MAAM,EAAE,aAAa,EAAE,CAAC;IAE/B;;OAEG;IACI,KAAK,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACI,WAAW,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACI,GAAG,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACI,KAAK,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACI,SAAS,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACI,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAErC;;OAEG;IACI,KAAK,CAAC,EAAE,aAAa,CAAC;IAE7B;;OAEG;IACI,KAAK,CAAC,EAAE,aAAa,CAAC;IAE7B;;OAEG;IACI,MAAM,CAAC,EAAE,cAAc,CAAC;IAE/B;;OAEG;IACI,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAEnC;;OAEG;IACI,MAAM,CAAC,EAAE,cAAc,CAAC;gBAEZ,IAAI,GAAE,QAAa;IAgBtC;;OAEG;IACH,IAAW,MAAM,IAAI,MAAM,CAQ1B;IAED;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAI3C;;;OAGG;IACI,SAAS,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI;IAWlD;;;;;OAKG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI;IAWzF;;;OAGG;IACI,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI;IAgBrD;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQ3C;;;OAGG;IACI,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQvD;;;OAGG;IACI,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI;IAerD;;;OAGG;IACI,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQzC;;;OAGG;IACI,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQ7C;;;OAGG;IACI,YAAY,CAAC,SAAS,GAAE,MAAM,GAAG,IAAI,GAAG,IAAiB,GAAG,IAAI;IAQvE;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQ3C;;;OAGG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQvC;;OAEG;IACI,MAAM,IAAI,QAAQ;IAIzB;;;OAGG;WACW,eAAe,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE;CAS1E"}
+300
View File
@@ -0,0 +1,300 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Embed = void 0;
const tslib_1 = require("tslib");
const ow_1 = tslib_1.__importDefault(require("ow"));
const Assertions_1 = require("./Assertions");
/**
* Represents an embed in a message (image/video preview, rich embed, etc.)
*/
class Embed {
constructor(data = {}) {
/**
* An array of fields of this embed.
*/
Object.defineProperty(this, "fields", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* The embed title.
*/
Object.defineProperty(this, "title", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* The embed description.
*/
Object.defineProperty(this, "description", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* The embed url.
*/
Object.defineProperty(this, "url", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* The embed color.
*/
Object.defineProperty(this, "color", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* The timestamp of the embed in the ISO format.
*/
Object.defineProperty(this, "timestamp", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* The embed thumbnail data.
*/
Object.defineProperty(this, "thumbnail", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* The embed image data.
*/
Object.defineProperty(this, "image", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* Received video data.
*/
Object.defineProperty(this, "video", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* The embed author data.
*/
Object.defineProperty(this, "author", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* Received data about the embed provider.
*/
Object.defineProperty(this, "provider", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* The embed footer data.
*/
Object.defineProperty(this, "footer", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.title = data.title;
this.description = data.description;
this.url = data.url;
this.color = data.color;
this.thumbnail = data.thumbnail;
this.image = data.image;
this.video = data.video;
this.author = data.author;
this.provider = data.provider;
this.footer = data.footer;
this.fields = data.fields ?? [];
if (data.timestamp)
this.timestamp = new Date(data.timestamp).toISOString();
}
/**
* The accumulated length for the embed title, description, fields, footer text, and author name.
*/
get length() {
return ((this.title?.length ?? 0) +
(this.description?.length ?? 0) +
this.fields.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) +
(this.footer?.text.length ?? 0) +
(this.author?.name?.length ?? 0));
}
/**
* Adds a field to the embed (max 25).
* @param field The field to add.
*/
addField(field) {
return this.addFields(field);
}
/**
* Adds fields to the embed (max 25).
* @param fields The fields to add.
*/
addFields(...fields) {
// Data assertions
ow_1.default(fields, 'fields', Assertions_1.embedFieldsArrayPredicate);
// Ensure adding these fields won't exceed the 25 field limit
Assertions_1.validateFieldLength(this.fields, fields.length);
this.fields.push(...Embed.normalizeFields(...fields));
return this;
}
/**
* Removes, replaces, or inserts fields in the embed (max 25).
* @param index The index to start at.
* @param deleteCount The number of fields to remove.
* @param fields The replacing field objects.
*/
spliceFields(index, deleteCount, ...fields) {
// Data assertions
ow_1.default(fields, 'fields', Assertions_1.embedFieldsArrayPredicate);
// Ensure adding these fields won't exceed the 25 field limit
Assertions_1.validateFieldLength(this.fields, fields.length - deleteCount);
this.fields.splice(index, deleteCount, ...Embed.normalizeFields(...fields));
return this;
}
/**
* Sets the author of this embed.
* @param options The options for the author.
*/
setAuthor(options) {
if (options === null) {
this.author = undefined;
return this;
}
const { name, iconURL, url } = options;
// Data assertions
ow_1.default(name, 'name', Assertions_1.authorNamePredicate);
ow_1.default(iconURL, 'iconURL', Assertions_1.urlPredicate);
ow_1.default(url, 'url', Assertions_1.urlPredicate);
this.author = { name, url, icon_url: iconURL };
return this;
}
/**
* Sets the color of this embed.
* @param color The color of the embed.
*/
setColor(color) {
// Data assertions
ow_1.default(color, 'color', Assertions_1.colorPredicate);
this.color = color ?? undefined;
return this;
}
/**
* Sets the description of this embed.
* @param description The description.
*/
setDescription(description) {
// Data assertions
ow_1.default(description, 'description', Assertions_1.descriptionPredicate);
this.description = description ?? undefined;
return this;
}
/**
* Sets the footer of this embed.
* @param options The options for the footer.
*/
setFooter(options) {
if (options === null) {
this.footer = undefined;
return this;
}
const { text, iconURL } = options;
// Data assertions
ow_1.default(text, 'text', Assertions_1.footerTextPredicate);
ow_1.default(iconURL, 'iconURL', Assertions_1.urlPredicate);
this.footer = { text, icon_url: iconURL };
return this;
}
/**
* Sets the image of this embed.
* @param url The URL of the image.
*/
setImage(url) {
// Data assertions
ow_1.default(url, 'url', Assertions_1.urlPredicate);
this.image = url ? { url } : undefined;
return this;
}
/**
* Sets the thumbnail of this embed.
* @param url The URL of the thumbnail.
*/
setThumbnail(url) {
// Data assertions
ow_1.default(url, 'url', Assertions_1.urlPredicate);
this.thumbnail = url ? { url } : undefined;
return this;
}
/**
* Sets the timestamp of this embed.
* @param timestamp The timestamp or date.
*/
setTimestamp(timestamp = Date.now()) {
// Data assertions
ow_1.default(timestamp, 'timestamp', Assertions_1.timestampPredicate);
this.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;
return this;
}
/**
* Sets the title of this embed.
* @param title The title.
*/
setTitle(title) {
// Data assertions
ow_1.default(title, 'title', Assertions_1.titlePredicate);
this.title = title ?? undefined;
return this;
}
/**
* Sets the URL of this embed.
* @param url The URL.
*/
setURL(url) {
// Data assertions
ow_1.default(url, 'url', Assertions_1.urlPredicate);
this.url = url ?? undefined;
return this;
}
/**
* Transforms the embed to a plain object.
*/
toJSON() {
return { ...this };
}
/**
* Normalizes field input and resolves strings.
* @param fields Fields to normalize.
*/
static normalizeFields(...fields) {
return fields.flat(Infinity).map((field) => {
ow_1.default(field.name, 'field name', Assertions_1.fieldNamePredicate);
ow_1.default(field.value, 'field value', Assertions_1.fieldValuePredicate);
ow_1.default(field.inline, 'field inline', Assertions_1.fieldInlinePredicate);
return { name: field.name, value: field.value, inline: field.inline ?? undefined };
});
}
}
exports.Embed = Embed;
//# sourceMappingURL=Embed.js.map
File diff suppressed because one or more lines are too long
+198
View File
@@ -0,0 +1,198 @@
/// <reference types="node" />
import type { Snowflake } from 'discord-api-types/globals';
import type { URL } from 'url';
/**
* Wraps the content inside a codeblock with no language.
* @param content The content to wrap.
*/
export declare function codeBlock<C extends string>(content: C): `\`\`\`\n${C}\`\`\``;
/**
* Wraps the content inside a codeblock with the specified language.
* @param language The language for the codeblock.
* @param content The content to wrap.
*/
export declare function codeBlock<L extends string, C extends string>(language: L, content: C): `\`\`\`${L}\n${C}\`\`\``;
/**
* Wraps the content inside \`backticks\`, which formats it as inline code.
* @param content The content to wrap.
*/
export declare function inlineCode<C extends string>(content: C): `\`${C}\``;
/**
* Formats the content into italic text.
* @param content The content to wrap.
*/
export declare function italic<C extends string>(content: C): `_${C}_`;
/**
* Formats the content into bold text.
* @param content The content to wrap.
*/
export declare function bold<C extends string>(content: C): `**${C}**`;
/**
* Formats the content into underscored text.
* @param content The content to wrap.
*/
export declare function underscore<C extends string>(content: C): `__${C}__`;
/**
* Formats the content into strike-through text.
* @param content The content to wrap.
*/
export declare function strikethrough<C extends string>(content: C): `~~${C}~~`;
/**
* Formats the content into a quote. This needs to be at the start of the line for Discord to format it.
* @param content The content to wrap.
*/
export declare function quote<C extends string>(content: C): `> ${C}`;
/**
* Formats the content into a block quote. This needs to be at the start of the line for Discord to format it.
* @param content The content to wrap.
*/
export declare function blockQuote<C extends string>(content: C): `>>> ${C}`;
/**
* Wraps the URL into `<>`, which stops it from embedding.
* @param url The URL to wrap.
*/
export declare function hideLinkEmbed<C extends string>(url: C): `<${C}>`;
/**
* Wraps the URL into `<>`, which stops it from embedding.
* @param url The URL to wrap.
*/
export declare function hideLinkEmbed(url: URL): `<${string}>`;
/**
* Formats the content and the URL into a masked URL.
* @param content The content to display.
* @param url The URL the content links to.
*/
export declare function hyperlink<C extends string>(content: C, url: URL): `[${C}](${string})`;
/**
* Formats the content and the URL into a masked URL.
* @param content The content to display.
* @param url The URL the content links to.
*/
export declare function hyperlink<C extends string, U extends string>(content: C, url: U): `[${C}](${U})`;
/**
* Formats the content and the URL into a masked URL.
* @param content The content to display.
* @param url The URL the content links to.
* @param title The title shown when hovering on the masked link.
*/
export declare function hyperlink<C extends string, T extends string>(content: C, url: URL, title: T): `[${C}](${string} "${T}")`;
/**
* Formats the content and the URL into a masked URL.
* @param content The content to display.
* @param url The URL the content links to.
* @param title The title shown when hovering on the masked link.
*/
export declare function hyperlink<C extends string, U extends string, T extends string>(content: C, url: U, title: T): `[${C}](${U} "${T}")`;
/**
* Wraps the content inside spoiler (hidden text).
* @param content The content to wrap.
*/
export declare function spoiler<C extends string>(content: C): `||${C}||`;
/**
* Formats a user ID into a user mention.
* @param userId The user ID to format.
*/
export declare function userMention<C extends Snowflake>(userId: C): `<@${C}>`;
/**
* Formats a user ID into a member-nickname mention.
* @param memberId The user ID to format.
*/
export declare function memberNicknameMention<C extends Snowflake>(memberId: C): `<@!${C}>`;
/**
* Formats a channel ID into a channel mention.
* @param channelId The channel ID to format.
*/
export declare function channelMention<C extends Snowflake>(channelId: C): `<#${C}>`;
/**
* Formats a role ID into a role mention.
* @param roleId The role ID to format.
*/
export declare function roleMention<C extends Snowflake>(roleId: C): `<@&${C}>`;
/**
* Formats an emoji ID into a fully qualified emoji identifier
* @param emojiId The emoji ID to format.
*/
export declare function formatEmoji<C extends Snowflake>(emojiId: C, animated?: false): `<:_:${C}>`;
/**
* Formats an emoji ID into a fully qualified emoji identifier
* @param emojiId The emoji ID to format.
* @param animated Whether the emoji is animated or not. Defaults to `false`
*/
export declare function formatEmoji<C extends Snowflake>(emojiId: C, animated?: true): `<a:_:${C}>`;
/**
* Formats a date into a short date-time string.
* @param date The date to format, defaults to the current time.
*/
export declare function time(date?: Date): `<t:${bigint}>`;
/**
* Formats a date given a format style.
* @param date The date to format.
* @param style The style to use.
*/
export declare function time<S extends TimestampStylesString>(date: Date, style: S): `<t:${bigint}:${S}>`;
/**
* Formats the given timestamp into a short date-time string.
* @param seconds The time to format, represents an UNIX timestamp in seconds.
*/
export declare function time<C extends number>(seconds: C): `<t:${C}>`;
/**
* Formats the given timestamp into a short date-time string.
* @param seconds The time to format, represents an UNIX timestamp in seconds.
* @param style The style to use.
*/
export declare function time<C extends number, S extends TimestampStylesString>(seconds: C, style: S): `<t:${C}:${S}>`;
/**
* The [message formatting timestamp styles](https://discord.com/developers/docs/reference#message-formatting-timestamp-styles) supported by Discord.
*/
export declare const TimestampStyles: {
/**
* Short time format, consisting of hours and minutes, e.g. 16:20.
*/
readonly ShortTime: "t";
/**
* Long time format, consisting of hours, minutes, and seconds, e.g. 16:20:30.
*/
readonly LongTime: "T";
/**
* Short date format, consisting of day, month, and year, e.g. 20/04/2021.
*/
readonly ShortDate: "d";
/**
* Long date format, consisting of day, month, and year, e.g. 20 April 2021.
*/
readonly LongDate: "D";
/**
* Short date-time format, consisting of short date and short time formats, e.g. 20 April 2021 16:20.
*/
readonly ShortDateTime: "f";
/**
* Long date-time format, consisting of long date and short time formats, e.g. Tuesday, 20 April 2021 16:20.
*/
readonly LongDateTime: "F";
/**
* Relative time format, consisting of a relative duration format, e.g. 2 months ago.
*/
readonly RelativeTime: "R";
};
/**
* The possible values, see {@link TimestampStyles} for more information.
*/
export declare type TimestampStylesString = typeof TimestampStyles[keyof typeof TimestampStyles];
/**
* An enum with all the available faces from Discord's native slash commands
*/
export declare enum Faces {
/**
* ¯\\_(ツ)\\_/¯
*/
Shrug = "\u00AF\\_(\u30C4)\\_/\u00AF",
/**
* (╯°□°)╯︵ ┻━┻
*/
Tableflip = "(\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35 \u253B\u2501\u253B",
/**
* ┬─┬ ノ( ゜-゜ノ)
*/
Unflip = "\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)"
}
//# sourceMappingURL=formatters.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"formatters.d.ts","sourceRoot":"/","sources":["messages/formatters.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC;AAE9E;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;AAKjH;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAEnE;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAE7D;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAE7D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAEnE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAEtE;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,CAE5D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,CAEnE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;AAElE;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,MAAM,GAAG,CAAC;AAMvD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,KAAK,MAAM,GAAG,CAAC;AAEvF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;AAElG;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC3D,OAAO,EAAE,CAAC,EACV,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,CAAC,GACN,IAAI,CAAC,KAAK,MAAM,KAAK,CAAC,IAAI,CAAC;AAE9B;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC7E,OAAO,EAAE,CAAC,EACV,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,GACN,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;AAMzB;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAEhE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,GAAG,CAErE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,GAAG,CAElF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,GAAG,CAE3E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,GAAG,CAEtE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC;AAE5F;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC;AAW5F;;;GAGG;AACH,wBAAgB,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,MAAM,GAAG,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,qBAAqB,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,MAAM,IAAI,CAAC,GAAG,CAAC;AAElG;;;GAGG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,qBAAqB,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAS/G;;GAEG;AACH,eAAO,MAAM,eAAe;IAC3B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEM,CAAC;AAEX;;GAEG;AACH,oBAAY,qBAAqB,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEzF;;GAEG;AACH,oBAAY,KAAK;IAChB;;OAEG;IACH,KAAK,gCAAiB;IAEtB;;OAEG;IACH,SAAS,mEAAiB;IAE1B;;OAEG;IACH,MAAM,oDAAiB;CACvB"}
+181
View File
@@ -0,0 +1,181 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Faces = exports.TimestampStyles = exports.time = exports.formatEmoji = exports.roleMention = exports.channelMention = exports.memberNicknameMention = exports.userMention = exports.spoiler = exports.hyperlink = exports.hideLinkEmbed = exports.blockQuote = exports.quote = exports.strikethrough = exports.underscore = exports.bold = exports.italic = exports.inlineCode = exports.codeBlock = void 0;
function codeBlock(language, content) {
return typeof content === 'undefined' ? `\`\`\`\n${language}\`\`\`` : `\`\`\`${language}\n${content}\`\`\``;
}
exports.codeBlock = codeBlock;
/**
* Wraps the content inside \`backticks\`, which formats it as inline code.
* @param content The content to wrap.
*/
function inlineCode(content) {
return `\`${content}\``;
}
exports.inlineCode = inlineCode;
/**
* Formats the content into italic text.
* @param content The content to wrap.
*/
function italic(content) {
return `_${content}_`;
}
exports.italic = italic;
/**
* Formats the content into bold text.
* @param content The content to wrap.
*/
function bold(content) {
return `**${content}**`;
}
exports.bold = bold;
/**
* Formats the content into underscored text.
* @param content The content to wrap.
*/
function underscore(content) {
return `__${content}__`;
}
exports.underscore = underscore;
/**
* Formats the content into strike-through text.
* @param content The content to wrap.
*/
function strikethrough(content) {
return `~~${content}~~`;
}
exports.strikethrough = strikethrough;
/**
* Formats the content into a quote. This needs to be at the start of the line for Discord to format it.
* @param content The content to wrap.
*/
function quote(content) {
return `> ${content}`;
}
exports.quote = quote;
/**
* Formats the content into a block quote. This needs to be at the start of the line for Discord to format it.
* @param content The content to wrap.
*/
function blockQuote(content) {
return `>>> ${content}`;
}
exports.blockQuote = blockQuote;
function hideLinkEmbed(url) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
return `<${url}>`;
}
exports.hideLinkEmbed = hideLinkEmbed;
function hyperlink(content, url, title) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`;
}
exports.hyperlink = hyperlink;
/**
* Wraps the content inside spoiler (hidden text).
* @param content The content to wrap.
*/
function spoiler(content) {
return `||${content}||`;
}
exports.spoiler = spoiler;
/**
* Formats a user ID into a user mention.
* @param userId The user ID to format.
*/
function userMention(userId) {
return `<@${userId}>`;
}
exports.userMention = userMention;
/**
* Formats a user ID into a member-nickname mention.
* @param memberId The user ID to format.
*/
function memberNicknameMention(memberId) {
return `<@!${memberId}>`;
}
exports.memberNicknameMention = memberNicknameMention;
/**
* Formats a channel ID into a channel mention.
* @param channelId The channel ID to format.
*/
function channelMention(channelId) {
return `<#${channelId}>`;
}
exports.channelMention = channelMention;
/**
* Formats a role ID into a role mention.
* @param roleId The role ID to format.
*/
function roleMention(roleId) {
return `<@&${roleId}>`;
}
exports.roleMention = roleMention;
/**
* Formats an emoji ID into a fully qualified emoji identifier
* @param emojiId The emoji ID to format.
* @param animated Whether the emoji is animated or not. Defaults to `false`
*/
function formatEmoji(emojiId, animated = false) {
return `<${animated ? 'a' : ''}:_:${emojiId}>`;
}
exports.formatEmoji = formatEmoji;
function time(timeOrSeconds, style) {
if (typeof timeOrSeconds !== 'number') {
timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1000);
}
return typeof style === 'string' ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`;
}
exports.time = time;
/**
* The [message formatting timestamp styles](https://discord.com/developers/docs/reference#message-formatting-timestamp-styles) supported by Discord.
*/
exports.TimestampStyles = {
/**
* Short time format, consisting of hours and minutes, e.g. 16:20.
*/
ShortTime: 't',
/**
* Long time format, consisting of hours, minutes, and seconds, e.g. 16:20:30.
*/
LongTime: 'T',
/**
* Short date format, consisting of day, month, and year, e.g. 20/04/2021.
*/
ShortDate: 'd',
/**
* Long date format, consisting of day, month, and year, e.g. 20 April 2021.
*/
LongDate: 'D',
/**
* Short date-time format, consisting of short date and short time formats, e.g. 20 April 2021 16:20.
*/
ShortDateTime: 'f',
/**
* Long date-time format, consisting of long date and short time formats, e.g. Tuesday, 20 April 2021 16:20.
*/
LongDateTime: 'F',
/**
* Relative time format, consisting of a relative duration format, e.g. 2 months ago.
*/
RelativeTime: 'R',
};
/**
* An enum with all the available faces from Discord's native slash commands
*/
var Faces;
(function (Faces) {
/**
* ¯\\_(ツ)\\_/¯
*/
Faces["Shrug"] = "\u00AF\\_(\u30C4)\\_/\u00AF";
/**
* (╯°□°)╯︵ ┻━┻
*/
Faces["Tableflip"] = "(\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35 \u253B\u2501\u253B";
/**
* ┬─┬ ノ( ゜-゜ノ)
*/
Faces["Unflip"] = "\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)";
})(Faces = exports.Faces || (exports.Faces = {}));
//# sourceMappingURL=formatters.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 vladfrangu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,97 @@
# Discord API Types
[![GitHub](https://img.shields.io/github/license/discordjs/discord-api-types)](https://github.com/discordjs/discord-api-types/blob/main/LICENSE.md)
[![npm](https://img.shields.io/npm/v/discord-api-types?color=crimson&logo=npm)](https://www.npmjs.com/package/discord-api-types)
[![deno](https://img.shields.io/npm/v/discord-api-types?color=blue&label=deno&logo=deno)](https://deno.land/x/discord_api_types)
[![Patreon Donate](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Donate%20with%20Patreon&logo=patreon&colorB=F96854&link=https://www.patreon.com/vladfrangu)](https://www.patreon.com/vladfrangu)
[![Ko-fi Donate](https://img.shields.io/badge/kofi-donate-brightgreen.svg?label=Donate%20with%20Ko-fi&logo=ko-fi&colorB=F16061&link=https://ko-fi.com/wolfgalvlad&logoColor=FFFFFF)](https://ko-fi.com/wolfgalvlad)
[![GitHub Sponsors](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Sponsor%20through%20GitHub&logo=github&colorB=F96854&link=https://github.com/sponsors/vladfrangu)](https://github.com/sponsors/vladfrangu)
Simple type definitions for the [Discord API](https://discord.com/developers/docs/intro).
## Installation
Install with [npm](https://www.npmjs.com/) / [yarn](https://yarnpkg.com) / [pnpm](https://pnpm.js.org/):
```sh
npm install discord-api-types
yarn add discord-api-types
pnpm add discord-api-types
```
### Usage
You can only import this module by specifying the API version you want to target. Append `/v*` to the import path, where the `*` represents the API version. Below are some examples
```js
const { APIUser } = require('discord-api-types/v9');
```
```ts
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types/v9';
```
You may also import just certain parts of the module that you need. The possible values are: `globals`, `gateway`, `gateway/v*`, `payloads`, `payloads/v*`, `rest`, `rest/v*`, `rpc`, `rpc/v*`, `utils`, `utils/v*`, `voice`, and `voice/v*`. Below are some examples
```js
const { GatewayVersion } = require('discord-api-types/gateway/v9');
```
```ts
// TypeScript/ES Module support
import { GatewayVersion } from 'discord-api-types/gateway/v9';
```
> _**Note:** The `v*` exports (`discord-api-type/v*`) include the appropriate version of `gateway`, `payloads`, `rest`, `rpc`, and `utils` you specified, alongside the `globals` exports_
### Deno
We also provide typings compatible with the [deno](https://deno.land/) runtime. You have 3 ways you can import them:
1. Directly from GitHub
```ts
// Importing a specific API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v9.ts';
```
2. From [deno.land/x](https://deno.land/x)
```ts
// Importing a specific API version
import { APIUser } from 'https://deno.land/x/discord_api_types/v9.ts';
```
3. From [skypack.dev](https://www.skypack.dev/)
```ts
// Importing a specific API version
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v9?dts';
```
## Project Structure
The exports of each API version is split into three main parts:
- Everything exported with the `API` prefix represents a payload you may get from the REST API _or_ the Gateway.
- Everything exported with the `Gateway` prefix represents data that ONLY comes from or is directly related to the Gateway.
- Everything exported with the `REST` prefix represents data that ONLY comes from or is directly related to the REST API.
- For endpoint options, they will follow the following structure: `REST<HTTP Method><Type><Query|(JSON|FormData)Body|Result>` where the type represents what it will return.
- For example, `RESTPostAPIChannelMessageJSONBody` or `RESTGetAPIGatewayBotInfoResult`.
- Some exported types (specifically OAuth2 related ones) may not respect this entire structure due to the nature of the fields. They will start with either `RESTOAuth2` or with something similar to `REST<HTTP Method>OAuth2`
- If a type ends with `Result`, then it represents the expected result by calling its accompanying route.
- Types that are exported as `never` usually mean the result will be a `204 No Content`, so you can safely ignore it. This does **not** account for errors.
- Anything else that is miscellaneous will be exported based on what it represents (for example the `REST` route object).
- There may be types exported that are identical for all versions. These will be exported as is and can be found in the `globals` file. They will still be prefixed accordingly as described above.
**Warning**: This package documents just KNOWN (and documented) properties. Anything that isn't documented will NOT be added to this package (unless said properties are in an open Pull Request to Discord's [API Documentation repository](https://github.com/discord/discord-api-docs) or known through other means _and have received the green light to be used_). For clarification's sake, this means that properties that are only known through the process of data mining and have not yet been confirmed in a way as described will **NOT** be included.
@@ -0,0 +1,9 @@
/**
* https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-params
*/
export interface GatewayURLQuery {
v: string;
encoding: 'json' | 'etf';
compress?: 'zlib-stream';
}
//# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["common.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC;IACzB,QAAQ,CAAC,EAAE,aAAa,CAAC;CACzB"}

Some files were not shown because too many files have changed in this diff Show More