diff --git a/src/discord/commands/guild/d.birthday.ts b/src/discord/commands/guild/d.birthday.ts index 2440727e6..d3f2235e6 100644 --- a/src/discord/commands/guild/d.birthday.ts +++ b/src/discord/commands/guild/d.birthday.ts @@ -163,8 +163,12 @@ export const dBirthday: SlashCommand = { .setName('day'))), async execute(interaction) { log.info(F, await commandContext(interaction)); - await interaction.deferReply({ ephemeral: (interaction.options.getBoolean('ephemeral') === true) }); let command = interaction.options.getSubcommand() as 'get' | 'set' | undefined; + if (command === 'set') { + await interaction.deferReply({ ephemeral: true }); + } else { + await interaction.deferReply({ ephemeral: (interaction.options.getBoolean('ephemeral') === true) }); + } let member = interaction.options.getMember('user'); const monthInput = interaction.options.getString('month'); const day = interaction.options.getInteger('day'); diff --git a/src/discord/commands/guild/d.rpg.ts b/src/discord/commands/guild/d.rpg.ts index c720e08d3..a4884c7a4 100644 --- a/src/discord/commands/guild/d.rpg.ts +++ b/src/discord/commands/guild/d.rpg.ts @@ -63,18 +63,18 @@ const timesUp = 'Time\'s up!'; const items = { general: { - // giftcard: { - // label: 'Gift Card', - // value: 'giftcard', - // description: 'A gift card to gift to someone else', + // userflair: { + // label: 'User Flair', + // value: 'userflair', + // description: 'A flair that appears next to your name.', // quantity: 1, // weight: 0, - // cost: 0, + // cost: 1000, // equipped: false, // consumable: false, - // effect: 'tokens', - // effect_value: '100', - // emoji: 'buttonBetHuge', + // effect: 'userflair', + // effect_value: 'userflair', + // emoji: 'itemDiscount', // }, // testkit: { // label: 'TestKit', diff --git a/src/discord/commands/guild/d.timezone.ts b/src/discord/commands/guild/d.timezone.ts index 93e454065..54a7eb2e1 100644 --- a/src/discord/commands/guild/d.timezone.ts +++ b/src/discord/commands/guild/d.timezone.ts @@ -5,6 +5,7 @@ import { } from 'discord.js'; import { SlashCommand } from '../../@types/commandDef'; import { timezone } from '../../../global/commands/g.timezone'; +import { embedTemplate } from '../../utils/embedTemplate'; import commandContext from '../../utils/context'; // import log from '../../../global/utils/log'; const F = f(__filename); @@ -32,8 +33,12 @@ export const dTimezone: SlashCommand = { .setAutocomplete(true))), async execute(interaction) { log.info(F, await commandContext(interaction)); - await interaction.deferReply({ ephemeral: (interaction.options.getBoolean('ephemeral') === true) }); let command = interaction.options.getSubcommand() as 'get' | 'set' | undefined; + if (command === 'set') { + await interaction.deferReply({ ephemeral: true }); + } else { + await interaction.deferReply({ ephemeral: (interaction.options.getBoolean('ephemeral') === true) }); + } const tzValue = interaction.options.getString('timezone'); let member = interaction.options.getMember('user') as GuildMember | null; @@ -45,15 +50,20 @@ export const dTimezone: SlashCommand = { member = interaction.member as GuildMember; } - const response = await timezone(command, member.id, tzValue); + const response = await timezone(command, member.id, tzValue, interaction); // log.debug(F, `response: ${response}`); if (command === 'get') { - if (response === null) { - await interaction.editReply({ content: `${member.displayName} is a timeless treasure <3 (and has not set a time zone)` }); + const embed = embedTemplate(); + if (response === '') { + embed.setTitle(`${member.displayName} is a timeless treasure <3\n(Has not set a time zone)`); + await interaction.editReply({ embeds: [embed] }); + // await interaction.editReply({ content: `${member.displayName} is a timeless treasure <3 (and has not set a time zone)` }); } else { - await interaction.editReply({ content: `${response} wherever ${member.displayName} is located.` }); + embed.setTitle(`${response} wherever ${member.displayName} is located`); + await interaction.editReply({ embeds: [embed] }); + // await interaction.editReply({ content: `${response} wherever ${member.displayName} is located.` }); } } else { await interaction.editReply({ content: response as string }); diff --git a/src/global/commands/g.birthday.ts b/src/global/commands/g.birthday.ts index cbbcf4006..d3c9ee3ab 100644 --- a/src/global/commands/g.birthday.ts +++ b/src/global/commands/g.birthday.ts @@ -22,7 +22,7 @@ export async function birthday( let response = {} as DateTime | null; if (command === 'set') { // log.debug(F, `${command} ${memberId} ${month} ${day}`); - const birthDate = DateTime.utc(2000, month as number, day as number); + const birthDate = DateTime.local(2000, month as number, day as number); // log.debug(F, `Setting birthDate for ${memberId} to ${birthDate}`); diff --git a/src/global/commands/g.timezone.ts b/src/global/commands/g.timezone.ts index 715747706..c20a27fea 100644 --- a/src/global/commands/g.timezone.ts +++ b/src/global/commands/g.timezone.ts @@ -2,6 +2,7 @@ import timezones from '../assets/data/timezones.json'; import { getUser, usersUpdate } from '../utils/knex'; +import { embedTemplate } from '../../discord/utils/embedTemplate'; const F = f(__filename); @@ -18,11 +19,13 @@ export async function timezone( command: 'get' | 'set', memberId: string, tzvalue?:string | null, + interaction?:any, ):Promise { // log.debug(F, `tzvalue: ${command} ${memberId} ${tzvalue}`); let response = '' as string | null; if (command === 'set') { + const embed = embedTemplate(); // define offset as the value from the timezones array let tzCode = ''; for (const zone of timezones) { // eslint-disable-line no-restricted-syntax @@ -31,6 +34,11 @@ export async function timezone( // log.debug(F, `tzCode: ${tzCode}`); } } + if (tzCode === '') { + embed.setTitle('Invalid timezone!\nPlease only use the options from the autocomplete list.'); + await interaction.editReply({ embeds: [embed] }); + return null; + } // log.debug(F, `actor.id: ${actor.id}`); const userData = await getUser(memberId, null, null); @@ -39,7 +47,9 @@ export async function timezone( await usersUpdate(userData); - return `I updated your timezone to ${tzvalue}`; + embed.setTitle(`I updated your timezone to ${tzvalue}`); + await interaction.editReply({ embeds: [embed] }); + return null; } let gmtValue = ''; @@ -56,8 +66,8 @@ export async function timezone( } } // get the user's timezone from the database - const timestring = new Date().toLocaleTimeString('en-US', { timeZone: tzCode }); - response = `It is likely ${timestring} (GMT${gmtValue})`; + const timestring = new Date().toLocaleTimeString('en-US', { timeZone: tzCode, hour: '2-digit', minute: '2-digit' }); + response = `It's ${timestring} (GMT${gmtValue})`; log.info(F, `response: ${JSON.stringify(response, null, 2)}`); } log.info(F, `response: ${JSON.stringify(response, null, 2)}`);