You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

468 lines
11 KiB
Markdown

<a href="https://nodei.co/npm/discord-image-generation/"><img src="https://nodei.co/npm/discord-image-generation.png?downloads=true&downloadRank=true&stars=true"></a>
# discord-image-generation
A powerfull module that allow you to generate awesome images.
# Bugs and glitches
3 years ago
Feel free to report all bugs and glitches by creating an issue in the <a href="https://git.mrkayjaydee.xyz/Mr-KayJayDee/discord-image-generation/issues">issue section.</a>
A correct and understandable issue contains :
- Steps to reproduce
- Code that summonned the error
- The complete error
Please join [this](https://discord.gg/5ZSGFYtnqw) community server to follow all my projects or if you need help.
# Links:
### Support Server Community
2 years ago
<a href="https://discord.gg/5ZSGFYtnqw"><img src="https://discord.com/api/guilds/833309512412299276/widget.png" alt="Coding support server"/></a>
2 years ago
### Xinko Discord Bot Support Server
<a href="https://discord.gg/Uqd2sQP"><img src="https://discord.com/api/guilds/527836578912010251/widget.png" alt="Xinko support server"/></a>
# Download
You can download it from <a href="https://www.npmjs.com/package/discord-image-generation">npmjs</a>.
```cli
npm i discord-image-generation
```
# Configuration
The first step is to import the module in your code.
```js
const DIG = require("discord-image-generation");
```
Then you have to request your image and send it as an attachement.
2 years ago
## Discord.js v13
```js
// Import the discord.js library.
2 years ago
const Discord = require("discord.js");
// Create a new discord.js client.
2 years ago
const bot = new Discord.Client();
const DIG = require("discord-image-generation");
// Listen to the ready event
bot.on("ready", () => {
2 years ago
console.log("Bot is online");
});
// Listen to the message event
2 years ago
bot.on("messageCreate", async (message) => {
// Send the image in a simple message
if (message.content === "*delete") {
5 years ago
// Get the avatarUrl of the user
2 years ago
let avatar = message.author.displayAvatarURL({
dynamic: false,
format: 'png'
});
// Make the image
2 years ago
let img = await new DIG.Delete().getImage(avatar);
// Add the image as an attachement
2 years ago
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
2 years ago
let avatar = message.author.displayAvatarURL({
dynamic: false,
format: 'png'
});
// Make the image
2 years ago
let img = await new DIG.Blur().getImage(avatar);
// Add the image as an attachement
let embed = new Discord.MessageEmbed()
.setTitle("Blur")
2 years ago
.setImage("attachment://delete.png");
let attach = new Discord.MessageAttachment(img, "blur.png");
message.channel.send({
embeds: [embed],
files: [attach]
});
}
2 years ago
});
// Log in to the bot
2 years ago
bot.login("super_secret_token");
```
2 years ago
## Discord.js v14
```js
2 years ago
// Import the required elements from the discord.js library.
const { Client, GatewayIntentBits, AttachmentBuilder, EmbedBuilder } = require("discord.js");
// Create a new discord.js client.
2 years ago
const bot = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
const DIG = require("discord-image-generation");
// Listen to the ready event
bot.on("ready", () => {
2 years ago
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
2 years ago
let avatar = message.author.displayAvatarURL({
forceStatic: true,
extension: 'png'
});
// Make the image
2 years ago
let img = await new DIG.Delete().getImage(avatar);
// Add the image as an attachement
2 years ago
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
2 years ago
let avatar = message.author.displayAvatarURL({
forceStatic: true,
extension: 'png'
});
// Make the image
2 years ago
let img = await new DIG.Blur().getImage(avatar);
// Add the image as an attachement
2 years ago
let embed = new EmbedBuilder()
.setTitle("Blur")
2 years ago
.setImage("attachment://blur.png");
let attach = new AttachmentBuilder(img).setName("blur.png");
message.channel.send({
embeds: [embed],
files: [attach]
});
}
2 years ago
});
// Log in to the bot
2 years ago
bot.login("super_secret_token");
```
# Available images
5 years ago
## Filters
5 years ago
- ``new DIG.Blur().getImage(`<Avatar>`, `<Level(Number)>`);``
5 years ago
![Blur](https://imgur.com/JqpNFTY.png)
5 years ago
- ``new DIG.Gay().getImage(`<Avatar>`);``
![Gay](https://imgur.com/BDTrXzZ.png)
5 years ago
- ``new DIG.Greyscale().getImage(`<Avatar>`);``
5 years ago
![Greyscale](https://imgur.com/h3ahY7Z.png)
5 years ago
- ``new DIG.Invert().getImage(`<Avatar>`);``
5 years ago
![Invert](https://imgur.com/Rl0wGQM.png)
5 years ago
- ``new DIG.Sepia().getImage(`<Avatar>`);``
5 years ago
![Sepia](https://imgur.com/OTbKVtj.png)
5 years ago
## Gifs
- ``new DIG.Blink().getImage(delay (in ms), `<Avatar>`, `<Avatar2>`.....);``
> You can add as many images as you want
5 years ago
![Blink](https://imgur.com/JjUXmRU.gif)
5 years ago
- ``new DIG.Triggered().getImage(`<Avatar>`);``
5 years ago
![Triggered](https://imgur.com/0QvyYQa.gif)
5 years ago
## Montage
- ``new DIG.Ad().getImage(`<Avatar>`);``
![Ad](https://imgur.com/H7FvUtZ.png)
5 years ago
- ``new DIG.Affect().getImage(`<Avatar>`);``
5 years ago
![Affect](https://imgur.com/g4Gaehb.png)
5 years ago
- ``new DIG.Batslap().getImage(`<Avatar>`, `<Avatar2>`);``
5 years ago
![Batslap](https://imgur.com/oYMpa5A.png)
5 years ago
- ``new DIG.Beautiful().getImage(`<Avatar>`);``
5 years ago
![Beautiful](https://imgur.com/HGZkmXo.png)
5 years ago
- ``new DIG.Bed().getImage(`<Avatar>`, `<Avatar2>`);``
5 years ago
![Bed](https://imgur.com/b1idSnr.png)
- ``new DIG.Bobross().getImage(`<Avatar>`);``
![Bobross](https://imgur.com/lATDohK.png)
- ``new DIG.Clown().getImage(`<Avatar>`);``
![Clown](https://imgur.com/qXUAAkb.png)
- ``new DIG.ConfusedStonk().getImage(`<Avatar>`);``
![ConfusedStonk](https://imgur.com/b4UB3BE.png)
- ``new DIG.Deepfry().getImage(`<Avatar>`);``
2 years ago
![Deepfry](https://imgur.com/q2ADecK.png)
5 years ago
- ``new DIG.Delete().getImage(`<Avatar>`);``
5 years ago
![Delete](https://imgur.com/6V1IYJp.png)
4 years ago
- ``new DIG.DiscordBlack().getImage(`<Avatar>`)``
![DiscordBlack](https://imgur.com/dTX3wta.png)
- ``new DIG.DiscordBlue().getImage(`<Avatar>`)``
![DiscordBlue](https://imgur.com/q1bRGrx.png)
- ``new DIG.DoubleStonk().getImage(`<Avatar`, `<Avatar2>`)``
![DoubleStonk](https://imgur.com/HbuuUC6.png)
5 years ago
- ``new DIG.Facepalm().getImage(`<Avatar>`);``
5 years ago
![Facepalm](https://imgur.com/cdPC3P1.png)
- ``new DIG.Hearbreaking().getImage(`<Avatar>`);``
![Hearbreaking](https://imgur.com/P6USTJ3.png)
5 years ago
- ``new DIG.Hitler().getImage(`<Avatar>`);``
![Hitler](https://imgur.com/wK9puxH.png)
5 years ago
- ``new DIG.Jail().getImage(`<Avatar>`);``
5 years ago
![Jail](https://imgur.com/QslACNo.png)
- ``new DIG.Karaba().getImage(`<Avatar>`);``
![Karaba](https://imgur.com/4aEZs6v.png)
5 years ago
- ``new DIG.Kiss().getImage(`<Avatar>`, `<Avatar2>`);``
5 years ago
![Kiss](https://imgur.com/sSoCAeH.png)
- ``new DIG.LisaPresentation().getImage(`<Text>`);``
4 years ago
![LisaPresentation](https://imgur.com/u5cPVVW.png)
> Limited to 300char
- ``new DIG.Mikkelsen().getImage(`<Avatar>`);``
![Mikkelsen](https://imgur.com/4p71VGS.png)
4 years ago
(Thanks to sιмση εcεяε#5765)
- ``new DIG.Mms().getImage(`<Avatar>`);``
5 years ago
![MMS](https://imgur.com/nH3URHb.png)
4 years ago
- ``new DIG.NotStonk().getImage(`<Avatar>`);``
![NotStonk](https://imgur.com/NJ2Svtj.png)
- ``new DIG.Podium().getImage(`<Avatar1>, <Avatar2>, <Avatar2>, <Name1>, <Name2>, <Name3>`);``
![Podium](https://imgur.com/bQoKf0a.png)
- ``new DIG.Poutine().getImage(`<Avatar>`);``
![Poutine](https://imgur.com/UpQJHzM.png)
5 years ago
- ``new DIG.Rip().getImage(`<Avatar>`);``
5 years ago
![RIP](https://imgur.com/qhyZKfz.png)
5 years ago
- ``new DIG.Snyder().getImage(`<Avatar>`);``
![Snyder](https://imgur.com/0dFnTcP.png)
5 years ago
- ``new DIG.Spank().getImage(`<Avatar>`, `<Avatar2>`);``
![Spank](https://imgur.com/25gq0es.png)
5 years ago
4 years ago
- ``new DIG.Stonk().getImage(`<Avatar>`);``
![Stonk](https://imgur.com/oAVgevR.png)
5 years ago
- ``new DIG.Tatoo().getImage(`<Avatar>`)``
5 years ago
![Tatoo](https://imgur.com/wJju4UJ.png)
5 years ago
- ``new DIG.Thomas().getImage(`<Avatar>`);``
5 years ago
![Thomas](https://imgur.com/7R37J2j.png)
5 years ago
- ``new DIG.Trash().getImage(`<Avatar>`);``
5 years ago
![Trash](https://imgur.com/nwAHGgF.png)
5 years ago
- ``new DIG.Wanted().getImage(`<Avatar>`, `<Currency>`);``
> Currency ($, €, ...)
![Wanted](https://imgur.com/NJfzJeN.png)
5 years ago
## Utils
5 years ago
- ``new DIG.Circle().getImage(`<Avatar>`);``
5 years ago
![Circle](https://imgur.com/0Zo8NYS.png)
5 years ago
- ``new DIG.Color().getImage(`<Color>`);``
5 years ago
> An hex color is needed, like "#FF0000"
5 years ago
![Color](https://imgur.com/40tMwfe.png)
2 years ago
- ``new DIG.Denoise().getImage(`<Avatar>`, `<Level>`);``
> Level should be a number
- ``new DIG.Mirror().getImage(`<Avatar>`, `<Level>`);``
![Mirror](https://imgur.com/oaxbVAC.png)
# Changelog
2 years ago
## v1.4.24
- Re added typings
2 years ago
## v1.4.23
- Fixed import issue
- Added Denoise()
- Added Mirror()
2 years ago
## v1.4.22
- Fixed some bugs
2 years ago
## 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)
- Added Deepfry() (thanks to Retrojection#1937)
2 years ago
- Added Heartbreaking() (thanks to Retrojection#1937)
- Added Mikkelsen() (thanks to Retrojection#1937)
- Added Snyder() (thanks to Retrojection#1937)
4 years ago
## v1.4.7
- Improved Blink() generation, now supports adding an insane amount of images ^^
## v1.4.5
- Added Karaba()
- Fixed some errors returns that were not the same
4 years ago
## v1.4.0
- Added DiscordBlack() and DiscordBlue()
- Added ESLint and fixed all problems
- Use of the function file in LisaPresentation() instead of an in file function
## v1.3.9
- Edited links in README
- Bumped jimp from 0.14.0 to 0.16.1
## v1.3.8
- Edited the Rip() image
- Fixed the Spank() colors
## v1.3.4
- Added bobross()
4 years ago
## v1.3.2
- Added Stonk()
- Added NotStonk()
- Added DoubleStonk()
- Added ConfusedStonk()
4 years ago
## v1.2.12
- Optimized src/index.js (thanks to https://github.com/Pyrojs)
## v1.2.9
- Added Podium()
- Added Ad()
- Added Poutine()
- Fixed Wanted()
- Bumped jimp from ^0.13.0 to ^0.14.0
## v1.1.5
- Added LisaPresentation
## v1.1.2
- Fixed invalid path
- Moved assets folder
5 years ago
## v1.0.0
- Changed the full structure
- Sorted all files in folders
- Sorted all files in the README
5 years ago
- Fixed new Wanted() text bug
- Added new Blink()
- Added a timeout options for new Triggered()
5 years ago
- Fixed the triggered example not animated
- Added some keywords
- Bumped jimp from ^0.12.1 to ^0.13.0
- Added workflow to auto publish to npm and github packages on push
5 years ago
## v0.1.14
- Updated .thomas() example
## v0.1.13
- Added example for .tatoo()
- Fixed the litle hole at the top of the users pic on .thomas()
## v0.1.12
- Saved all examples to imgur
## v0.1.11
- Added .tatoo()
- Updated JSDoc
5 years ago
## v0.1.9
- Added options for the wanted.
- The base image has been updated
- There is now a random price diplayed
- You can now configure a currency
4 years ago
- Added .thomas()
Thanks to Alex15#0010 for the big help ! ❤