npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rh_discord_bot

v1.3.0

Published

Raw Handler, generate events handlers,boots and commands for discord bot from modules inside the directory

Downloads

30

Readme

Raw Handler. Commands, events, and boots generator. For discord API

hello world

create file 'main.js' and put this code there

    const Discord = require("discord.js");
    const client = new Discord.Client();
    const fs = require("fs");

    let RH=require(`rh_discord_bot`);

 RH.folder_name='...';//<-----PATH TO FOLDER (with folder name) THERE YOUR MODULES ARE
    client.on("raw", (...args) => {try{
        RH.run(client,...args);
    }catch(err){console.log(err);}; });

   client.login(...);//<------TOKEN HERE

create dir 'rh_modules' ,and put file 'hello_world.js' add there following code

module.exports.commands = {};

module.exports.commands.printHelloWorld={aliase:'hello', run:async(client,message,args)=>{try{
    
        message.channel.send('Hello World!!!');

}catch(err){console.log(err);};}};//

run main.js file and send '!hello'

extended


    const Discord = require("discord.js");
    const client = new Discord.Client();
    const fs = require("fs");
    client.SERVER_ID='...';//<-------PUT ID SERVER HERE

    let RH=require(`rh_discord_bot`);


    RH.folder_name='...';//<-----PATH TO FOLDER (with folder name) THERE YOUR MODULES ARE
    //full path to folder there are modules for build RH event handler;  default value:none, must be specified

     RH.server_id=client.SERVER_ID;
   //set main server id, needed be set for fetching members and messages; default value:client.SERVER_ID;

    RH.prefix='!';
   //prefix for commands; default value: '!'

   RH.fetch_members=true;
   //true- fetching members from main server;false-not; default value:true;
 
    RH.fetch_messages=true;
   //true - fetching last 100 messages from each channel main server; default value:true;

    RH.log=true;
   //true-console log feedback on;false-console log feedback off; default value:'true'

    RH.dm_commands=false; 
   //true - allowed executing commands sending by DM generated by RH event handler; false - this commands not allowed; default value:false;

    
    let some_module = require(`./some_module_name.js`);
    RH.external_module.push(some_module);
    //including some external modules in building RH event handler proccess
   
   client.on("raw", (...args) => {try{
     RH.run(client,...args);
   }catch(err){console.log(err);}; });

   client.login('...');//<--------TOKEN HERE 

simple module example


//________________________________________TOOLS__________________________________________
let delay=async(duration)=>{await new Promise(resolve=>setTimeout(resolve,duration))}; 
     //* for delay inside async function, use it instead setTimeout
let random =(max)=>{ return Math.floor(Math.random()*max);};


//_________________PART MANAGER (OPCIONAL)
//exports.RH_IGNORE_TOTAL=true;//add this line to ignore this module 
//exports.RH_IGNORE_COMMANDS=true;//add this line to ignore all commands from this module
//module.exports.RH_BOOTS=true;//add this line to ignore all boots from this module
//module.exports.RH_IGNORE_EVENTS=true;//add this line to ignore all events from this module
//module.exports.RH_IGNORE_EVENTS_PRIMITIVE=true;//add this line to ignore all events_primitive from this module


//___________________________ETERNAL_VARIABLE_PART
module.exports.e={};
   module.exports.e.test="test";
//_________________________________________BOOTS_PART___________________________________________________
module.exports.boots = {}; 

module.exports.boots.someBoot={run:async(client)=>{try{
    //code to execut bot on loading
}catch(err){console.log(err);};}};//
//module.exports.boots.someBoot.RH_IGNORE=true;//add this line to ignore this command
//...
//_________________________________________COMMANDS_PART_________________________________________________
module.exports.commands = {};

module.exports.commands.someCommand={aliase:'aliase_for_command', run:async(client,message,args)=>{try{
   //code to execut then this command triggered
}catch(err){console.log(err);};}};//
//module.exports.commands.someCommand.RH_IGNORE=true;//add this line to ignore this command
// ...


//_________________________________________EVENTS_PART_________________________________________________
module.exports.events={};

module.exports.events.someEvent={ run:async(client,event_parametrs)=>{try{
    //code to execut then event occurs
}catch(err){console.log(err);};}};//
//module.exports.events.someEvent.RH_IGNORE=true;//add this line to ignore this event trigger
// ...
//_________________________________________EVENTS_PART_END__________________________________________

//______________________________EVENTS PRIMITIVE
module.exports.events_primitive={};

module.exports.events_primitive.SOME_EVENT_NAME={run:async(client,event)=>{try{
      //some code here
}catch(err){console.log(err);};}};//
//module.exports.events_primitive.SOME_EVENT_NAME.RH_IGNORE = true;//add this line to ignore this primitive event trigger
   EVENTS:
channelCreate
channelDelete
channelPinsUpdate
channelUpdate
clientUserGuildSettingsUpdate
clientUserSettingsUpdate
debug
disconnect
emojiCreate
emojiDelete
emojiUpdate
error
guildBanAdd
guildBanRemove
guildCreate
guildDelete
guildMemberAdd
guildMemberAvailable
guildMemberRemove
guildMembersChunk
guildMemberSpeaking
guildMemberUpdate
guildUnavailable
guildUpdate
message
messageDelete
messageDeleteBulk
messageReactionAdd
messageReactionRemove
messageReactionRemoveAll
messageUpdate
presenceUpdate
rateLimit
ready
reconnecting
resume
roleCreate
roleDelete
roleUpdate
typingStart
typingStop
userNoteUpdate
userUpdate
voiceStateUpdate
warn
Properties
//_________
EVENTS PRIMITIVE:(WSEvent)
READY
RESUMED
GUILD_SYNC
GUILD_CREATE
GUILD_DELETE
GUILD_UPDATE
GUILD_MEMBER_ADD
GUILD_MEMBER_REMOVE
GUILD_MEMBER_UPDATE
GUILD_MEMBERS_CHUNK
GUILD_ROLE_CREATE
GUILD_ROLE_DELETE
GUILD_ROLE_UPDATE
GUILD_BAN_ADD
GUILD_BAN_REMOVE
CHANNEL_CREATE
CHANNEL_DELETE
CHANNEL_UPDATE
CHANNEL_PINS_UPDATE
MESSAGE_CREATE
MESSAGE_DELETE
MESSAGE_UPDATE
MESSAGE_DELETE_BULK
MESSAGE_REACTION_ADD
MESSAGE_REACTION_REMOVE
MESSAGE_REACTION_REMOVE_ALL
USER_UPDATE
USER_NOTE_UPDATE
USER_SETTINGS_UPDATE
PRESENCE_UPDATE
VOICE_STATE_UPDATE
TYPING_START
VOICE_SERVER_UPDATE
RELATIONSHIP_ADD
RELATIONSHIP_REMOVE

// read more about events,websocet events and client methods :https://discord.js.org https://github.com/e3Dr8nj/npm_mdl_test