mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 13:56:43 +02:00
Improve Cleverbot
This commit is contained in:
@@ -49,12 +49,15 @@ client.registry
|
|||||||
.registerCommandsIn(path.join(__dirname, 'commands'));
|
.registerCommandsIn(path.join(__dirname, 'commands'));
|
||||||
|
|
||||||
client.on('message', async (msg) => {
|
client.on('message', async (msg) => {
|
||||||
|
if (msg.author.bot) return;
|
||||||
|
if (msg.channel.type === 'dm')
|
||||||
|
if (!msg.channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
|
||||||
if (msg.isMentioned(client.user)) {
|
if (msg.isMentioned(client.user)) {
|
||||||
msg.channel.startTyping();
|
msg.channel.startTyping();
|
||||||
const message = msg.content.replace(mention, '');
|
const message = msg.content.replace(mention, '');
|
||||||
try {
|
try {
|
||||||
const { body } = await clevs.ask(message);
|
const { response } = await clevs.ask(message);
|
||||||
return msg.reply(body.response)
|
return msg.reply(response)
|
||||||
.then(() => msg.channel.stopTyping());
|
.then(() => msg.channel.stopTyping());
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(err)
|
return msg.reply(err)
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "18.9.3",
|
"version": "18.9.4",
|
||||||
"description": "A Discord Bot",
|
"description": "A Discord Bot",
|
||||||
"main": "shardingmanager.js",
|
"main": "shardingmanager.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ class Cleverbot {
|
|||||||
user: this.user,
|
user: this.user,
|
||||||
key: this.key,
|
key: this.key,
|
||||||
nick: this.nick
|
nick: this.nick
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
return response.body;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,6 +28,9 @@ class Cleverbot {
|
|||||||
key: this.key,
|
key: this.key,
|
||||||
nick: this.nick,
|
nick: this.nick,
|
||||||
text
|
text
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
return response.body;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user