Skip to content

Commit

Permalink
feat(user profile #64): Added in support for basic user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
DasithKuruppu committed Nov 13, 2022
1 parent 87e5f17 commit 07688d8
Show file tree
Hide file tree
Showing 32 changed files with 591 additions and 61 deletions.
13 changes: 9 additions & 4 deletions bot/embeds/templates/neverwinter/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const tenPersonSeperation: ISectionSeperation = {
[Category.HEALER_TITLE]: { start: 10, end: 11 },
[Category.HEALER]: { start: 11, end: 13 },
[Category.WAITLIST_TITLE]: { start: 13, end: 14 },
[Category.WAITLIST]: { start: 14, end: 19 },
[Category.WAITLIST]: { start: 14, end: 20 },
};

export const tenPersonSoloTankSeperation: ISectionSeperation = {
Expand All @@ -22,7 +22,7 @@ export const tenPersonSoloTankSeperation: ISectionSeperation = {
[Category.HEALER_TITLE]: { start: 10, end: 11 },
[Category.HEALER]: { start: 11, end: 13 },
[Category.WAITLIST_TITLE]: { start: 13, end: 14 },
[Category.WAITLIST]: { start: 14, end: 19 },
[Category.WAITLIST]: { start: 14, end: 20 },
};

export const tenPersonSoloHealSeperation: ISectionSeperation = {
Expand All @@ -33,7 +33,7 @@ export const tenPersonSoloHealSeperation: ISectionSeperation = {
[Category.HEALER_TITLE]: { start: 11, end: 12 },
[Category.HEALER]: { start: 12, end: 13 },
[Category.WAITLIST_TITLE]: { start: 13, end: 14 },
[Category.WAITLIST]: { start: 14, end: 19 },
[Category.WAITLIST]: { start: 14, end: 20 },
};

export const tenPersonSoloHealTankSeperation: ISectionSeperation = {
Expand All @@ -44,7 +44,7 @@ export const tenPersonSoloHealTankSeperation: ISectionSeperation = {
[Category.HEALER_TITLE]: { start: 11, end: 12 },
[Category.HEALER]: { start: 12, end: 13 },
[Category.WAITLIST_TITLE]: { start: 13, end: 14 },
[Category.WAITLIST]: { start: 14, end: 19 },
[Category.WAITLIST]: { start: 14, end: 20 },
};

export const fivePersonSeperation: ISectionSeperation = {
Expand All @@ -64,4 +64,9 @@ export const raidConfigs = {
"1U7U1U2U1U1U1U3": tenPersonSoloHealSeperation,
"1U8U1U1U1U1U1U3": tenPersonSoloHealTankSeperation,
"1U3U1U1U1U1U1U3": fivePersonSeperation,
// compatible with previous configs
"1U6U1U2U1U2U1U6": tenPersonSeperation,
"1U7U1U1U1U2U1U6": tenPersonSoloTankSeperation,
"1U7U1U2U1U1U1U6": tenPersonSoloHealSeperation,
"1U8U1U1U1U1U1U6": tenPersonSoloHealTankSeperation,
};
30 changes: 30 additions & 0 deletions bot/embeds/templates/neverwinter/profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export const infoCardBuilder = ({}) => {
return {
components: [],
embeds: [userProfile],
};
};
const userProfile = ({ userName, timestamp= new Date() }) => {

return {
type: "rich",
title: `Profile - ${userName}`,
description: `Paragon Path - Hunter\nTotal Item Level - 81,404\n☑️ Masterworks\n☑️ Raptors(Power)`,
color: 0xffa200,
timestamp,
thumbnail: {
url: `https://www.dasithsblog.com/images/Ranger-Hunter-Build.png`,
height: 0,
width: 0,
},
author: {
name: `${userName}`,
},
fields: [

],
footer: {
text: ``,
},
};
};
15 changes: 11 additions & 4 deletions bot/embeds/templates/neverwinter/raid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ export const generateAvailableFields = ({
});

export const sectionTitleNames = {
[Category.DPS_TITLE]: `───────── <:dps:911695908482207774> DPS <:dps:911695908482207774> ─────────`,
[Category.TANK_TITLE]: `──────── <:tank:911695908134060112> TANKS <:tank:911695908134060112> ────────`,
[Category.HEALER_TITLE]: `──────── <:healer:911695908117315654> HEALS <:healer:911695908117315654> ────────`,
[Category.WAITLIST_TITLE]: `────── ⌛ WAITING LIST ⌛ ──────`,
};

export const previousSectionTitleNames = {
[Category.DPS_TITLE]: `__𒆜𒆜⚔️ DPS ⚔️𒆜𒆜__`,
[Category.TANK_TITLE]: `__𒆜𒆜🛡️ TANKS 🛡️𒆜𒆜__`,
[Category.HEALER_TITLE]: `__𒆜𒆜⚕️ HEALS ⚕️𒆜𒆜__`,
Expand Down Expand Up @@ -150,22 +157,22 @@ export const raidBuilder = ({
// },
fields: [
{
name: `__𒆜𒆜⚔️ DPS ⚔️𒆜𒆜__`,
name: sectionTitleNames[Category.DPS_TITLE],
value: `\u200B`,
},
...generateAvailableFields(template).DPS,
{
name: `__𒆜𒆜🛡️ TANKS 🛡️𒆜𒆜__`,
name: sectionTitleNames[Category.TANK_TITLE],
value: `\u200B`,
},
...generateAvailableFields(template).TANKS,
{
name: `__𒆜𒆜⚕️ HEALS ⚕️𒆜𒆜__`,
name: sectionTitleNames[Category.HEALER_TITLE],
value: `\u200B`,
},
...generateAvailableFields(template).HEALS,
{
name: `__𒆜𒆜⌛ WAITING LIST ⌛𒆜𒆜__`,
name: sectionTitleNames[Category.WAITLIST_TITLE],
value: `\u200B`,
},
...generateAvailableFields(template).WAITLIST,
Expand Down
2 changes: 2 additions & 0 deletions bot/interactions/commands/create/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from "discord.js";
import { Logger } from "winston";
import { createRaidCommand } from "./raid";
import { profileCommand } from "./profile";
import { unrecognizedCommand } from "..";
interface factoryInitializations {
logger: Logger;
Expand All @@ -21,6 +22,7 @@ interface factoryInitializations {
export const commandName_create = "create";
export const availableSubCommands = {
raid: createRaidCommand,
user_profile: profileCommand,
};
export const recognizedSubCommands = Object.keys(availableSubCommands);
export const createCommand = async (
Expand Down
33 changes: 33 additions & 0 deletions bot/interactions/commands/create/profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
APIChatInputApplicationCommandInteractionData,
REST,
Routes,
APIInteractionGuildMember,
APIApplicationCommandInteractionDataSubcommandOption,
} from "discord.js";

import { Logger } from "winston";
import { userProfile } from "../../../modals/profile";

interface factoryInitializations {
logger: Logger;
rest: REST;
interactionConfig: {
guild_id: string;
application_id: string;
token: string;
member: APIInteractionGuildMember;
};
}

export const profileCommand = async (
data: APIChatInputApplicationCommandInteractionData,
factoryInits: factoryInitializations
) => {
const { rest, logger, interactionConfig } = factoryInits;
const [{ type: subCommandType, options: subCommandOptions = [] }] =
data.options as APIApplicationCommandInteractionDataSubcommandOption[];

return false;
};

45 changes: 29 additions & 16 deletions bot/interactions/commands/create/raid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
REST,
Routes,
APIInteractionGuildMember,
RESTPostAPIChannelMessageResult,
} from "discord.js";
import ShortUniqueId from 'short-unique-id';
import { Logger } from "winston";
Expand Down Expand Up @@ -59,6 +60,7 @@ export const createRaidCommand = async (
"https://cdn.player.one/sites/player.one/files/styles/full_large/public/2022/01/12/neverwinter-update.jpg",
[trialNamesList.TM]:
"https://db4sgowjqfwig.cloudfront.net/campaigns/68638/assets/330407/Tiamat_Mobile.jpg?1400812964",
[trialNamesList.VOS]: "https://pwimages-a.akamaihd.net/arc/14/57/1457e07177cd42d03f8ef695335a88441613762258.jpg",
[trialNamesList.TOSM]:
"https://static.wikia.nocookie.net/forgottenrealms/images/f/fd/Spider_Temple_Concept.png/revision/latest/scale-to-width-down/350?cb=20210725190230",
};
Expand All @@ -68,9 +70,9 @@ export const createRaidCommand = async (
const requestedRelativeDate = convertToDiscordDate(dateTime,{relative:true})
logger.log("info", "create attributes", {isFivePerson, requestedDate, dateTime});
const partyOptionsToMap = {
Standard: { DPS: 6, HEALS: 2, TANKS: 2, WAITLIST: 3 },
Solo_tank: { DPS: 7, HEALS: 2, TANKS: 1, WAITLIST: 3 },
Solo_heal: { DPS: 7, HEALS: 1, TANKS: 2, WAITLIST: 3 },
Standard: { DPS: 6, HEALS: 2, TANKS: 2, WAITLIST: 6 },
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: 3 },
};
const uniqueRaidId = new ShortUniqueId({ length: 10 })();
Expand All @@ -91,6 +93,25 @@ export const createRaidCommand = async (
template: { DPS: 3, HEALS: 1, TANKS: 1, WAITLIST: 3 },
}),
});
logger.log("info", "creating raid", {
raidId: uniqueRaidId,
raidEmbed
});
const raidCreateResponse = await rest.patch(
(Routes as any).webhookMessage(
interactionConfig.application_id,
interactionConfig.token,
),
{
body: {
content: `Event/Raid will start on ${requestedDate}`,
...raidEmbed,
allowed_mentions: {
parse: [],
},
},
}
) as RESTPostAPIChannelMessageResult;
const updateValues = setUpdateValues({
title,
creatorId: interactionConfig.member?.user?.id,
Expand All @@ -104,12 +125,10 @@ export const createRaidCommand = async (
type,
raidEmbed: JSON.stringify(raidEmbed),
serverId: interactionConfig?.guild_id,
messageId: raidCreateResponse?.id,
channelId: raidCreateResponse?.channel_id,
updatedAt: Date.now(),
});
logger.log("info", "creating raid", {
updateValues,
raidId: uniqueRaidId,
});
const createdRaid = await documentClient
.update({
TableName: raidsTable.name.get(),
Expand All @@ -123,19 +142,13 @@ export const createRaidCommand = async (
ExpressionAttributeValues: updateValues.updateExpressionAttributeValues,
})
.promise();

logger.log("info", "created raid", {
createdRaid,
updateValues,
raidCreateResponse
});
return {
body: {
content: `Event/Raid will start on ${requestedDate}`,
...raidEmbed,
allowed_mentions: {
parse: [],
},
},
};
return false;
};

//https://discordjs.guide/popular-topics/embeds.html#resending-a-received-embed
2 changes: 2 additions & 0 deletions bot/interactions/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { infoCommand, commandName_info } from "./info/info";
import { requestCommand, commandName_request } from "./request";
import { createCommand, commandName_create } from "./create";
import { commandName_remove, removeCommand } from "./remove";
import { notRecognized } from "./unrecognized";

export const commandActions = {
[commandName_info]: infoCommand,
[commandName_request]: requestCommand,
[commandName_create]: createCommand,
[commandName_remove]: removeCommand,
};

export const unrecognizedCommand = notRecognized;
Expand Down
47 changes: 47 additions & 0 deletions bot/interactions/commands/remove/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {
APIInteractionGuildMember,
ApplicationCommandType,
REST,
APIChatInputApplicationCommandInteractionData,
} from "discord.js";
import { Logger } from "winston";
import { removeRaidUserCommand } from "./raidUser";
import { unrecognizedCommand } from "..";
interface factoryInitializations {
logger: Logger;
rest: REST;
interactionConfig: {
application_id: string;
token: string;
member: APIInteractionGuildMember;
channel_id: string,
};
}

export const commandName_remove = "remove";
export const availableSubCommands = {
raid_user: removeRaidUserCommand,
};
export const recognizedSubCommands = Object.keys(availableSubCommands);
export const removeCommand = async (
data: APIChatInputApplicationCommandInteractionData & { type: number },
factoryInits: factoryInitializations
) => {
const { logger, rest, interactionConfig } = factoryInits;
logger.log("info", `command - ${commandName_remove}`, { data });
const { options, type } = data;
const [{ name = "" } = {}] = options || [];
if (type !== ApplicationCommandType.ChatInput) {
return {
body: {
content: "Unsupported input used",
},
};
}
const subCommandResult = recognizedSubCommands.includes(name)
? await availableSubCommands[name](data, factoryInits)
: unrecognizedCommand();

return subCommandResult;
};

Loading

0 comments on commit 07688d8

Please sign in to comment.