Skip to content

Commit

Permalink
fix(testkits): remove dosetest, old discounts, fix formatting for 5 c…
Browse files Browse the repository at this point in the history
…olumns
  • Loading branch information
theimperious1 authored Nov 9, 2024
1 parent b3e68be commit a58f4de
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 28 deletions.
51 changes: 37 additions & 14 deletions src/discord/commands/global/d.testkits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
7 changes: 0 additions & 7 deletions src/discord/tests/testkits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
8 changes: 1 addition & 7 deletions src/global/commands/g.testkits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ export default async function testkits():Promise<HelpResource[]> {
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',
Expand All @@ -40,7 +34,7 @@ export default async function testkits():Promise<HelpResource[]> {
name: 'EZ Test',
country: 'Australia',
website: 'http://ez-test.com.au/',
description: '10% off with TripsitAusOct\n15% off with TripsitAusNov',
description: '',
},
{
name: 'Test Drogue',
Expand Down

0 comments on commit a58f4de

Please sign in to comment.