diff --git a/README.md b/README.md
index 62b9130..4fad523 100644
--- a/README.md
+++ b/README.md
@@ -18,10 +18,10 @@ Please join [this](https://discord.gg/5ZSGFYtnqw) community server to follow all
# Links:
### Support Server Community
-
+
-### Amandine Discord Bot Support Server
-
+### Xinko Discord Bot Support Server
+
# Download
@@ -41,96 +41,123 @@ const DIG = require("discord-image-generation");
Then you have to request your image and send it as an attachement.
-## Discord.js v12
+## Discord.js v13
```js
// Import the discord.js library.
-const Discord = require("discord.js")
+const Discord = require("discord.js");
// Create a new discord.js client.
-const bot = new Discord.Client()
+const bot = new Discord.Client();
const DIG = require("discord-image-generation");
-> You can also destructure to avoid repeating DIG.
// Listen to the ready event
bot.on("ready", () => {
- console.log("ok");
-})
+ console.log("Bot is online");
+});
// Listen to the message event
-bot.on("message", async (message) => {
+bot.on("messageCreate", async (message) => {
// Send the image in a simple message
if (message.content === "*delete") {
// Get the avatarUrl of the user
- let avatar = message.author.displayAvatarURL({ dynamic: false, format: 'png' });
+ let avatar = message.author.displayAvatarURL({
+ dynamic: false,
+ format: 'png'
+ });
// Make the image
- let img = await new DIG.Delete().getImage(avatar)
+ let img = await new DIG.Delete().getImage(avatar);
// Add the image as an attachement
- let attach = new Discord.MessageAttachment(img, "delete.png");;
- message.channel.send(attach)
+ let attach = new Discord.MessageAttachment(img, "delete.png");
+ message.channel.send({
+ files: [attach]
+ });
}
// Send the message with the image attached to an embed
if (message.content === "*blur") {
// Get the avatarUrl of the user
- let avatar = message.author.displayAvatarURL({ dynamic: false, format: 'png' });
+ let avatar = message.author.displayAvatarURL({
+ dynamic: false,
+ format: 'png'
+ });
// Make the image
- let img = await new DIG.Blur().getImage(avatar)
+ let img = await new DIG.Blur().getImage(avatar);
// Add the image as an attachement
let embed = new Discord.MessageEmbed()
.setTitle("Blur")
- .setImage("attachment://delete.png")
- let attach = new Discord.MessageAttachment(img, "blur.png");;
- message.channel.send({ embed: embed, files: [attach])
+ .setImage("attachment://delete.png");
+ let attach = new Discord.MessageAttachment(img, "blur.png");
+ message.channel.send({
+ embeds: [embed],
+ files: [attach]
+ });
}
-})
+});
// Log in to the bot
-bot.login("super_secret_token")
+bot.login("super_secret_token");
```
-## Discord.js v13
+## Discord.js v14
```js
-// Import the discord.js library.
-const Discord = require("discord.js")
+// Import the required elements from the discord.js library.
+const { Client, GatewayIntentBits, AttachmentBuilder, EmbedBuilder } = require("discord.js");
// Create a new discord.js client.
-const bot = new Discord.Client()
+const bot = new Client({
+ intents: [
+ GatewayIntentBits.Guilds,
+ GatewayIntentBits.GuildMembers,
+ GatewayIntentBits.GuildMessages,
+ GatewayIntentBits.MessageContent,
+ ],
+});
const DIG = require("discord-image-generation");
-> You can also destructure to avoid repeating DIG.
// Listen to the ready event
bot.on("ready", () => {
- console.log("ok");
-})
+ console.log("Bot is online");
+});
// Listen to the message event
bot.on("messageCreate", async (message) => {
// Send the image in a simple message
if (message.content === "*delete") {
// Get the avatarUrl of the user
- let avatar = message.author.displayAvatarURL({ dynamic: false, format: 'png' });
+ let avatar = message.author.displayAvatarURL({
+ forceStatic: true,
+ extension: 'png'
+ });
// Make the image
- let img = await new DIG.Delete().getImage(avatar)
+ let img = await new DIG.Delete().getImage(avatar);
// Add the image as an attachement
- let attach = new Discord.MessageAttachment(img, "delete.png");;
- message.channel.send({ files: [attach] })
+ let attach = new AttachmentBuilder(img).setName("delete.png");
+ message.channel.send({
+ files: [attach]
+ });
}
// Send the message with the image attached to an embed
if (message.content === "*blur") {
// Get the avatarUrl of the user
- let avatar = message.author.displayAvatarURL({ dynamic: false, format: 'png' });
+ let avatar = message.author.displayAvatarURL({
+ forceStatic: true,
+ extension: 'png'
+ });
// Make the image
- let img = await new DIG.Blur().getImage(avatar)
+ let img = await new DIG.Blur().getImage(avatar);
// Add the image as an attachement
- let embed = new Discord.MessageEmbed()
+ let embed = new EmbedBuilder()
.setTitle("Blur")
- .setImage("attachment://delete.png")
- let attach = new Discord.MessageAttachment(img, "blur.png");;
- message.channel.send({ embeds: [embed], files: [attach])
+ .setImage("attachment://blur.png");
+ let attach = new AttachmentBuilder(img).setName("blur.png");
+ message.channel.send({
+ embeds: [embed],
+ files: [attach]
+ });
}
-})
+});
// Log in to the bot
-bot.login("super_secret_token")
+bot.login("super_secret_token");
```
# Available images
@@ -209,7 +236,7 @@ bot.login("super_secret_token")
- ``new DIG.Deepfry().getImage(``);``
-![Deepfry](https://imgur.com/beAiPNv.png)
+![Deepfry](https://imgur.com/q2ADecK.png)
- ``new DIG.Delete().getImage(``);``
@@ -327,6 +354,10 @@ bot.login("super_secret_token")
# Changelog
+## v1.4.21
+- Added discord.js V14 usage example
+- Removed discord.js V12 usage example
+
## v1.4.20
- Some fixes
- Added Clown() (thanks to Retrojection#1937)
diff --git a/package.json b/package.json
index 3a9df40..118f8f0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "discord-image-generation",
- "version": "1.4.20",
+ "version": "1.4.21",
"description": "discord-image-generation is a powerful module that allow you to generate awesome images.",
"main": "src/index.js",
"scripts": {
diff --git a/src/module/montage/deepfry.js b/src/module/montage/deepfry.js
index a45c58b..cfe7961 100644
--- a/src/module/montage/deepfry.js
+++ b/src/module/montage/deepfry.js
@@ -4,7 +4,7 @@ const { validateURL } = require(`../functions`);
module.exports = class Deepfry {
async getImage(image) {
if (!image) throw new Error(`You must provide an image as a first argument.`);
- let isValid = await validateURL(img1);
+ let isValid = await validateURL(image);
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
image = await jimp.read(image);
image.resize(500, 500);