Skip to content

Commit

Permalink
⏰ Added seconds to valid times (eg: 2s), fixed image attachments on i…
Browse files Browse the repository at this point in the history
…mgedit
  • Loading branch information
wiki-Bird committed Nov 12, 2023
1 parent 31cddb3 commit be83f39
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/commands/imgedit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ const imgedit: Command = {
}
else if (!user && attachment) {
// if attachment is not an image, return
if (!attachment.url.endsWith(".png") && !attachment.url.endsWith(".jpg") && !attachment.url.endsWith(".jpeg") && !attachment.url.endsWith(".gif")) {
interaction.editReply({ content: "You must specify a jpg, gif, or png image." });
console.log(attachment.contentType)
// if (!attachment.url.endsWith(".png") && !attachment.url.endsWith(".jpg") && !attachment.url.endsWith(".jpeg") && !attachment.url.endsWith(".gif")) {
if (!attachment.contentType!.startsWith("image/")) {
interaction.editReply({ content: "You must upload an image." });
return;
}
image = attachment.url;
Expand Down
6 changes: 3 additions & 3 deletions src/functions/validateDuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default async function validateDuration(time: string, interaction: Comman
// first part of time will be a number, the second part will be m/min, h/hrs/hours/etc, d. Break it into these two parts.
let midPoint = 0;
for (let i = 0; i < time.length; i++) {
if (time[i] === 'm' || time[i] === 'h' || time[i] === 'd') {
if (time[i] === 'm' || time[i] === 'h' || time[i] === 'd' || time[i] === 's') {
midPoint = i;
break;
}
Expand All @@ -27,7 +27,7 @@ export default async function validateDuration(time: string, interaction: Comman
}

const timeNumber = time.slice(0, midPoint);
const timeUnit = time[midPoint]; // D.js only handles m, h, d, so we don't need to check for anything else -- even if the user enters it.
const timeUnit = time[midPoint]; // D.js only handles m, h, d, s, so we don't need to check for anything else -- even if the user enters it.

// check if timeNumber is a number
if (isNaN(Number(timeNumber)) === true) {
Expand All @@ -41,7 +41,7 @@ export default async function validateDuration(time: string, interaction: Comman
}

return {
timeInMS: Number(timeNumber) * (timeUnit === 'm' ? 60000 : timeUnit === 'h' ? 3600000 : timeUnit === 'd' ? 86400000 : 0),
timeInMS: Number(timeNumber) * (timeUnit === 'm' ? 60000 : timeUnit === 'h' ? 3600000 : timeUnit === 'd' ? 86400000 : timeUnit === 's' ? 1000 : 0),
timeString: timeNumber + timeUnit
}

Expand Down
6 changes: 2 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ const commandCheck = async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

// ESlint doesn't like this, but any is needed
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const data:any = await rest.put(
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
) as unknown[];

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
Expand Down

0 comments on commit be83f39

Please sign in to comment.