Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
🐛 (embeds ) fix embeds not sending due to body size
Browse files Browse the repository at this point in the history
todo embeds were erroring because the description body size grew too big, fixed by seperating tasks into one field per task

Closes #29
  • Loading branch information
MeerBiene committed Apr 10, 2021
1 parent e2c7b05 commit a622104
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion TODOBOT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const apm = require('elastic-apm-node')
apm.start({
serverUrl: process.env.DEBUG_URL_APM_SERVER,
serviceName: process.env.BOT_NAME,
environment: 'development',
environment: process.env.ELASTIC_ENV
// uncomment this for troubleshooting the apm agent
// logLevel: 'trace',
})
Expand Down
2 changes: 1 addition & 1 deletion TODOBOT/interactions/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = {
// split the string containing the tasks at the semicolon and filter out all empty
// tasks as well as task strings that are too long. If theres more than 10, were just
// capping the array by setting the length to 10
let temp = interaction.data.options[index].value.split(';').filter(task => task !== '' && task.length < 110);
let temp = interaction.data.options[index].value.split(';').filter(task => task !== '' && task.length < 1020);
if (temp.length > 10) temp.length = 10;
todoobject.tasks = temp
} else {
Expand Down
15 changes: 11 additions & 4 deletions TODOBOT/modules/util/embeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,28 @@ module.exports = (client) => {
if (todoobj.tasks && todoobj.tasks.length > 0) {
let output = '';
let count = 0;
let tasks = [];
let progressBar = [];

for (let i = 0; i < todoobj.tasks.length; i++) {
output += `${todoobj.tasks[i].includes('finished_') ? '<:checksquareregular:820384679562838046> ' + todoobj.tasks[i].replace('finished_', '') : '<:squareregular:820381667881517118> ' + todoobj.tasks[i]} \n`
output = `${todoobj.tasks[i].includes('finished_') ? '<:checksquareregular:820384679562838046> ' + todoobj.tasks[i].replace('finished_', '') : '<:squareregular:820381667881517118> ' + todoobj.tasks[i]}`
tasks.push(output);
if (todoobj.tasks[i].includes('finished_')) {
count++
progressBar.push(client.emojiMap['+']);
} else {
progressBar.push(client.emojiMap['-']);
};
}

embed.addField(`Tasks (${count} / ${todoobj.tasks.length}): \n ${progressBar.join('')}`, `${output}`)

embed.addField(`Tasks (${count} / ${todoobj.tasks.length}):`, `${progressBar.join('')}`)

for (let j = 0; j < tasks.length; j++) embed.addField('\u200b', tasks[j]);


}

if (todoobj.content) embed.addField("Content", `> ${todoobj.content}`);
if (todoobj.content) embed.addField("Content", `> ${ todoobj.content.length >= 1024 ? todoobj.content.slice(0, 1020) + '...' : todoobj.content }`);
if (todoobj.category) embed.addField("Category", todoobj.category, true);
if (todoobj.attachlink) attacher();

Expand Down
1 change: 1 addition & 0 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
BOT_NAME=TODOBOT

PM2_NAME=
ELASTIC_ENV=production

# Discord Authentification stuff production
TOKEN=your_token
Expand Down

0 comments on commit a622104

Please sign in to comment.