UltraX
ℹ️ || About
UltraX a unique package that gives you multiple useful usages using functions and events.
📥 || Installation
To install UltraX package you need:
Then you can open your application's terminal and type:
$ npm install ultrax
📜 || Table of content
functions:
-
sleep()
- Functions that creates timeout easily and fast.
-
passGen()
- Function to create passwords made by letters and numbers randomly with specified length.
-
bin()
- Function that allows you to bin codes.
-
ButtonPaginator()
- Function to create embed pages using buttons easily.
-
welcomeImage()
- Function that creates a welcome image fully customizable using canvas.
-
Wikipedia()
- Function that allows users to search wikipedia and return results for a query.
-
remind()
- Function to make remind command
-
daBaby()
- Function to make a user DaBaby
-
boostImage()
- Function that creates a booster card.
Events:
-
inviteJoin
allows you to get some informations about the invite such as the inviter, etc...
-
reminder
It Triggers when someone used remind function and its time to remind user.
-
boost
This event emits when the server is boosted and returns the booster as GuildMember, with all data existing about it.
|| Functions:
sleep
sleep is a simple function, where is make it easier and faster to make a timeout in your code.
Example:
const ultrax = require('ultrax')
const sleep = ultrax.sleep
console.log('Start!')
sleep(5000)
console.log('5 Seconds passed')
sleep(ms: Number)
passGen
this is a simple function that can generate passwords using letters and numbers and the password length is custom so you can change it to any length you want!
Example:
const ultrax = require('ultrax')
const passGen = ultrax.passGen
console.log(passGen(6))
passGen(Length: Number)
Bin
This function is used to bin your code.
Example:
const ultrax = require('ultrax')
if (!args.join(' ')) return message.channel.send('What do you want to bin?');
else {
const bin = await ultrax.bin(args.join(' '), true);
console.log('Here i binned the code ' + bin)
}
bin(String)
ultrax.bin(args.join(' '), true/false)
if its true that mean the bin is editable, else if its false that means no one can edit it.
Button Paginator
Button Paginator function allows you to create embed pages easily and fast.
Styles: red
, grey
, blurple
, green
, url
Example:
const ultrax = require('ultrax')
const { MessageEmbed, MessageButton } = require("discord.js")
const embed1 = new MessageEmbed()
.setTitle("1st page embed");
const embed2 = new MessageEmbed()
.setTitle("2nd page embed");
const embed3 = new MessageEmbed()
.setTitle("3rd page embed");
const embed4 = new MessageEmbed()
.setTitle("4th page embed");
const buttonBack = new MessageButton()
.setStyle("DANGER")
.setEmoji("◀")
const buttonForward = new MessageButton()
.setStyle("SUCCESS")
.setEmoji("▶")
await ultrax.ButtonPaginator(message, [embed1, embed2, embed3, embed4], [buttonBack, buttonForward]);
Don't change the id of the buttons otherwise, don't expect it to work.
welcomeImage
This function is used to create a welcome image using canvas, fully customizable and fast!
The function returns a Promise(<Attachment>) to Buffer the image and make it an Attachment, so you need to await it.
await welcomeImage()
As we mentioned before its fully customizable, so lets see the parameters and the options available.
Parameters (Required):
-
background
-
avatar
-
text_1 (Title)
-
text_2 (Subtitle)
-
text_3 (Footer)
-
color
Options (Optional):
-
font
{ default: "San Serif" }
-
attachmentName
{ default: "welcome" }
-
text1_fontSize
{ default: "72 pixels" }
-
text2_fontSize
{ default: "42 pixels" }
-
text3_fontSize
{ default: "32 pixels" }
So now lets talk about the correct Syntax for it!
await welcomeImage(background, avatar, text_1, text_2, text_3, color)
The background must be a PNG image, local images and URL images are supported.
The color must be a HEX color's code.
As example this HEX:#FFFFFF
In case you will use the options:
You don't have to use all options you can just use the ones you want to use, and you are not obligate of using them at all they are optional.
await welcomeImage(background, avatar, text_1, text_2, text_3, color {
font: String,
attachmentName: String,
text1_fontSize: Number,
text2_fontSize: Number,
text3_fontSize: Number
})
the attachmentName
is always PNG, so whatever name you will put it will end with .png
automatically.
Example:
attachmentName: "Hello"
returns: "Hello.png"
Example:
const { registerFont } = require('canvas')
registerFont('ShadowsIntoLight-Regular.ttf', { family: "Shadows Into Light" });
To use custom fonts, you need to install the font (ttf/otf) yourself and use registerFont()
to register the font and be able to use it.
This is an example font, if you used this without install the font you will get an error.
After all these explanations and examples, lets see a full and nice welcome image function working inside of an guildMemberAdd
event!
Example:
const ultrax = require('ultrax')
const { registerFont } = require('canvas')
registerFont('ShadowsIntoLight-Regular.ttf', { family: "Shadows Into Light" });
Client.on('guildMemberAdd', async member => {
let bg = 'https://www.cdn.discordapp.com/attachments/850808002545319957/859359637106065408/bg.png'
let avatar = member.user.displayAvatarURL({ format: "png" })
let text1 = "welcome"
let text2 = member.user.tag
let text3 = `You're the ${member.guild.memberCount}th member`
let color = '#ffffff'
const options = {
font: "Shadows Into Light",
attachmentName: `welcome-${member.id}`,
text1_fontSize: 80,
text2_fontSize: 50,
text3_fontSize: 30
}
const image = await ultrax.welcomeImage(bg, avatar, text1, text2, text3, color, options)
});
Sussybaka
Makes a sussybaka image with a image url
Example
const ultrax = require("ultrax");
const { Client } = require("discord.js");
const client = new Client();
client.on("message", async(message) => {
if(message.content === "!sussybaka"){
const theSussyBaka = new ultrax.sussyBaka(message.mentions.users.first()?.displayAvatarURL({ format: 'png' }) || message.author.displayAvatarURL({ format: 'png' }));
const Image = await theSussyBaka.get();
return message.channel.send(Image);
}
});
Output
wikipedia
A simple function to allow you to fetch a topic from wikipedia
Example
const ultrax = require('ultrax')
let query = 'earth'
const res = new ultrax.Wikipedia({
message: message,
color: "RED",
query: query
})
res.fetch()
daBaby
Simple function to DaBaby a user!
The function returns a Promise(<Attachment>) to Buffer the image and make it an Attachment, so you need to await it.
await daBaby()
Example
const ultrax = require('ultrax')
client.on("message", async(message) => {
if(message.content === "!dababy"){
const daBaby = await ultrax.dababy(message.mentions.users.first()?.displayAvatarURL({ format: 'png' }) || message.author.displayAvatarURL({ format: 'png' }));
return message.channel.send(daBaby);
}
});
Output
boostImage
Function that creates a booster card, credit to French Noodles.
The function returns a Promise(<String>) the output is a URL in the form of a String, so you can use it as a MessageAttachement or in the .setImage()/.setThumbnail() function in a MessageEmbed.
Parameter(s)
Parameter | Description | Type | Position |
---|
url | The image url of the booster! | string | 1 |
boostImage(url)
Example
const ultrax = require('ultrax')
const boostImage = ultrax.boostImage
let avatar = user.displayAvatarURL()
let boostCard = await boostImage(avatar)
const discord = require('discord.js')
let embed = new discord.MessageEmbed()
.setTitle('Boost Card!')
.setImage(boostCard)
.setThumbnail(boostCard)
channel.send({ embeds: [embed] })
channel.send({ content: 'Booster Card!', files: [ img ] })
Output
Remind
Used in remind command.
Parameters:
Example
const remind = require("ultrax").remind;
const time = args[0];
const reason = args.slice(1).join(" ");
if (!time) return message.channel.send("Specify Time! e.g `1m`")
if (!reason) return message.channel.send("Specify Reason! e.g `Going to Market`")
remind(message.author.id, time, reason);
message.channel.send("Successfully set a reminder.")
Events:
Reminder Event
This will trigger when someone uses remind command ( remind function
) And when its time to remind user his message, this will trgger. It has 3 parameters:
Example
const Discord = require("discord.js");
const client = new Discord.Client();
client.login('TOKEN HERE');
const ultrax = require("ultrax")
ultrax.connectToMongoDB('MONGO DB URL');
ultrax.remind.startRemind(client);
client.on('reminder', (user, reason, time) => {
client.users.cache.get(user.id).send(`You asked me \`${time}\` ago to remind you \n \`${reason}\``);
});
client.on('message'(message) => {
let prefix = '?'
let args = message.content.slice(prefix.length).trim().split(/ +/g);
let cmd = args.shift().toLowerCase();
if (cmd === 'remind') {
const time = args[0];
const reason = args.slice(1).join(" ");
if (!time) return message.channel.send("Specify Time! e.g `1m`")
if (!reason) return message.channel.send("Specify Reason! e.g `Going to Market`")
remind(message.author.id, time, reason);
message.channel.send("Successfully set a reminder.")
};
});
Invite Logger Event
This event is for logging invite uses. This is same as guildMemberAdd
event but this is custom event which has 3 parameters:
Example:
const ultrax = require("ultrax")
const discord = require('discord.js')
const client = new discord.Client()
ultrax.inviteLogger(client)
client.on('inviteJoin', (member, invite, inviter) => {
console.log(`${member.user.tag} joined using invite code ${invite.code} from ${inviter.tag}. Invite was used ${invite.uses} times since its creation.`)
});
ultrax.inviteLogger(client)
put here your discord client. without it, the event won't emit.
Boost Event
This event fires when the server is boosted and returns the booster as GuildMember, with all data existing about it.
Function:
start(client, boosterRoleID)
Parameters:
Parameter | Description | Type | Position |
---|
client | The client object | object | 1 |
BoosterRoleID | The ID of the booster role in the server | string/Snowflake | 2 |
Example:
const discord = require('discord.js')
const client = new Discord.Client({ intents: [ Discord.Intents.FLAGS.your_intents ... ] })
const ultrax = require('ultrax')
ultrax.boost.start(client, '12345678910111213141516')
client.on('boost', async booster => {
const boostchannel = client.channels.cache.get('12345678910111213141516')
boostchannel.send({ content: `${booster} boosted the server!` })
})
🤫 | PS: You can use boostImage() to add a nice image to your embed/message
( booster.user.displayAvatarURL() returns the avatar of the booster )
Output:
⎝🔶⎠ Contact us
In case you have idea's to improve the package, or maybe you found some bugs or you need help, you can contact us from our discord server!