fix(discord-bot): only send lowercased text

This commit is contained in:
GramingFoxTeam
2022-11-16 18:09:42 +03:00
parent 92571085b7
commit 78037580dc
5 changed files with 6 additions and 5 deletions

View File

@@ -45,7 +45,7 @@ export default {
collector.on('collect', (i) => { collector.on('collect', (i) => {
i.client.helper.sendTrainData( i.client.helper.sendTrainData(
interaction.targetMessage.content, interaction.targetMessage.content.toLowerCase(),
i.values[0].toUpperCase() i.values[0].toUpperCase()
); );

View File

@@ -8,6 +8,8 @@ export default {
if (!response) return; if (!response) return;
if (Number(aiRes.predictions[0].score) >= response.threshold) { if (Number(aiRes.predictions[0].score) >= response.threshold) {
if (!response.text) return;
const ids = aiRes.id.split('/'); const ids = aiRes.id.split('/');
let channel = global.client.channels.cache.get(ids[0]); let channel = global.client.channels.cache.get(ids[0]);

View File

@@ -1,7 +1,6 @@
export default { export default {
command: /\/train/, command: /\/train/,
async execute(msg) { async execute(msg) {
console.log(msg);
if (msg.reply_to_message.message_id === msg.message_thread_id) if (msg.reply_to_message.message_id === msg.message_thread_id)
return global.bot.sendMessage(msg.chat.id, 'Please reply to a message!', { return global.bot.sendMessage(msg.chat.id, 'Please reply to a message!', {
message_thread_id: msg.message_thread_id, message_thread_id: msg.message_thread_id,

View File

@@ -10,6 +10,8 @@ export default {
if (Number(aiRes.predictions[0].score) >= response.threshold) { if (Number(aiRes.predictions[0].score) >= response.threshold) {
const ids = aiRes.id.split('/'); const ids = aiRes.id.split('/');
if (!response.text) return;
global.bot.sendMessage(ids[0], response.text, { global.bot.sendMessage(ids[0], response.text, {
message_thread_id: ids[1], message_thread_id: ids[1],
reply_to_message_id: ids[2] reply_to_message_id: ids[2]

View File

@@ -3,9 +3,7 @@ export default {
once: false, once: false,
async execute(cb) { async execute(cb) {
const admins = await global.bot.getChatAdministrators(cb.message.chat.id); const admins = await global.bot.getChatAdministrators(cb.message.chat.id);
const isAdmin = admins.find( const isAdmin = admins.find((admin) => admin.user.id === cb.from.id);
(admin) => admin.user.id === cb.from.id
);
if (!isAdmin) if (!isAdmin)
return global.bot.sendMessage( return global.bot.sendMessage(