Skip to content

Commit

Permalink
Merge branch 'main' into gpt-queue-400-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
theimperious1 authored Nov 11, 2024
2 parents 1a588cc + 9b3c2ba commit 8f077a2
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 30 deletions.
80 changes: 57 additions & 23 deletions src/discord/commands/guild/d.rpg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ const items = {
// effect_value: '0.1',
// emoji: 'itemBonus',
},
PremiumMember: {
// eslint-disable-next-line sonarjs/no-duplicate-string
label: 'Premium Member Role',
value: 'PremiumMembership',
description: 'Grants the Premium Member role',
quantity: 1,
weight: 0,
cost: 25000,
equipped: false,
consumable: true,
effect: 'role',
effect_value: 'PremiumMembership',
emoji: 'itemPremium',
},
},
fonts: {
AbrilFatFace: {
Expand Down Expand Up @@ -1642,7 +1656,8 @@ export async function rpgMarketInventory(

for (const [category, categoryItems] of Object.entries(items)) {
for (const item of Object.values(categoryItems)) {
if (!inventoryData.find(i => i.value === item.value)) {
if (!inventoryData.find(i => i.value === item.value)
&& !(item.value === 'PremiumMembership' && member?.roles.cache.has(env.ROLE_PREMIUM))) {
marketInventory.push({
label: `${item.label} - ${(item.cost - (discount * item.cost))} TT$`,
value: item.value,
Expand Down Expand Up @@ -2080,7 +2095,8 @@ export async function rpgMarketAccept(
persona_id: personaData.id,
},
});
if (inventoryData.length >= 20) {

if (inventoryData.length >= 20 && (itemData.value !== 'PremiumMembership')) {
const { embeds, components } = await rpgMarketChange(interaction);

// This grossness takes the APIEmbed object, turns it into a JSON object, and pulls the description
Expand Down Expand Up @@ -2151,27 +2167,29 @@ export async function rpgMarketAccept(
update: personaData,
});

// Add the item to the user's inventory
const newItem = {
persona_id: personaData.id,
label: itemData.label,
value: itemData.value,
description: itemData.description,
quantity: itemData.quantity,
weight: itemData.weight,
cost: itemData.cost,
equipped: itemData.equipped,
consumable: itemData.consumable,
effect: itemData.effect,
effect_value: itemData.effect_value,
emoji: itemData.emoji,
} as rpg_inventory;
// log.debug(F, `personaInventory: ${JSON.stringify(newItem, null, 2)}`);

// await inventorySet(newItem);
await db.rpg_inventory.create({
data: newItem,
});
if (itemData.value !== 'PremiumMembership') {
// Add the item to the user's inventory
const newItem = {
persona_id: personaData.id,
label: itemData.label,
value: itemData.value,
description: itemData.description,
quantity: itemData.quantity,
weight: itemData.weight,
cost: itemData.cost,
equipped: itemData.equipped,
consumable: itemData.consumable,
effect: itemData.effect,
effect_value: itemData.effect_value,
emoji: itemData.emoji,
} as rpg_inventory;
// log.debug(F, `personaInventory: ${JSON.stringify(newItem, null, 2)}`);

// await inventorySet(newItem);
await db.rpg_inventory.create({
data: newItem,
});
}

// if the item is a background or font, automatically equip it and unequip the other items of the same type
if (itemData.effect === 'background' || itemData.effect === 'font') {
Expand Down Expand Up @@ -2235,6 +2253,22 @@ export async function rpgMarketAccept(
embedInfoText = 'Your flair has been equipped! Use `/rpg flair` to change your flair, or head Home to unequip it.';
}

if (itemData.value === 'PremiumMembership') {
try {
(interaction.member as GuildMember)?.roles.add(env.ROLE_PREMIUM);
} catch (err) {
personaData.tokens += itemCost;

await db.personas.upsert({
where: {
id: personaData.id,
},
create: personaData,
update: personaData,
});
}
}

const { embeds, components } = await rpgMarketChange(interaction);

// This grossness takes the APIEmbed object, turns it into a JSON object, and pulls the description
Expand Down
18 changes: 12 additions & 6 deletions src/discord/utils/techHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
TextChannel,
ButtonBuilder,
GuildMember,
User,
ThreadChannel,
ModalSubmitInteraction,
Colors,
Expand Down Expand Up @@ -96,15 +97,20 @@ export async function techHelpClick(interaction:ButtonInteraction) {
const modalInput = i.fields.getTextInputValue(`${issueType}IssueInput`);
// log.debug(F, `modalInput: ${modalInput}!`);

// // Get the actor
const actor = i.user;
// Get the actor
const actor = (i.member ?? i.user) as GuildMember | User;

// Get the actors name.
const targetName = (actor as GuildMember | null)?.displayName
?? (actor as User | null)?.username
?? '[Deleted Discord Account]';

// Create a new thread in channel
const ticketThread = await (i.channel as TextChannel).threads.create({
name: `🧡│${actor.username}'s ${issueType} issue!`,
name: `🧡│${targetName}'s ${issueType} issue!`,
autoArchiveDuration: 1440,
type: ChannelType.PrivateThread as AllowedThreadTypeForTextChannel,
reason: `${actor.username} submitted a(n) ${issueType} issue`,
reason: `${targetName} submitted a(n) ${issueType} issue`,
invitable: false,
});
// log.debug(F, `Created meta-thread ${ticketThread.id}`);
Expand All @@ -119,11 +125,11 @@ export async function techHelpClick(interaction:ButtonInteraction) {
const techHelpButtons = new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId(`techHelpOwn~${issueType}~${actor.id}`)
.setCustomId(`techHelpOwn~${issueType}~${actor?.id}`)
.setLabel('Own this issue!')
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId(`techHelpClose~${issueType}~${actor.id}`)
.setCustomId(`techHelpClose~${issueType}~${actor?.id}`)
.setLabel('Close this issue!')
.setStyle(ButtonStyle.Success),
);
Expand Down
9 changes: 8 additions & 1 deletion src/discord/utils/trust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,21 @@ but they were already marked at trusted in the database, so no message was sent`
const greeting = greetingList[Math.floor(Math.random() * greetingList.length)];

const channelLounge = await newMember.client.channels.fetch(env.CHANNEL_LOUNGE) as TextChannel;
await channelLounge.send({
const message = await channelLounge.send({
content: stripIndents`**${greeting}**
Head to <#${env.CHANNEL_TRIPSIT}> if you need a tripsitter. :)
Be safe, have fun, and don't forget to visit the <id:guide> for more information!
*${await topic()}*`,
});

try {
await message.react('<:ts_welcomeA:1222543903677485156>');
await message.react('<:ts_welcomeB:1222543905216663634>');
} catch (err) {
log.debug(F, 'Attempted to add welcome emojis to welcome message, but they appear to be missing.');
}

await db.members.upsert({
where: {
id_guild_id: {
Expand Down

0 comments on commit 8f077a2

Please sign in to comment.