T
T
TolaF2020-04-14 12:31:26
JavaScript
TolaF, 2020-04-14 12:31:26

How to make a !say command in a bot?

Please tell me the code for the !say command.
(!say [text])
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kiljko, 2020-04-14
@TolaF

client.on('message', msg => {
  if (msg.content === '!say') {
    const text = message.content.split(' ').slice(1).join(' ');

    msg.reply(text);
  }
});

1
1loveu, 2020-04-14
@1loveu

const Discord = require("discord.js");
const pf = "!"; // your prefix
const bot = new Discord.Client();
bot.on('message', message => {
if (message.content === pf+'say') {
const text = message.content.split('|||').slice(1).join(' '); //
let gg = new Discord.RichEmbed()
.setDescription(text[0])
.setTitle(text[1])
.setColor("#ff5733")
message.channel.send(gg);
msg.react ('✅')
.then(console.log)
.catch(console.error);
}
}
});
bot.login("your bot's token")
there are a lot of errors ||| maybe it doesn't work...
https://discordjs.guide/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question