Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

discord-slider

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-slider - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

43

index.js
const { Structures } = require("discord.js");
module.exports = (client) => {
const { MessageButton } = require("discord-buttons")
const { MessageButton, MessageActionRow } = require("discord-buttons");
class TextChannel extends Structures.get("TextChannel") {
async createSlider(userID, embeds) {
async createSlider(userID, embeds, emojiNext, emojiBack) {
const button_back = new MessageButton()
.setStyle('gray')
.setID('back')
.setLabel("<<");
.setID('back');
const button_next = new MessageButton()
.setStyle('gray')
.setID('next')
.setLabel('>>');
.setID('next');

@@ -22,3 +20,2 @@ const button_back_disabled = new MessageButton()

.setID('back_disabled')
.setLabel("<<")
.setDisabled();

@@ -29,10 +26,24 @@

.setID('next_disabled')
.setLabel('>>')
.setDisabled();
const buttonsActive = [button_back, button_next];
if (emojiNext && emojiBack) {
button_back.setEmoji(emojiBack)
button_next.setEmoji(emojiNext)
button_back_disabled.setEmoji(emojiBack)
button_next_disabled.setEmoji(emojiNext)
}
else {
button_back.setLabel('<<');
button_next.setLabel('>>');
button_back_disabled.setLabel('<<');
button_next_disabled.setLabel('>>');
};
const buttonsDisabled = [button_back_disabled, button_next_disabled];
const buttonsActive = new MessageActionRow()
.addComponents([button_back, button_next]);
this.send({ embed: embeds[0], buttons: buttonsActive }).then(msg => {
const buttonsDisabled = new MessageActionRow()
.addComponents([button_back_disabled, button_next_disabled]);
this.send({ embed: embeds[0], component: buttonsActive }).then(msg => {
const collector = msg.createButtonCollector((button) => userID === userID, { time: 300000 });

@@ -49,6 +60,6 @@

--currentPage;
msg.edit({embed:embeds[currentPage], buttons: buttonsActive});
msg.edit({embed:embeds[currentPage], component: buttonsActive});
} else {
currentPage = embeds.length - 1
msg.edit({embed:embeds[currentPage], buttons: buttonsActive});
msg.edit({embed:embeds[currentPage], component: buttonsActive});
};

@@ -60,6 +71,6 @@ }

currentPage++;
msg.edit({embed:embeds[currentPage], buttons: buttonsActive});
msg.edit({embed:embeds[currentPage], component: buttonsActive});
} else {
currentPage = 0
msg.edit({embed:embeds[currentPage], buttons: buttonsActive});
msg.edit({embed:embeds[currentPage], component: buttonsActive});
};

@@ -70,3 +81,3 @@ };

collector.on('end', collected => {
msg.edit({ embed: embeds[0], buttons: buttonsDisabled })
msg.edit({ embed: embeds[0], component: buttonsDisabled })
});

@@ -73,0 +84,0 @@ collector.on("error", (e) => console.log(e))

{
"name": "discord-slider",
"version": "1.1.4",
"version": "1.1.5",
"description": "Allow you to easily create beautiful page slider for your discord.js bot",

@@ -20,4 +20,4 @@ "main": "index.js",

"dependencies": {
"discord-buttons": "^2.4.1"
"discord-buttons": "^3.0.1"
}
}

@@ -23,9 +23,15 @@ <div align="center">

### You absolutly need to require both discord-buttons and discord-role-react !
### You absolutly need to require both discord-buttons and discord-slider !
<br />
## Method
```js
channel.createSlider(userID, embedsArray, emojiNext, emojiBack)
```
- If you don't precise any emojiNext and emojiBack, they will be ">>" and "<<".
## Example
```js
channel.createSlider(userID, [embed0, embed1, embed2, embed3])
channel.createSlider(message.author.id, [embed0, embed1, embed2, embed3], "➡", "⬅")
```

@@ -32,0 +38,0 @@ - The order of the embeds in the array will be the order of the pages.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc