Working with discord bots

How do i make my bot respond to !hello

Read the docs for the library you are using

1 Like

where are the docs @anon43649539

What library are you using?

wdym by library @anon43649539

discordjs, discordpy, jdm, eris etc?

i just remixed the starter-discord.glitch.me starter kit

I’m pretty sure that is discord.js

1 Like
1 Like

It’s actually Botkit for Discord.js, and not Discord.js.

1 Like

Try
const Discord = require(‘discord.js’);

// create a new Discord client

const config = require(’./config.json’);

const client = new Discord.Client();
bot.on(‘ready’, () =>{

Tags.sync();

console.log(‘Online’);

bot.user.setActivity(‘Piggy [Alpha] CHAPTER 12!’, { type: ‘PLAYING’}).catch(console.error);

});

if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
client.on(‘message’, message => {
if (message.content.startsWith($prefix}hi)) {
const embed = new RichEmbed()

        .setTitle("Hi ! Hope your having a good time! ")

        .setColor(0xFF0000)

        .setDescription("Make sure to use the !help to get access to the commands");

        message.author.send(embed);

} else if // your other commands

client.login(your-token)

config.json file :
{

"prefix": "prefix here",

"token": "token here"

}

@DaRealMiniToon, next time you send code in this forum, can you please wrap it in back-ticks (```) so that the code is readable, like this:

image

will become

console.log("wrap your code in backticks");

It makes reading of the code easier for other support users!

4 Likes

hi okay I realized!

1 Like

Thank you so much for saying this, this makes the code 1000% easier to read.

2 Likes

All bot instances would need to be changed to client as that’s the name of your new client.