discord-utils.js

discord-utils.js is a cool package for discord bots (can be used for something else too) which has alot of stuff like image manupulation, random stuff, etc

Usage no npm install needed!

<script type="module">
  import discordUtilsJs from 'https://cdn.skypack.dev/discord-utils.js';
</script>

README

Discord-utils.js

This package is an api wrapper for the devs hub api (made by me) & cool-img-api (made by my friend)

Installing the package:

npm i discord-utils.js

Getting started:

const Discord = require("discord.js")
const { Client } = require("discord.js")
const { APIClient } = require("discord-utils.js")
const client = new Client()
const api = new APIClient()

client.on("message", async (message) => {
if (message.content.startsWith("!communist")) {
let user = message.mentions.users.first()
let avatar = user.displayAvatarURL({ format: "png" })
let image = await api.Canvas.communist(avatar)
message.channel.send({
files: [{
name: "image.png",
attachment: image
}]
})
}
})

client.login("token")

if you use a command handler it would look like this:

const { APIClient } = require("discord-utils.js")
const api = new APIClient()

module.exports = {
name: "communist",
description: "sends an image with the communist filter",
run: async (client, message, args) => {
let user = message.mentions.users.first() || message.author
let avatar = user.displayAvatarURL()
let image = await api.Canvas.communist(avatar)
message.channel.send({
files: [{
name: "image.png",
attachment: image
}]
})
}
}

for random cats, dogs, or birds:

const { APIClient } = require("discord-utils.js")
const api = new APIClient()

module.exports = {
name: "dog",
description: "sends a random dog picture",
run: async (client, message, args) => {
let image = await api.random.dog()
message.channel.send({
files: [{
name: "image.png",
attachment: image
}]
})
}
}

for using the util stuff:

const { APIClient } = require("discord-utils.js")
const api = new APIClient()

module.exports = {
name: "emojify",
description: "emojifies provided text",
run: async (client, message, args) => {
let text = args.join(" ")
if (!text) return message.channel.send("Provide text to emojify!")
try {
let emojify = await Utils.emojify(text)
return message.channel.send(emojify)
} catch (error) {
console.log(error)
} //if you get errors join the support server on discord
}
}

using the djsDocs method on Utils:

const { APIClient } = require("discord-utils.js")
const api = new APIClient()
module.exports = {
name: "docs",
aliases: ["djs"],
description: "searches the djs docs for the provided query",
run: async (client, message, args) => {
let text = args.join(" ")
if (!text) return message.channel.send("Provide the query!")
try {
let embed = await api.Utils.djsDocs(text)
return message.channel.send(embed)
} catch (error) {
console.log(error)
} //if you get errors join the support server on discord
}
}

Links:

Note: the list of Canvas methods are listed on the documentation