New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

myteams-api

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

myteams-api

An MyTeams Module to use discord.js easily

  • 2.0.1
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

MyTeams Helper.

A simple api to use discord.js easily.

Client:

  • The client to login with Discord.js.
  • Parameters: client: Discord.Client, token: String.
/**
 * @example Client example
 **/

const { HelperClient } = require("myteams"); //Here we require the client.
const Discord = require("discord.js");
const client = new Discord.Client(); //Makes djs client.

new HelperClient(client, "token here"); //Creates the ready event an login with the provided token.

Command Handling:

  • A CommandHandler with sub-folders.
  • Parameters:
  • path: string //The path of the folder.
  • client: Client //Discord.js client.
  • log: boolean //Log all commands if its true. Default: true.
  • Collection: Discord.Collection //Discord collection for commands.
/**
 * @example Handler Example
 **/

const Discord = require("discord.js");
const path = require("path");
const client = new Discord.Client({ intents: 32767 });
const myteams = require("myteams-api");
client.commands = new Discord.Collection();

myteams.RegisterCommand(
  path.join(__dirname, "./commands"),
  client,
  true,
  client.commands
);

client.on("messageCreate", async (message) => {
  const prefix = "m!";
  if (!message.content.startsWith(prefix)) return;

  let args = message.content.slice(prefix.length).trim().split(/ +/g);
  let command = args.shift().toLowerCase();

  let cmd =
    client.commands.get(command) ||
    client.commands.find((c) => c.alias.includes(command));

  if (!cmd) return;

  if (cmd) {
    cmd.run(client, message, args);
  }
});

Slash Command Handling

  • A slash command handler.
  • Parameters:
  • client: Client //A Discord.js client.
  • folderName: string //The name of the folder of slash commands.
  • Collection: Discord.Collection //The Collection of the slash handler.
  • guild< Optional >: The guild to deploy the slash, if there its no guild the deploy will be global.
/**
 * @example Slash Command Handling
 **/
const Discord = require("discord.js");
const client = new Discord.Client({ intents: 32767 });
const myteams = require("myteams-api");
client.commands = new Discord.Collection();
client.slashCommands = new Discord.Collection();

myteams.RegisterSlash(
  client,
  "SlashCommands",
  client.slashCommands,
  "Guild id (optional) if doesnt have guild the deploy its glolal"
);

client.on("interactionCreate", async (interaction) => {
  if (interaction.isCommand()) {
    await interaction.deferReply({ ephemeral: false }).catch(() => {});

    const cmd = client.slashCommands.get(interaction.commandName);
    if (!cmd) {
      interaction.editReply("That command doesn't exists!");
    }

    const args = [];

    for (let option of interaction.options.data) {
      if (option.type === "SUB_COMMAND") {
        if (option.name) args.push(option.name);
        option.options?.forEach((x) => {
          if (x.value) args.push(x.value);
        });
      } else if (option.value) args.push(option.value);
    }

    cmd.run(client, interaction, args);
  }
});

ChatBot:

  • ChatBot. An easy chatbot without API Key.

  • Parameters:

  • input: string //Input for the chatbot.
  • message: Message //Discord.js message class.
  • uuid: string //Degaults to author's id.
chatBot(options: ChatBotOptions): Promise<string>

Keywords

FAQs

Package last updated on 14 Aug 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc