@21x37/discord-bot 中文文档教程

发布于 6年前 浏览 35 项目主页 更新于 3年前

@21x37/discord-bot

使用这个 npm 模块轻松设置 discord 机器人! ????️

Install

npm install @21x37/discord-bot

Usage

const discordBot = require('@21x37/discord-bot');

const options ={
    token: 
    isModerating,
    isGreeting,
    emotes
};

Token is the discord token received from https://discordapp.com/developers/applications

const token = process.env.DISCORD_TOKEN

isModerating is a boolean, true or false. If you want the bot to have !kick and !ban commands.

const isModerating = true;

在不和谐

!kick @username

isGreeting is a object with possibly three properties.

  • Boolean is if the greeting is active or not.
  • Message is the message you want displayed when a person joins the channel. The username if the new user will immediately be added to the end of the string.
  • Channel is the channel name of where you want the greeting to be.
const isGreeting = { boolean: true, message: 'Welcome!', 'general' };

Emotes is an ARRAY of objects where each object will have the command and a url to the image.

const emotes = [
  { command: '!foo', url: 'https://www.bar.com/thevalueofbar.jpg' }
]

To start the bot.

const bot = new discordBot(options);
bot.start();

Example

const discordBot = require('@21x37/discord-bot');

const options = {
    token: process.env.DISCORD_TOKEN,
    isModerating: true,
    isGreeting: { active: true, message: 'Welcome to our server!', channelName: 'general' },
    emotes: [{ command: '!pepeHands', url: 'https://i.kym-cdn.com/entries/icons/original/000/025/382/Screen_Shot_2018-02-06_at_3.37.14_PM.png' }],
}

const bot = new discordBot(options);

bot.start();

中然后只需在 cli 中节点您的文件。

node discordBot.js

@21x37/discord-bot

Easily setup a discord bot with this npm module! ????️

Install

npm install @21x37/discord-bot

Usage

const discordBot = require('@21x37/discord-bot');

const options ={
    token: 
    isModerating,
    isGreeting,
    emotes
};

Token is the discord token received from https://discordapp.com/developers/applications

const token = process.env.DISCORD_TOKEN

isModerating is a boolean, true or false. If you want the bot to have !kick and !ban commands.

const isModerating = true;

In discord

!kick @username

isGreeting is a object with possibly three properties.

  • Boolean is if the greeting is active or not.
  • Message is the message you want displayed when a person joins the channel. The username if the new user will immediately be added to the end of the string.
  • Channel is the channel name of where you want the greeting to be.
const isGreeting = { boolean: true, message: 'Welcome!', 'general' };

Emotes is an ARRAY of objects where each object will have the command and a url to the image.

const emotes = [
  { command: '!foo', url: 'https://www.bar.com/thevalueofbar.jpg' }
]

To start the bot.

const bot = new discordBot(options);
bot.start();

Example

const discordBot = require('@21x37/discord-bot');

const options = {
    token: process.env.DISCORD_TOKEN,
    isModerating: true,
    isGreeting: { active: true, message: 'Welcome to our server!', channelName: 'general' },
    emotes: [{ command: '!pepeHands', url: 'https://i.kym-cdn.com/entries/icons/original/000/025/382/Screen_Shot_2018-02-06_at_3.37.14_PM.png' }],
}

const bot = new discordBot(options);

bot.start();

Then just node your file in the cli.

node discordBot.js
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文