Skip to content

Commit

Permalink
NICE
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Oct 22, 2024
1 parent 6b82393 commit f194a66
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/app/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ const client = new orm.ORM({

export * from "@ghom/orm"

export default client
export default client
11 changes: 10 additions & 1 deletion src/buttons/givePoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export default new app.Button<GivePointsButtonParams>({
)} You can't give points to yourself.`,
})

const topic = interaction.channel

if (fromId !== topic.ownerId)
return await interaction.editReply({
content: `${app.emote(interaction, "Cross")} You can't give points to a user in a topic that you don't own.`,
})

const fromUser = await app.getUser({ id: fromId }, true)
const toUser = await app.getUser({ id: toId }, true)

Expand All @@ -45,7 +52,9 @@ export default new app.Button<GivePointsButtonParams>({
)

await interaction.editReply({
content: `${app.emote(interaction, "CheckMark")} Successfully rated.`,
content: `${app.emote(interaction, "CheckMark")} Successfully thanked ${app.userMention(
toId,
)}`,
})

const target = await interaction.client.users.fetch(toId, {
Expand Down
5 changes: 1 addition & 4 deletions src/listeners/button.interactionCreate.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ const listener: app.Listener<"interactionCreate"> = {
ephemeral: true,
})

const error = await app.prepareButton(
{ ...(interaction as any), triggerCooldown: () => {} },
button,
)
const error = await app.prepareButton(interaction as any, button)

if (error)
return interaction.reply({
Expand Down
7 changes: 2 additions & 5 deletions src/namespaces/point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export function getPointRank(user: app.User): Promise<{ rank: string }> {

export function buildHelpingFooterEmbed(
helpers: app.User[],
helped: { id: string },
topicState: Helping | undefined,
): app.SystemMessage {
const components = topicState?.resolved
Expand All @@ -76,7 +75,7 @@ export function buildHelpingFooterEmbed(
})
.map((helper) => {
return givePoints
.create(helped.id, 5)
.create(helper.id, 5)
.setLabel(`Remercier ${helper.username}`)
})
: [upTopic.create(), resolveTopic.create()]
Expand Down Expand Up @@ -159,7 +158,5 @@ export async function refreshHelpingFooter(topic: app.ThreadChannel) {
await topic.setLocked(true)
}

await topic.send(
buildHelpingFooterEmbed(bestHelpers.slice(0, 5), helped, topicState),
)
await topic.send(buildHelpingFooterEmbed(bestHelpers.slice(0, 5), topicState))
}

0 comments on commit f194a66

Please sign in to comment.