1.3.0 • Published 3 years ago

gydo.js v1.3.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

gydo.js

'Gydo-js' is a form of discord.js designed to simplify the process of creating a Discord bot.

Table of Contents

Installation

Node v16.6.0 or later is required

npm install gydo.js

Example Usage

const gydo = require("gydo.js-dev");
const bot = new gydo.config({
    // change the <token here> to your bots token, same with the prefix (you can only do one prefix yet)
    token: "<token here>",
    prefix: "<your prefix>"
});

// Detect Messages
bot.MessageDetect();

// Ping Command
bot.cmd({
    name: "ping",
    code: "Pong! | $[ping]ms'
});

You will automatically have this intents: GUILDS GUILD_MESSAGES

Which is enough, and what is required.

Once you've completed the setup, you can run node . (or node <filename>.js) in your terminal to run the bot.

Commands

If you encounter any bugs, please report it to our Discord Server

Before you put any commands put:

bot.MessageDetect()

For the command to actually work (Make sure to put it above the commands)

To create a command do:

bot.cmd({
    name: "<cmd name>", 
    code: "<code>"
});

Every command will start with your prefix like ?ping

Example Command:

bot.cmd({ 
    name: "ping",
    code: "Pong! | $[ping]ms"
});

Functions:

$[ping] - Sends the Bot's ping

$[author.tag] - Author's User Tag of the message

Args

$[args;<num>]

You can replace <num> with a number.

Example:

Code: $[args;0]

Message sent by user: "!example gydo"

Output: gydo

Raw Args Output: ["gydo"]

Command Handler

Baisc Command Handler Example:

const fs = require('fs');
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    
    bot.cmd(command);
}

Slash Commands

Make sure your bot has the permission to create slash commands

Simple Ping Slash Command:

bot.slashCommand.create({
    name: "ping",
    description: "a simple ping command",
    code: "pong",
    // optional
    guildId: "1234567890"
});

You can also put {ping} inside code: "" to get the bots ping.

If you want your slash command to only be created on a specific server, then you can put the server's guild ID in guildId

If you want it so only the user who created the interaction can see it, add the property in slashCommand.create({}): ephemeral: true

To detect the slash command:

bot.slashCommand.detect("ping")

You will have to do bot.slashCommand.detect("<slashCommandName>") to detect the slash commands you've created, otherwise the bot will say "interaction failed"

ClientError

ClientError extends EventEmitter

const { ClientError } = require('gydo.js-dev');

const ClientErr = new ClientError();

ClientErr.on('error', error => {
    console.error(error);
});

Embeds

To make an embed:

You will first have to specify on what command should the embed be attached on. It'll automatically attached on a command, if you have put one, and does exist.

All things you could add in the embed's property is mentioned here:

new gydo.Embed("<any of your command name>", {
    title: "Embed Title",
    author: "Embed Author",
    authorURL: "<some URL here>",
    description: "Embed Description \n [Hyper Link](https://npmjs.com/package/gydo.js-dev/)",
    footer: "Embed Footer",
    // (You can add more than 2 fields)
    fields: [
        {
            name: "First Field",
            value: "First Field Value",
            // Optional
            inline: true
        },
        {
            name: "Second Field",
            value: "Second Field Value"
        }
    ],
    color: "RANDOM",
    timestamp: true
});

Status

bot.activity.setActivity("<status>", { type: "PLAYING" });

or a Changing Status Loop

bot.activity.loopStatus(["<status>", "another one"], 1000, { type: "PLAYING" })

It must be on an Array, otherwise it'll send an error.

The Second Argument (or the time) is in Miliseconds (1000 = 1 second), and you can't go below 1000 ms, or it'll send an error.

Status Types are: PLAYING,

LISTENING,

WATCHING, and

STREAMING

You can also do just a normal status:

bot.activity.setUserStatus('idle');

Normal Status Types are:

idle (Idle)

dnd (Do not Disturb)

invisible (Invisible)

online (Online)

Events

Member Leave Event

bot.guildMemberRemove({
    message: "Sad to see you leave $[member.tag]",
    // put any message you want
    channel: "<CHANNEL ID>"
});

Functions:

$[member.tag] - Returns the member's tag

$[member.id] - Returns the member's ID

$[guild.name] - Returns the Guild's name

$[guild.memberCount] - Returns the Guild's Member Count (Will Include Bots)

Join Message Event

bot.guildMemberAdd({
    // put any message here
    message: "$[member.tag] Welcome to $[guild.name]!",
    channel: "<channel ID>"
});

Functions:

$[member.tag] - Return the member's tag

$[member] - Mentions the member that just joined

$[guild.name] - Returns the Guild's name

$[member.id] - Returns the member's id

$[guild.memberCount] - Returns the Guild's Member Count (Will Include Bots)

Message Update

MessageUpdate extends Base

Example:

bot.MessageUpdate({
    channel: "<CHANNEL_ID>",
    message: "<MESSAGE>"
});

Functions:

$[oldMessage] - Old Message Content before the message were updated

$[newMessage] - New Message Content after the message were updated

$[author.id] - Message Author's ID

$[author.tag] - Message Author's User Tag

$[author] - Mentions the Message Author

$[channel] - the Channel the message was sent on by the author

Contributing

You can contribute on gydo.js dev branch by making a pull request on our GitHub Repository

See Contributing Guide

...and Thanks for Contributing!

Links

Report the bugs on our Discord Server, and/or to our GitHub Repository.

Gydo-JS Discord Server

Github Repo