diff --git a/src/discord/commands/global/d.testkits.ts b/src/discord/commands/global/d.testkits.ts index 60d232dd3..516a4ee17 100644 --- a/src/discord/commands/global/d.testkits.ts +++ b/src/discord/commands/global/d.testkits.ts @@ -24,20 +24,43 @@ export default { const embed = embedTemplate(); embed.setTitle('Test Kit Resources and information!'); - // for (const entry of emsInfo) { - emsInfo.forEach(entry => { - const website = `\n[Website](${entry.website})`; - embed.addFields( - { - name: `${entry.name} (${entry.country})`, - value: stripIndents`${entry.website ? website : ''}\ - ${entry.description ? ` - ${entry.description}` : ''} - `, - inline: true, - }, - ); - }); + + const fieldsPerRow = 3; // Set fields per row to 3 + const totalFields = emsInfo.length; + + // Group fields into rows + const rows = Math.ceil(totalFields / fieldsPerRow); // Total number of rows + + // Iterate over the number of rows and add fields to each row + for (let rowIndex = 0; rowIndex < rows; rowIndex += 1) { + const startIndex = rowIndex * fieldsPerRow; + const endIndex = Math.min(startIndex + fieldsPerRow, totalFields); // Prevent going out of bounds + const rowFields = emsInfo.slice(startIndex, endIndex); // Get fields for this row + + rowFields.forEach((entry, index) => { + const website = entry.website ? `\n[Website](${entry.website})` : ''; // Move ternary outside template literal + const description = entry.description ? `\n${entry.description}` : ''; + embed.addFields( + { + name: `${startIndex + index + 1}. ${entry.name} (${entry.country})`, + value: stripIndents`${website}${description}`, + inline: true, // Ensure all fields are inline + }, + ); + }); + + // Add invisible fields only if the row is not completely filled + if (rowFields.length < fieldsPerRow) { + const remainingSpaces = fieldsPerRow - rowFields.length; + for (let i = 0; i < remainingSpaces; i += 1) { + embed.addFields({ + name: '\u200b', // Invisible field + value: '\u200b', + inline: true, + }); + } + } + } embed.setDescription(stripIndents` [How to use a reagent test kit](https://dancesafe.org/testing-kit-instructions/) [How to use fentanyl strips](https://dancesafe.org/fentanyl/) diff --git a/src/discord/tests/testkits.test.ts b/src/discord/tests/testkits.test.ts index 5989b4f0d..71336543d 100644 --- a/src/discord/tests/testkits.test.ts +++ b/src/discord/tests/testkits.test.ts @@ -45,13 +45,6 @@ describe(slashCommand.data.name, () => { [Info on the new test strips](https://dancesafe.org/fentanyl/)`, inline: true, }, - { - name: 'Dosetest (Worldwide)', - value: stripIndents` - [Website](https://dosetest.com/) - 20% off test kits with code TripSit!`, - inline: true, - }, { name: 'ReagentTests UK (UK & EU)', value: stripIndents` diff --git a/src/global/commands/g.testkits.ts b/src/global/commands/g.testkits.ts index 04db89bbc..9d7ac5ddb 100644 --- a/src/global/commands/g.testkits.ts +++ b/src/global/commands/g.testkits.ts @@ -18,12 +18,6 @@ export default async function testkits():Promise { website: 'https://dancesafe.org/product-category/testing-strips/', description: '[Info on the new test strips](https://dancesafe.org/fentanyl/)', }, - { - name: 'Dosetest', - country: 'Worldwide', - website: 'https://dosetest.com/tripsit', - description: '20% off with code TripSit (Affiliate link)', - }, { name: 'Protest', country: 'Europe', @@ -40,7 +34,7 @@ export default async function testkits():Promise { name: 'EZ Test', country: 'Australia', website: 'http://ez-test.com.au/', - description: '10% off with TripsitAusOct\n15% off with TripsitAusNov', + description: '', }, { name: 'Test Drogue',