Create a basic bot
Let's create a basic pong bot!
If you haven't created the bot application on Guilded or copied your bots auth token follow the below.
Setting up a Guilded botCreate the bots main file
Let's create an index.js or index.ts file so that we can have our bot login!
// index.js
// Import the guilded client
const { Client } = require('guilded.js');
/**
* Create an instance of the client class
* To be even more secure use environment variables or a config.json!
*/
const client = new Client({
token: 'your-super-secret-bot-token',
});
// When the bot connects successfully, log to the console.
client.on('ready', () => {
console.log(`Bot is successfully logged in as ${client.user.name}`);
});
// Login to Guilded
client.login();
// index.ts
// Import the guilded client
import { Client } from 'guilded.js';
/**
* Create an instance of the client class
* To be even more secure use environment variables or a config.json!
*/
const client = new Client({
token: 'your-super-secret-bot-token',
});
// When the bot connects successfully, log to the console.
client.on('ready', () => {
console.log(`Bot is successfully logged in as ${client.user?.name}`);
});
// Login to Guilded
client.login();Last updated
Was this helpful?