shreosh

1.0.2 • Public • Published

shreosh v1.0.2

Is an easy and efficienty way to code discord bot with discord.js v14 with many features available.

shreosh Examples

Install

npm install shreosh@latest

Example

Setup

const { osh } = require("shreosh");
new osh({
    token: process.env.TOKEN, // required
    commandsPath: "Commands", // slash commands directory
    eventsPath: "Events", // events directory
    componentsPath: "Components", // NRR components like buttons, select menus etc.
    owner: "ownerId" || ["owner1", "owner2"], // NRR bot owner id
    mongoURI: process.env.MONGOURI, // mongodb extension
    client: client, // optional by default client with all perms created
    legaciesPath: "Legacies", // NRR prefix based commands
    prefix: ",", // optional by default is ','
});
/* NRR - Not Really Required */

Slash commands setup

const { osh } = require("shreosh");
new osh({
    token: process.env.TOKEN, // required
    commandsPath: "Commands", // slash commands directory
    developerGuild: 'TestGuildId' // id of the guild for testing - optional
    mainGuild: 'mainGuildId' // main guild where commands were to made - optional
    eventsPath: "Events", // events directory
    componentsPath: "Components", // NRR components like buttons, select menus etc.
    mongoURI: process.env.MONGOURI, // mongodb extension
    client: client, // optional by default client with all perms created
});
/* NRR - Not Really Required */

Legacy commands setup

const { osh } = require("shreosh");
new osh({
    token: process.env.TOKEN, // required
    eventsPath: "Events", // events directory
    owner: "ownerId" || ["owner1", "owner2"], // NRR bot owner id
    mongoURI: process.env.MONGOURI, // mongodb extension
    client: client, // optional by default client with all perms created
    legaciesPath: "Legacies", // NRR prefix based commands
    prefix: ",", // optional by default is ','
});
/* NRR - Not Really Required */

Events example (ready)

const { Client, ActivityType } = require("discord.js");
module.exports = {
    name: "ready",
    once: true,
    async execute(client) {
        console.log(`Logged in as ${client.user.username}`);
        client.user.setPresence({
            activities: [{ name: "to You", type: ActivityType.Listening }],
            status: "idle",
        });
    },
};

Slash commands example (ping)

const {
    SlashCommandBuilder,
    Client,
    ChatInputCommandInteraction,
} = require("discord.js");
module.exports = {
    data: new SlashCommandBuilder()
        .setName("ping")
        .setDescription("replies with pong!"),
    cooldown: 3, // cooldown of the command could aalso be '3m' or '4h' format
    ephemeral: true, // whether the reply response be ephemeral or not
    developer: true, // guild command available to developer guild only
    async execute(interaction, client) {
        await interaction.editReply({ content: "pinging the client!" });
        return interaction.editReply({
            content: `Pong!\n\`${client.ws.ping}\`ms`,
        });
    },
};

Legacy commands example (ping)

module.exports = {
    name: "ping",
    aliases: ["latency", "lag"],
    description: "sends the api ping",
    ownerOnly: true, // toggles owneronly or not
    requiredChannels: ["channel1", "channe2"], //limit commands to these channels
    requiredRoles: ["role1", "role2"], // limit commands to the roles
    userPerms: "SendMessages", // permission required for the user
    clientPerms: "ViewChannel", // permission needed by the bot
    cooldown: 3, // cooldown could also be written as like '3m' or '4h' etc.
    async execute(message, args, client) {
        message.reply({ content: "Pong!" });
    },
};

Components

For components create sub folders inside componentsPath directory (/Components)

  • Buttons
  • Modals
  • SelectMenus

Features

const { functions } = require("shreosh");
const {
    randomPicker,
    probabilityFunc,
    timeParser,
    timeIntoSec,
    currencyParser,
} = functions;
const array = [1, 2, 3, 4, 5, 6];
const obj = { first: 1, second: 9, third: 4 };
randomPicker(array, 2); // returns [2,3]
probabilityFunc(obj); // returns second
timeParser(86401); // returns 1d1s
timeIntoSec("1d1m"); // return 86460
currencyParser("3k"); // returns 3000
  • randomPicker(Array, num) where num is no. of random item
  • probabilityFunc(Object)
  • timeParser(time) where time is in form of total seconds
  • timeIntoSec(time) where time is in form like 3h5m
  • currencyParser(currency)

Readme

Keywords

Package Sidebar

Install

npm i shreosh

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

26.8 kB

Total Files

10

Last publish

Collaborators

  • shreosh