UrbanBotDiscord
Urban bot part which is responsible to launch discord bot.
Install
npm i @urban-bot/discord --save
yarn add @urban-bot/discord
Usage
import { render, Root, Text } from '@urban-bot/core';
import { UrbanBotDiscord } from '@urban-bot/discord';
const urbanBotDiscord = new UrbanBotDiscord({
token: 'discordToken',
intents: ['GUILDS', 'GUILD_MESSAGES', 'DIRECT_MESSAGES', 'DIRECT_MESSAGE_REACTIONS'],
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
});
render(
<Root bot={urbanBotDiscord}>
<Text>Hello, Discord!</Text>
</Root>,
);
Options
token
A discord token. You can get it from https://discord.com/developers/applications/PASTE_YOUR_ID/bot
required
string
const urbanBotDiscord = new UrbanBotDiscord({
token: 'ODg8MDEzODM3NDU3OTEzODU5.YUMhVA.YdPFx-QL1iwWeczrIV1A2-53XoQ',
});
intents
Discord bot intents https://discordjs.guide/popular-topics/intents.html#privileged-intents.
required
string[]
const urbanBotDiscord = new UrbanBotDiscord({
intents: ['GUILDS', 'GUILD_MESSAGES', 'DIRECT_MESSAGES', 'DIRECT_MESSAGE_REACTIONS'],
});
partials
Discord bot partials https://discordjs.guide/popular-topics/partials.html#enabling-partials
optional
string[]
const urbanBotDiscord = new UrbanBotDiscord({
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
});
other
All options from https://discord.js.org/#/docs/main/stable/typedef/ClientOptions
Bot Instance
You could get bot instance by useBotContext
.
function SomeComponent() {
const { bot } = useBotContext();
// ...
}
type
Bot type.
required
'DISCORD'
nativeEvent
A nativeEvent which you can use for call any Discord.js API.
required
function SomeComponent() {
useText(({ text, nativeEvent }) => {
if (text.includes('Fu**')) {
nativeEvent.payload?.member?.kick();
}
});
// ...
}