cleanup cleanup cleanup on isle dd (#2792)

* cleanup cleanup cleanup on isle dd

* fix: rest manager import in test
This commit is contained in:
Skillz4Killz
2023-02-25 20:11:15 -06:00
committed by GitHub
parent b82dafd173
commit 3bbb03b8e3
173 changed files with 13719 additions and 9270 deletions

View File

@@ -22,27 +22,27 @@ We have a pre-made class for collectors which you can find
[here](https://github.com/meister03/discordeno.js/blob/master/Util/Collectors.js).
```js
const Discord = require("discordeno.js");
const filter = (m) => m.data?.customId === "warn_modal" && m.user.id === interaction.user.id;
const listener = client.eventListener; // When the eventListener property is named different
const collector = new Discord.Collector("interactionCreate", {
const Discord = require('discordeno.js')
const filter = (m) => m.data?.customId === 'warn_modal' && m.user.id === interaction.user.id
const listener = client.eventListener // When the eventListener property is named different
const collector = new Discord.Collector('interactionCreate', {
client: client,
timeout: 60000,
filter,
max: 20,
listener,
});
collector.on("collect", (m) => {
const interaction = client.interactions.forge(m);
})
collector.on('collect', (m) => {
const interaction = client.interactions.forge(m)
// Stop Collector
// collector.stop();
});
})
// Fires on a timeout, when the collector has reached the max amount of interactions or when it has been closed
collector.on("end", (collected) => {
collector.on('end', (collected) => {
// Map of Collected Interactions
console.log(collected);
});
console.log(collected)
})
```
As you can see, this opens up many possibilities. You can listen to any event and get the interaction you need.

View File

@@ -82,20 +82,20 @@ component you want to use.
```js
class ActionRow {
constructor(options = {}) {
this.type = 1;
this.type = 1
}
setComponents(...components) {
this.components = components;
return this;
this.components = components
return this
}
}
```
```js
const button = new Button();
const button2 = new Button();
const actionRow = new ActionRow().setComponents(button, button2);
const button = new Button()
const button2 = new Button()
const actionRow = new ActionRow().setComponents(button, button2)
```
This code will obviously not work because it's a missing a lot required of data. The other reason is that we can't send
@@ -107,34 +107,21 @@ We have a pre-made class for components which you can find
### Button
```js
const Discord = require("discordeno.js");
const message = client.messages.forge(rawMessage);
const Discord = require('discordeno.js')
const message = client.messages.forge(rawMessage)
const button = new Discord.Component()
.setType("BUTTON")
.setStyle("LINK")
.setLabel("Click me!")
.setUrl("https://google.com")
.toJSON();
const button = new Discord.Component().setType('BUTTON').setStyle('LINK').setLabel('Click me!').setUrl('https://google.com').toJSON()
// Button with raw types
const button2 = new Discord.Component()
.setType(2)
.setStyle(4)
.setLabel("DO NOT CLICK")
.setCustomId("12345")
.toJSON();
const button2 = new Discord.Component().setType(2).setStyle(4).setLabel('DO NOT CLICK').setCustomId('12345').toJSON()
const actionRow = new Discord.Component()
.setType("ACTION_ROW")
.setComponents(button, button2)
.toJSON();
const actionRow = new Discord.Component().setType('ACTION_ROW').setComponents(button, button2).toJSON()
// Message to send
const messageOptions = { content: "hello", components: [actionRow] };
const messageOptions = { content: 'hello', components: [actionRow] }
// await client.helpers.sendMessage(channelId, messageOptions); // Do it the raw way
message.channel.send(messageOptions); // Do it with the structure
message.channel.send(messageOptions) // Do it with the structure
```
As you can see, for simplicity you can use strings instead of numbers (types), which are hard to remember.
@@ -142,79 +129,76 @@ As you can see, for simplicity you can use strings instead of numbers (types), w
### Select Menu
```js
const Discord = require("discordeno.js");
const message = client.messages.forge(rawMessage);
const Discord = require('discordeno.js')
const message = client.messages.forge(rawMessage)
const selectMenu = new Discord.Component()
.setType("SELECT_MENU")
.setCustomId("12345")
.setType('SELECT_MENU')
.setCustomId('12345')
.setOptions([
{
label: "Option 1",
value: "1",
label: 'Option 1',
value: '1',
description: `This is option 1`,
},
{
label: "Option 2",
value: "2",
label: 'Option 2',
value: '2',
description: `This is option 2`,
},
{
label: "Default Option",
value: "3",
label: 'Default Option',
value: '3',
description: `Default option...`,
default: true,
},
])
.setPlaceholder("Select an option")
.toJSON();
.setPlaceholder('Select an option')
.toJSON()
const actionRow = new Discord.Component()
.setType("ACTION_ROW")
.setComponents(selectMenu)
.toJSON();
const actionRow = new Discord.Component().setType('ACTION_ROW').setComponents(selectMenu).toJSON()
const messageOptions = { content: "hello", components: [actionRow] };
const messageOptions = { content: 'hello', components: [actionRow] }
// await client.helpers.sendMessage(channelId, messageOptions); // Do it the raw way
message.channel.send(messageOptions); // Do it with the structure
message.channel.send(messageOptions) // Do it with the structure
```
### Text Input
```js
const Discord = require("discordeno.js");
const interaction = client.messages.forge(rawInteraction);
const Discord = require('discordeno.js')
const interaction = client.messages.forge(rawInteraction)
const textInput = new Component()
.setType("TEXT_INPUT")
.setStyle("SHORT")
.setCustomId("t1")
.setLabel("User ID")
.setPlaceholder("User ID")
.setType('TEXT_INPUT')
.setStyle('SHORT')
.setCustomId('t1')
.setLabel('User ID')
.setPlaceholder('User ID')
.setRequired(true)
.setMaxLength(20)
.setMinLength(1)
.toJSON();
.toJSON()
const textInput2 = new Component()
.setType("TEXT_INPUT")
.setStyle("PARAGRAPH")
.setCustomId("t2")
.setLabel("Reason")
.setPlaceholder("Reason for Ban")
.setType('TEXT_INPUT')
.setStyle('PARAGRAPH')
.setCustomId('t2')
.setLabel('Reason')
.setPlaceholder('Reason for Ban')
.setRequired(false)
.setMaxLength(300)
.toJSON();
.toJSON()
const actionRow = new Component().setType("ACTION_ROW").setComponents(textInput).toJSON();
const actionRow2 = new Component().setType("ACTION_ROW").setComponents(textInput2).toJSON();
const actionRow = new Component().setType('ACTION_ROW').setComponents(textInput).toJSON()
const actionRow2 = new Component().setType('ACTION_ROW').setComponents(textInput2).toJSON()
interaction.popupModal({
customId: "ban_modal",
title: "Ban User",
customId: 'ban_modal',
title: 'Ban User',
components: [actionRow, actionRow2],
});
})
```
### Receive Interactions

View File

@@ -11,14 +11,14 @@ Imagine you have a channel object to which you want to send a message.
```js
const data = {
id: 806947972004839444n,
name: "spam-and-bots",
};
name: 'spam-and-bots',
}
```
The recommended way would be:
```js
await client.helpers.sendMessage(data.id, { content: "hello" });
await client.helpers.sendMessage(data.id, { content: 'hello' })
```
However, you probably want to use something shorter, such as the following:
@@ -26,13 +26,13 @@ However, you probably want to use something shorter, such as the following:
```js
class Channel {
constructor(client, data) {
this.client = client;
this.id = data.id;
this.name = data.name;
this.client = client
this.id = data.id
this.name = data.name
}
async send(options) {
return await this.client.helpers.sendMessage(this.id, options);
return await this.client.helpers.sendMessage(this.id, options)
}
}
```
@@ -40,8 +40,8 @@ class Channel {
Now you can use the `.send()` method on the channel object without using such a long code:
```js
const channel = new Channel(client, data);
await channel.send({ content: "hello" });
const channel = new Channel(client, data)
await channel.send({ content: 'hello' })
```
Moreover, you can modify the `.send()` method to better suit your use case e.g not send the message if the channel is
@@ -74,22 +74,22 @@ construct the client for following the Guide
**Using the Structures:**
```js
const Discord = require("discordeno.js");
const client = new Discord.Client(clientOptions, cacheOptions); //See the Readme above
Discord.startBot(client);
const guild = client.guilds.forge(guildData);
const channel = guild.channels.forge(channelData);
const role = guild.roles.forge(roleData);
const member = guild.members.forge(memberData);
const user = guild.users.forge(userData);
const message = guild.messages.forge(messageData);
const interaction = guild.interactions.forge(interactionData);
const emoji = guild.emojis.forge(emojiData);
const Discord = require('discordeno.js')
const client = new Discord.Client(clientOptions, cacheOptions) //See the Readme above
Discord.startBot(client)
const guild = client.guilds.forge(guildData)
const channel = guild.channels.forge(channelData)
const role = guild.roles.forge(roleData)
const member = guild.members.forge(memberData)
const user = guild.users.forge(userData)
const message = guild.messages.forge(messageData)
const interaction = guild.interactions.forge(interactionData)
const emoji = guild.emojis.forge(emojiData)
const webhook = new Discord.Webhook(client, webhookData);
const embed = new Discord.Embed(embedData); // embedData is optional
const component = new Discord.Component(componentData); // componentData is optional
const collection = new Discord.Collection();
const webhook = new Discord.Webhook(client, webhookData)
const embed = new Discord.Embed(embedData) // embedData is optional
const component = new Discord.Component(componentData) // componentData is optional
const collection = new Discord.Collection()
```
Some popular methods have been added to the structures so that you can use them without having to come up with your own.

View File

@@ -32,7 +32,7 @@ Now we have created a class which we can use to create embeds. But we can't just
So we need an additional method which will convert the data from the class to the correct format.
```js
class Embed(){
class Embed(){
constructor() {}
setTitle(title) {
@@ -50,10 +50,10 @@ class Embed(){
Wow, now you can create a embed and send it to Discord.
```js
const Channel = require("./structures/Channel"); // Path to structure
const Channel = require('./structures/Channel') // Path to structure
const channel = new Channel(client, data);
await channel.send({ embeds: [embed] });
const channel = new Channel(client, data)
await channel.send({ embeds: [embed] })
```
You probably want more methods which you can use to create embeds.
@@ -62,36 +62,36 @@ You probably want more methods which you can use to create embeds.
### Using the Embed Structure:
```js
const Discord = require("discordeno.js");
const Discord = require('discordeno.js')
const channel = client.channels.forge(channelData);
const channel = client.channels.forge(channelData)
const showCaseEmbed = new Discord.Embed()
.setColor(0x00AE86)
.setTitle("A Random Title")
.setURL("https://github.com/discordeno")
.setColor(0x00ae86)
.setTitle('A Random Title')
.setURL('https://github.com/discordeno')
.setAuthor({
name: "Author name",
iconUrl: "https://raw.githubusercontent.com/discordeno/discordeno/main/site/static/img/logo.png",
url: "https://github.com/discordeno",
name: 'Author name',
iconUrl: 'https://raw.githubusercontent.com/discordeno/discordeno/main/site/static/img/logo.png',
url: 'https://github.com/discordeno',
})
.setDescription("A Random Description")
.setThumbnail("https://raw.githubusercontent.com/discordeno/discordeno/main/site/static/img/logo.png")
.setDescription('A Random Description')
.setThumbnail('https://raw.githubusercontent.com/discordeno/discordeno/main/site/static/img/logo.png')
.addFields(
{ name: "Field 1 Name", value: "Normal Field Value" },
{ name: "\u200B", value: "\u200B" },
{ name: "Field 2 Name", value: "Inline Field Value", inline: true },
{ name: "Field 3 Name", value: "Inline Field Value", inline: true },
{ name: 'Field 1 Name', value: 'Normal Field Value' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Field 2 Name', value: 'Inline Field Value', inline: true },
{ name: 'Field 3 Name', value: 'Inline Field Value', inline: true },
)
.addField({ name: "Field 4", value: "Field Value" })
.setImage("https://raw.githubusercontent.com/discordeno/discordeno/main/site/static/img/logo.png")
.addField({ name: 'Field 4', value: 'Field Value' })
.setImage('https://raw.githubusercontent.com/discordeno/discordeno/main/site/static/img/logo.png')
.setTimestamp()
.setFooter({
text: "A Footer Text",
iconUrl: "https://raw.githubusercontent.com/discordeno/discordeno/main/site/static/img/logo.png",
text: 'A Footer Text',
iconUrl: 'https://raw.githubusercontent.com/discordeno/discordeno/main/site/static/img/logo.png',
})
.toJSON();
.toJSON()
await channel.send({ embeds: [showCaseEmbed] });
await channel.send({ embeds: [showCaseEmbed] })
```
### Embed Limits:

View File

@@ -9,7 +9,7 @@ As previously mentioned, Discordeno was built with as few classes as possible, t
For example, you cannot execute functions on objects.
```diff
- message.channel.send({content: "hello"})
- message.channel.send({content: "hello"})
+ client.helpers.sendMessage(message.channel.id, {content: "hello"})
```