@2pg/music 中文文档教程
2PG Music
2PG 使用的简单音乐模块,使用 TypeScript 构建。
文档 - https://twopg.github.io/music
Example
npm i -S @2pg/music discord.js
< strong>ES6:
import { Client } from 'discord.js';
import { MusicClient } from '@2pg/music';
const music = new MusicClient();
const bot = new Client();
music.on('trackStart', (player, track) => player.textChannel?.send(`\`${track.title}\` - **${track.requestor}** started.`));
bot.on('message', async (msg) => {
if (msg.author.bot) return;
if (msg.content === '.play') {
const player = getPlayer(msg);
await player.play('discord bot dashboard intro', { member: msg.member });
}
});
function getPlayer(msg) {
return music.get(msg.guild.id)
?? music.create({
voiceChannel: msg.member.voice.channel,
textChannel: msg.channel
});
}
bot.login('<your_bot_token>');
2PG Music
Simple music module, built with TypeScript, used by 2PG.
Docs - https://twopg.github.io/music
Example
npm i -S @2pg/music discord.js
ES6:
import { Client } from 'discord.js';
import { MusicClient } from '@2pg/music';
const music = new MusicClient();
const bot = new Client();
music.on('trackStart', (player, track) => player.textChannel?.send(`\`${track.title}\` - **${track.requestor}** started.`));
bot.on('message', async (msg) => {
if (msg.author.bot) return;
if (msg.content === '.play') {
const player = getPlayer(msg);
await player.play('discord bot dashboard intro', { member: msg.member });
}
});
function getPlayer(msg) {
return music.get(msg.guild.id)
?? music.create({
voiceChannel: msg.member.voice.channel,
textChannel: msg.channel
});
}
bot.login('<your_bot_token>');
更多
你可能也喜欢
- 3e 中文文档教程
- @0confirmation/sdk 中文文档教程
- @1onlinesolution/dws-session 中文文档教程
- @36node/telegram 中文文档教程
- @3test/ethereum-bitski-frontend-provider 中文文档教程
- @51xuanshi/wxapp_component 中文文档教程
- @aaxis/react-native-secure-storage 中文文档教程
- @abext/notifications 中文文档教程
- @abhishekrajeshirke/axios-curlirize 中文文档教程
- @abmcode/fe-core 中文文档教程