Is an easy and efficienty way to code discord bot with discord.js v14 with many features available.
- Installation
- Setup
- Example Usage
- Slash commands setup
- Legacy commands setup
- Events example (ready)
- Slash commands example (ping)
- Legacy commands example (ping)
- Components
- Features
npm install shreosh@latest
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 */
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 */
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 */
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",
});
},
};
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`,
});
},
};
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!" });
},
};
- Buttons
- Modals
- SelectMenus
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)