-
Notifications
You must be signed in to change notification settings - Fork 19
Usage
Tim K edited this page Feb 26, 2017
·
9 revisions
This section will talk about basic usage of the bot and how you can configure some advanced features. For more information, see Configuration.
Create a file called index.js
and put the following inside:
'use strict';
const SpoilerBot = require('discord-spoiler-bot');
let config = {
token: 'you_secret_token_here',
};
let bot = new SpoilerBot(config);
bot.connect();
Note the config object, it is required for Discord Spoiler Bot to work. Once you save the file, you can run your bot using Node.js:
$ node index.js
If you follow the basic usage instructions above, spoiler bot will create a new Client
instance from discord.js library. If you already have an instance of Client
from discord.js or discord.io libraries running and want to avoid duplicating the bot, you can pass the existing instance as client
in the config object.
E.g. for discord.js:
'use strict';
const Discord = require('discord.js');
const SpoilerBot = require('discord-spoiler-bot');
let client = new Discord.Client();
client.login('your_token_here');
let config = {
client: client,
};
let bot = new SpoilerBot(config);
bot.connect();
Or for discord.io:
'use strict';
const Discord = require('discord.io');
const SpoilerBot = require('discord-spoiler-bot');
let client = new Discord.Client({
autorun: true,
token: 'your_token_here'
});
let config = {
client: client,
};
let bot = new SpoilerBot(config);
bot.connect();