Skip to content

Commit

Permalink
build(deps): bump discord.js from 14.16.3 to 14.17.2 (#66)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
dependabot[bot] authored Jan 2, 2025
1 parent 980a875 commit fd11e6b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 102 deletions.
40 changes: 25 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import "dotenv/config";
import { Client, Events, GatewayIntentBits, Partials } from "discord.js";
import {
Client,
Events,
GatewayIntentBits,
MessageFlags,
Partials,
} from "discord.js";
import { DateTime } from "luxon";

const SUPPORTED_TIMEZONES = Intl.supportedValuesOf("timeZone");
Expand Down Expand Up @@ -46,7 +52,7 @@ function getContent(unix, preferUsability = false) {

function getConsoleContent(
currenttimestamp,
ephemeral,
pub,
day,
month,
year,
Expand All @@ -56,8 +62,8 @@ function getConsoleContent(
timezone,
) {
if (currenttimestamp)
return `[currenttimestamp] Executed /currenttimestamp (Ephemeral: ${ephemeral})`;
return `[timestamp] Day: ${day}; Month: ${month}; Year: ${year}; Hour: ${hour}; Minute: ${minute}; Second: ${second}; Timezone: ${timezone}; Ephemeral: ${ephemeral}`;
return `[currenttimestamp] Executed /currenttimestamp (Public: ${pub})`;
return `[timestamp] Day: ${day}; Month: ${month}; Year: ${year}; Hour: ${hour}; Minute: ${minute}; Second: ${second}; Timezone: ${timezone}; Public: ${pub}`;
}

client.on(Events.ClientReady, () => {
Expand All @@ -68,7 +74,12 @@ client.on(Events.InteractionCreate, async (interaction) => {
if (interaction.isCommand()) {
let preferUsability =
interaction.options.getBoolean("prefer_usability") ?? false;
let ephemeral = !interaction.options.getBoolean("public");
let pub = interaction.options.getBoolean("public") == true;
if (pub) {
await interaction.deferReply();
} else {
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
}
let unix = 0;
let { day, month, year, hour, minute, second, timezone, src, dst } = [
1,
Expand All @@ -83,7 +94,6 @@ client.on(Events.InteractionCreate, async (interaction) => {
];
switch (interaction.commandName) {
case "timestamp":
await interaction.deferReply({ ephemeral });
day = interaction.options.getInteger("day") ?? 1;
month = interaction.options.getInteger("month") ?? 1;
year = interaction.options.getInteger("year") ?? 1970;
Expand All @@ -109,7 +119,7 @@ client.on(Events.InteractionCreate, async (interaction) => {
console.log(
getConsoleContent(
false,
ephemeral,
pub,
day,
month,
year,
Expand All @@ -121,15 +131,13 @@ client.on(Events.InteractionCreate, async (interaction) => {
);
break;
case "currenttimestamp":
await interaction.deferReply({ ephemeral });
unix = DateTime.now().toUnixInteger();
await interaction.editReply({
content: getContent(unix, preferUsability),
});
console.log(getConsoleContent(true, ephemeral));
console.log(getConsoleContent(true, pub));
break;
case "converttime":
await interaction.deferReply({ ephemeral });
day = interaction.options.getInteger("day") ?? 1;
month = interaction.options.getInteger("month") ?? 1;
year = interaction.options.getInteger("year") ?? 1;
Expand Down Expand Up @@ -162,11 +170,10 @@ client.on(Events.InteractionCreate, async (interaction) => {
content: `\`${srcTime}\` (Timezone: \`${src}\`) in \`${dst}\` is \`${dstTime}\``,
});
console.log(
`[converttime] Day: ${day}; Month: ${month}; Year: ${year}; Hour: ${hour}; Minute: ${minute}; Second: ${second}; Source: ${src}; Destination: ${dst}; Ephemeral: ${ephemeral}`,
`[converttime] Day: ${day}; Month: ${month}; Year: ${year}; Hour: ${hour}; Minute: ${minute}; Second: ${second}; Source: ${src}; Destination: ${dst}; Public: ${pub}`,
);
break;
case "convertcurrenttime":
await interaction.deferReply({ ephemeral });
timezone = interaction.options.getString("timezone");
let currenttime = DateTime.now()
.setZone(timezone)
Expand All @@ -179,11 +186,10 @@ client.on(Events.InteractionCreate, async (interaction) => {
)}\` is \`${currenttime}\``,
});
console.log(
`[convertcurrenttime] Executed /convertcurrenttime (Ephemeral: ${ephemeral})`,
`[convertcurrenttime] Executed /convertcurrenttime (Public: ${pub})`,
);
break;
case "temperature":
await interaction.deferReply({ ephemeral });
let response = "N/A";
let source = interaction.options.getString("source");
let target = interaction.options.getString("target");
Expand Down Expand Up @@ -312,8 +318,12 @@ client.on(Events.InteractionCreate, async (interaction) => {
await interaction.editReply({
content: response,
});
console.log(`[temperature] ${response} (Ephemeral: ${ephemeral})`);
console.log(`[temperature] ${response} (Public: ${pub})`);
break;
default:
await interaction.editReply({
content: "subcommand not known! How did you even call it?",
});
}
} else if (interaction.isAutocomplete()) {
let timezoneResponse = SUPPORTED_TIMEZONES.filter((zone) => {
Expand Down
Loading

0 comments on commit fd11e6b

Please sign in to comment.