Urban Bot

Urban Bot

  • Docs
  • GitHub

›Bots

Getting Started

  • Intro
  • Telegram

Tutorials

  • Todo List

API

  • Components
  • Hooks
  • Bots

    • Telegram
    • Discord
    • Facebook
    • Slack

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

discord.js

function SomeComponent() {
    useText(({ text, nativeEvent }) => {
        if (text.includes('Fu**')) {
            nativeEvent.payload?.member?.kick();
        }
    });

    // ...
}
← TelegramFacebook →
  • Options
  • Bot Instance
Docs
Get StartedComponentsHooksTelegramDiscordFacebookSlack
Community
Telegram
Links
Urban Bot
Copyright © 2022 German Smirnov and Ivan Pakhotin