Skip to content

Commit

Permalink
feat(userAvailability #134): user availability and preferences can be…
Browse files Browse the repository at this point in the history
… specified
  • Loading branch information
DasithKuruppu committed Apr 6, 2023
1 parent a3022ea commit 908847a
Show file tree
Hide file tree
Showing 20 changed files with 1,713 additions and 52 deletions.
81 changes: 81 additions & 0 deletions bot/embeds/templates/neverwinter/availabilityBuilder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { convertToDiscordDate } from "../../../interactions/messageComponents/utils/date/dateToDiscordTimeStamp";

const availabilityInfo = ({
userId,
availabilityList,
prefferedRaids,
timestamp = new Date(),
requestedTime = Date.now(),
}) => {
return {
type: "rich",
title: `Raid summary for the upcoming week`,
description: `<@${userId}}> availablility for raids\n
Last updated - ${convertToDiscordDate("now", {
relative: true,
})}
`,
color: 0xffa200,
timestamp,
// thumbnail: {
// url: `https://www.dasithsblog.com/images/Ranger-Hunter-Build.png`,
// height: 0,
// width: 0,
// },
// author: {
// name: `${userName}`,
// },
fields: availabilityList.map(
({
availableDay,
availableStartTime,
availableDuration,
}) => {
return {
name: `Availablility`,
value: `${availableDay} ${availableStartTime} ${availableDuration}`,
inline: false,
};
}
),
// footer: {
// text: `Footer text`,
// },
};
};

export const availabilityBuilder = ({
userName,
userId,
availabilityList,
prefferedRaids = [],
}) => {
const availabilityInfoEmbed = availabilityInfo({
userId,
availabilityList,
prefferedRaids,
});
console.log({ prefferedRaids });
return {
components: [
{
type: 1,
components: [
{
style: 3,
label: `Refresh`,
emoji: {
id: `1074205923154858014`,
name: `refresh`,
animated: false,
},
custom_id: `button_raidavailability_refresh`,
disabled: false,
type: 2,
},
],
},
],
embeds: [availabilityInfoEmbed],
};
};
156 changes: 149 additions & 7 deletions bot/embeds/templates/neverwinter/profile.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { displayMountsAsEmoji } from "../../../interactions/messageComponents/utils/helper/artifactsRenderer";
import { createRaidNameChoicesList } from "../../../registerCommands/commands";
import { MountsList } from "../mountsList";

const userProfile = ({
userId,
userName,
userStatus,
timeZone,
activityList,
prefferedRaids,
availabilityList,
preferredRunTypes,
mountsList = [],
rankList,
classesPlayed,
Expand Down Expand Up @@ -37,7 +42,7 @@ const userProfile = ({
inline: false,
},
{
name: `Account wide mounts`,
name: `Mounts`,
value: mountsList.length
? displayMountsAsEmoji(mountsList).join("|")
: "-",
Expand All @@ -53,6 +58,38 @@ const userProfile = ({
value: hasActivityList ? processedActivityList.join("\n") : "-",
inline: false,
},
{
name: `Time Zone`,
value: timeZone ? `> ${timeZone?.label}` : "-",
inline: false,
},
{
name: "Availablity",
value: availabilityList.length ? availabilityList
.map(({ startTime, endTime }) => {
return `> <t:${startTime}:F> to <t:${endTime}:t>`;
})
.join("\n") : `> /request update_user_availability command can be used to update your availability here`,
inline: false,
},
{
name: "Preferred Raids",
value: prefferedRaids.length ? prefferedRaids
.map((name) => {
return `> ${name}`;
})
.join("\n"): "-",
inline: false,
},
{
name: "Preferred Raid Types",
value: preferredRunTypes.length ? preferredRunTypes
.map((name) => {
return `> ${name}`;
})
.join("\n"): "-",
inline: false,
},
],
// footer: {
// text: `Footer text`,
Expand Down Expand Up @@ -115,10 +152,64 @@ export const getProfileStatusesList = () => [
shortName: UserStatusValues.RANKI,
},
];
export const getTimeZones = () => [
{
label: "Central Standard Time (NA) [GMT-6]",
value: "GMT-06:00",
},
{
label: "Eastern Standard Time (NA) [GMT-5]",
value: "GMT-05:00",
},
{
label: "Pacific Standard Time (NA) [GMT-8]",
value: "GMT-08:00",
},
{
label: "Moscow Standard Time (Russia) [GMT+3]",
value: "GMT+03:00",
},
{
label: "Greenwich Mean Time (UTC) [GMT+0]",
value: "GMT+0:00",
},
{
label: "Eastern European/Central Africa/Isreal Time [GMT+2]",
value: "GMT+02:00",
},
{
label: "Central European/British/West Africa Time [GMT+1]",
value: "GMT+01:00",
},
{
label: "Australian Central Standard Time [GMT+9:30]",
value: "GMT+9:30",
},
{
label: "Brazil Time(Sao Paulo) [GMT-03:00]",
value: "GMT-03:00",
},
{
label: "Australian Eastern Standard/Hawaii Time [GMT+10:00]",
value: "GMT+10:00",
},
{
label: "Singapore Time [GMT+8:00]",
value: "GMT+8:00",
},
{
label: "Indian Standard Time [GMT+5:30]",
value: "GMT+5:30",
},
];
export const profileBuilder = ({
userId,
userName,
prefferedRaids,
preferredRunTypes,
timeZone,
activityList,
availabilityList,
mountsList,
rankList,
userStatus,
Expand All @@ -127,10 +218,14 @@ export const profileBuilder = ({
}) => {
const userProfileEmbed = userProfile({
userId,
timeZone,
userName,
prefferedRaids,
preferredRunTypes,
activityList,
mountsList,
userStatus,
availabilityList,
rankList,
classesPlayed,
trialsParticipatedOn,
Expand Down Expand Up @@ -159,20 +254,67 @@ export const profileBuilder = ({
type: 1,
components: [
{
custom_id: `select_profile_mounts`,
placeholder: `Select mounts`,
options: MountsList.map(({ label, shortName, emoji }) => ({
custom_id: `select_profile_timezone`,
placeholder: `Select Timezone`,
options: getTimeZones().map(({ label, value }) => ({
label,
value: shortName,
emoji,
value,
default: false,
})),
min_values: 1,
min_values: 0,
type: 3,
},
],
},
{
type: 1,
components: [
{
custom_id: `select_preferred_raids`,
placeholder: `Select Preferred Raids`,
options: createRaidNameChoicesList.map(({ name, value }) => ({
label: name,
value,
default: false,
})),
min_values: 0,
max_values: 5,
type: 3,
},
],
},
{
type: 1,
components: [
{
custom_id: `select_preferred_raid_types`,
placeholder: `Select Preferred Raid Types`,
options: [
{
label: "Training",
value: "Training",
default: false,
// description: "Set type of raid to a training run",
},
{
label: "Farm",
value: "Farm",
default: false,
// description: "Set type of raid to a farm run",
},
{
label: "Wipe",
value: "Wipe",
default: false,
// description: "Set type of raid to a wipe with a mix of experienced and inexperienced players",
},
],
min_values: 0,
max_values: 3,
type: 3,
},
],
},
],
embeds: [userProfileEmbed],
};
Expand Down
2 changes: 1 addition & 1 deletion bot/embeds/templates/serverProfile/getServerProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const serverProfileBuilder = ({
serverRoles,
activityList,
});
const filteredRoles = guildRoles.filter(({ name }) => name !== "@everyone");
const filteredRoles = guildRoles.filter(({ name }) => name !== "@everyone").slice(0,24);
const maxRoles = filteredRoles?.length > 10 ? 10 : filteredRoles?.length;
return {
components: [
Expand Down
11 changes: 7 additions & 4 deletions bot/interactions/commands/create/raid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export const createRaidCommand = async (
const nameToCoverUrl = {
[trialNamesList.TOMM]:
"https://pwimages-a.akamaihd.net/arc/8d/5d/8d5d88772e1edccad4f98cb882677a5e1564178653.jpg",
[trialNamesList.GAZEMNIDS_RELIQUARY_M]: "https://i.ibb.co/qsVXXJJ/img-atd-Npq30-Pp-Rdfo-Vw-MN6yzl-RR.png",
[trialNamesList.GAZEMNIDS_RELIQUARY_M]:
"https://i.ibb.co/qsVXXJJ/img-atd-Npq30-Pp-Rdfo-Vw-MN6yzl-RR.png",
[trialNamesList.ZCM]:
"https://static.wikia.nocookie.net/dungeonsdragons/images/4/43/Zariel.jpg/revision/latest?cb=20200408175529",
[trialNamesList.COKM]:
Expand All @@ -88,7 +89,9 @@ export const createRaidCommand = async (
{ discordServerId: interactionConfig.guild_id },
{ documentClient }
);
const processedTime = normalizeTime(dateTime, { offSet: serverProfile?.timezoneOffset });
const processedTime = normalizeTime(dateTime, {
offSet: serverProfile?.timezoneOffset,
});
const isFivePerson = isFivePersonDungeon(title);
const requestedDate = convertToDiscordDate(processedTime);
const requestedRelativeDate = convertToDiscordDate(processedTime, {
Expand All @@ -106,8 +109,8 @@ export const createRaidCommand = async (
Solo_tank: { DPS: 7, HEALS: 2, TANKS: 1, WAITLIST: 6 },
Solo_heal: { DPS: 7, HEALS: 1, TANKS: 2, WAITLIST: 6 },
Solo_tank_heal: { DPS: 8, HEALS: 1, TANKS: 1, WAITLIST: 6 },
Three_heal: {DPS: 5, HEALS: 3, TANKS: 2, WAITLIST: 6 },
Three_heal_one_tank: {DPS: 6, HEALS: 3, TANKS: 1, WAITLIST: 6 },
Three_heal: { DPS: 5, HEALS: 3, TANKS: 2, WAITLIST: 6 },
Three_heal_one_tank: { DPS: 6, HEALS: 3, TANKS: 1, WAITLIST: 6 },
};
const uniqueRaidId = new ShortUniqueId({ length: 10 })();
const raidEmbed = raidBuilder({
Expand Down
11 changes: 7 additions & 4 deletions bot/interactions/commands/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {
} from "discord.js";
import { Logger } from "winston";
import { requestRoleCommand } from "./role";
import { inviteLinkCommand} from "./inviteLink"
import { inviteLinkCommand } from "./inviteLink";
import { buildCommand } from "./builds";
import { profileCommand } from "./profile";
import { serverProfileCommand } from "./serverProfile"
import { raidSummaryCommand } from "./raidSummary"
import { serverProfileCommand } from "./serverProfile";
import { raidSummaryCommand } from "./raidSummary";
import { updateUserAvailabilityCommand } from "./updateUserAvailablity";
import { unrecognizedCommand } from "..";
interface factoryInitializations {
logger: Logger;
Expand All @@ -29,8 +30,10 @@ export const availableSubCommands = {
build: buildCommand,
profile: profileCommand,
server_profile: serverProfileCommand,
raid_summary: raidSummaryCommand
raid_summary: raidSummaryCommand,
update_user_availability: updateUserAvailabilityCommand,
};

export const recognizedSubCommands = Object.keys(availableSubCommands);
export const requestCommand = async (
data: APIChatInputApplicationCommandInteractionData & { type: number },
Expand Down
Loading

0 comments on commit 908847a

Please sign in to comment.