New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fishy-bot-framework

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fishy-bot-framework

A basic framework for making interaction based discord bot

latest
Source
npmnpm
Version
0.3.3
Version published
Maintainers
1
Created
Source

FishyBot Framework

A framework for creating complex discord bots easily.

How to use:

  • install the package with npm install fishy-bot-framework -s
  • import the package with either import * as FBF from "fishy-bot-framework" or const FBF = require("fishy-bot-framework")
  • Start a new client:
import * as FBF from "fishy-bot-framework"
const client = new FBF.FishyClient({
  token:"discord bot token",
  author:"Your name",
  db_uri: "mongodb://myDBReader:D1fficultP%40ssw0rd@mongos0.example.com:27017",
  guild_model: GuildModel,
  cmd_dir: "dist/commands",
})
client.login()

Commands:

A basic command should look something like this

// The code that gets run when the command gets called;
// It takes the arguments `FishyClient` and `Interaction`
export const run: FishyCommandCode = async (client, interaction) => {
  interaction.send(`Current websocket ping: \`${client.ws.ping}ms\``);
};

// The configuration of the commands, it needs this to run
export const config: FishyCommandConfig = {
  name: "ping",               // Name of the command
  bot_needed: false,          // If the bot user is required to be in the guild
                              // Needed for `Interaction.channel.send()` for example
  user_perms: [],             // An array of permissions the user needs to run the command
  interaction_options: {      // Discord interaction options
                              // https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command-json-params
    name: "ping",
    description: "Ping the bot"
  },
};

Use these steps to create a new category

create - /commands/"category"/
create - /commands/"category"/index.ts
export - "name" & "description" from /commands/"category"/index.ts
create - /commands/"category"/command.ts

Example:

image

Buttons!

To create a button you can run:

interaction.send("Message", {
  components: [
    {
      type: ComponentType.ActionRow,
      components: [
        {
          type: ComponentType.Button,
          style: ComponentStyle.Success,
          label: "HEY",
          custom_id: "send_ping",
        },
      ],
    },
  ],
});

To run code when this button is pressed, you can create a new file just like a normal command. You can put this file anywhere you can place a normal command.

Put this code in the new file:

export const run: FishyComponentCommandCode = async (client, interaction) => {
  if (interaction instanceof ButtonInteraction) {
    const memberID = interaction.data.custom_id.slice(config.custom_id.length);
    const member = await interaction.guild?.members.fetch(memberID);
    await member?.kick();
    interaction.send("Kicked the member!");
  }
};

export const config: FishyComponentCommandConfig = {
  custom_id: "kick_",
  atStart: true,
  bot_needed: true,
  user_perms: ["KICK_MEMBERS"],
};

Select menus

To send a select menu, just like a button, you need to send message components

interaction.send("oi", {
  components: [
    {
      type: ComponentType.ActionRow,
      components: [
        {
          type: ComponentType.Select,
          custom_id: "selectOption",
          options: [
            {
              label:"Option 1", value:"1",
              label:"Option 2", value:"2",
              label:"Option 3", value:"3",
              label:"Option 4", value:"4",
              label:"Option 5", value:"5",
            }
          ],
          max_values: 3,
          min_values: 1,
        },
      ],
    },
  ],
})

Then to do something with them

export const run: FishyComponentCommandCode = async (client, interaction) => {
  if (interaction instanceof SelectInteraction) {
    interaction.sendSilent(`You have selected: \`${interaction.data.values.join(", ")}\``);
  }
};

export const config: FishyComponentCommandConfig = {
  custom_id: "selectOption",
};

Events

A basic event file should look something like this:

export const trigger: WSEventType | string = "INTERACTION_CREATE";
export async function run(client, data){

};

Database

Required Mongoose data fields:

{
  id: String,     // The guild's id for fetching, index this
  settings: Object   // Used for disabeling commands
}

FAQs

Package last updated on 23 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts