@abdevs/discord.js-utils 中文文档教程
Discord.js Utils (Re-Coded in TypeScript)
discord.js 库的实用程序包。 这包含 utils 函数和类,可轻松使用 Discord.js
Support
加入我们的 Discord Server 以获取任何与支持相关的查询。
Installation
npm i @abdevs/discord.js-utils
或 yarn add @abdevs/discord.js-utils
初始化
const discordUtils = require('@abdevs/discord.js-utils');
const { Client } = require('discord.js');
const client = new Client();
discordUtils.init(client, {
isCmdManager: true,
isHelpCommand: true,
cmdManagerOptions: { prefix, isPrefixMap: false },
});
client.login(token);
Options
Option | Default | Description |
---|---|---|
isCmdManager | false | Enables command manager |
isHelpCommand | false | Adds a help command |
cmdManagerOptions | { isPrefixMap: false, prefix: '!'} | Command Manager Options |
Features
Function / Class | Description |
---|---|
MessageQuestion | Builds message question object |
ReactionQuestion | Builds reaction question object |
QuestionsAPI | Build the questions API. Lets you easily ask long sets of questions from single or multiple users. |
askReactionQuestion | Lets your ask a single reaction question |
askMessageQuestion | Lets your ask a single message question |
ReactionMenu | Builds a reaction menu (Credits: Juby210) |
PaginationMenu | Builds a pagination menu (Credits: Thomas Jowsey) |
errorHandler | One liner error handler |
deepCloneWithLose | Deep clones a non-complex object |
isValidSnowflake | If the provide string is a valid snowflake |
fetchUser | Fetches a user |
fetchChannel | Fetches a channel |
fetchGuild | Fetches a guild |
fetchMember | Fetches a member |
fetchRole | Fetches a role |
toTimestamp | Converts string time eg: 5h2m into milliseconds |
toTimeLeft | Converts milliseconds to 1 Minute 20 Seconds format |
getRandomInt | A random number between the provided range |
findCodeBlock | Finds the groups between a string code block |
findEmoteById | Finds a emote by id |
isValidEmail | Checks if an email address is valid |
getConfig | Creates a config file or yml or json and returns the config object |
SpamHandler | Checks if a user is spamming |
getPrefix | Gets the default prefix or guild prefix |
getPrefixMap | Gets the guild prefix map |
registerCategory | Registers a category |
addCommand | Adds a command |
addMiddleware | Adds a middleware |
Examples
QuestionsAPI Example
const {
addCommand,
MessageQuestion,
ReactionQuestion,
QuestionsAPI,
} = require('@abdevs/discord.js-utils');
const { MessageEmbed } = require('discord.js');
module.exports = async () => {
addCommand({
command: 'helpme',
handler: async (message) => {
const typeEmbed = new MessageEmbed({
description: `What type of help you want?
❤: *Love Life*
????: *Money*`,
color: 'RANDOM',
});
const moreInfo = new MessageEmbed({
description: 'We need additional about your situation',
color: 'RANDOM',
});
const api = new QuestionsAPI();
const typeQuestion = new ReactionQuestion(message.author.id)
.setQuestion({ embed: typeEmbed, reply: message.author })
.setPossibleAnswers(['❤', '????'])
.setRun(({ reaction }) => {
if (reaction.emoji.name === '❤') return 'Love';
return 'Money';
});
const helpQuestion = new MessageQuestion(message.author.id)
.setQuestion({ embed: moreInfo, reply: message.author })
.setRun(({ message }) => message.content);
api.addQuestion([typeQuestion, helpQuestion]);
const { data } = await api.ask(message.channel);
const type = data[0].result;
const info = data[1].result;
const embed = new MessageEmbed({
description: `${message.author.toString()} needs help with **${type}**
*Here is some additional information:*
${info}`,
});
message.channel.send({ embed });
},
});
};
Terms and Conditions
此存储库仅供代码查找和个人使用。
您不得从该存储库中窃取代码。
Discord.js Utils (Re-Coded in TypeScript)
A utils package for discord.js lib. This contains utils function and classes to easily work with Discord.js
Support
Join our Discord Server for any support related queries.
Installation
npm i @abdevs/discord.js-utils
or yarn add @abdevs/discord.js-utils
Initialization
const discordUtils = require('@abdevs/discord.js-utils');
const { Client } = require('discord.js');
const client = new Client();
discordUtils.init(client, {
isCmdManager: true,
isHelpCommand: true,
cmdManagerOptions: { prefix, isPrefixMap: false },
});
client.login(token);
Options
Option | Default | Description |
---|---|---|
isCmdManager | false | Enables command manager |
isHelpCommand | false | Adds a help command |
cmdManagerOptions | { isPrefixMap: false, prefix: '!'} | Command Manager Options |
Features
Function / Class | Description |
---|---|
MessageQuestion | Builds message question object |
ReactionQuestion | Builds reaction question object |
QuestionsAPI | Build the questions API. Lets you easily ask long sets of questions from single or multiple users. |
askReactionQuestion | Lets your ask a single reaction question |
askMessageQuestion | Lets your ask a single message question |
ReactionMenu | Builds a reaction menu (Credits: Juby210) |
PaginationMenu | Builds a pagination menu (Credits: Thomas Jowsey) |
errorHandler | One liner error handler |
deepCloneWithLose | Deep clones a non-complex object |
isValidSnowflake | If the provide string is a valid snowflake |
fetchUser | Fetches a user |
fetchChannel | Fetches a channel |
fetchGuild | Fetches a guild |
fetchMember | Fetches a member |
fetchRole | Fetches a role |
toTimestamp | Converts string time eg: 5h2m into milliseconds |
toTimeLeft | Converts milliseconds to 1 Minute 20 Seconds format |
getRandomInt | A random number between the provided range |
findCodeBlock | Finds the groups between a string code block |
findEmoteById | Finds a emote by id |
isValidEmail | Checks if an email address is valid |
getConfig | Creates a config file or yml or json and returns the config object |
SpamHandler | Checks if a user is spamming |
getPrefix | Gets the default prefix or guild prefix |
getPrefixMap | Gets the guild prefix map |
registerCategory | Registers a category |
addCommand | Adds a command |
addMiddleware | Adds a middleware |
Examples
QuestionsAPI Example
const {
addCommand,
MessageQuestion,
ReactionQuestion,
QuestionsAPI,
} = require('@abdevs/discord.js-utils');
const { MessageEmbed } = require('discord.js');
module.exports = async () => {
addCommand({
command: 'helpme',
handler: async (message) => {
const typeEmbed = new MessageEmbed({
description: `What type of help you want?
❤: *Love Life*
????: *Money*`,
color: 'RANDOM',
});
const moreInfo = new MessageEmbed({
description: 'We need additional about your situation',
color: 'RANDOM',
});
const api = new QuestionsAPI();
const typeQuestion = new ReactionQuestion(message.author.id)
.setQuestion({ embed: typeEmbed, reply: message.author })
.setPossibleAnswers(['❤', '????'])
.setRun(({ reaction }) => {
if (reaction.emoji.name === '❤') return 'Love';
return 'Money';
});
const helpQuestion = new MessageQuestion(message.author.id)
.setQuestion({ embed: moreInfo, reply: message.author })
.setRun(({ message }) => message.content);
api.addQuestion([typeQuestion, helpQuestion]);
const { data } = await api.ask(message.channel);
const type = data[0].result;
const info = data[1].result;
const embed = new MessageEmbed({
description: `${message.author.toString()} needs help with **${type}**
*Here is some additional information:*
${info}`,
});
message.channel.send({ embed });
},
});
};
Terms and Conditions
This Repository only available for code look up and personal use.
You are not allowed to steal the code from this repository.
更多
你可能也喜欢
- 1a 中文文档教程
- @0x-lerna-fork/diff 中文文档教程
- @10play/popups 中文文档教程
- @12stonechurch/react-native-chromecast 中文文档教程
- @3t-transform/transform-datatransformation-lib 中文文档教程
- @a-sync/opencv-build 中文文档教程
- @aapokiiso/hsl-congestion-route-repository 中文文档教程
- @abancu/explorer-plugin-eth-memento 中文文档教程
- @abbica/cdk 中文文档教程
- @abdt/ornament 中文文档教程