Closed Arisamiga closed 2 years ago
The deletion notification should contain a short message aswell, why it was deleted.
We currently have no popover ui component so just use browser input like for linking a character.
The deletion notification should contain a short message aswell, why it was deleted.
Are you referring to the description of the embed? If so I couldn't think of what information might be relevant to add on the description of the embed as most of the information is on the embed itself.
We currently have no popover ui component so just use browser input like for linking a character.
I currently have it so it gets the user that deleted the pick from the cookies and the person that made the pick from the database as the pick is already obtained for deletion.
The way you Grab the user is fine.
The staff member that deletes should be required to enter a message for the deletion tho that shows up on the embed.
Unless i overread thag cause im on mobile.
The way you Grab the user is fine.
The staff member that deletes should be required to enter a message for the deletion tho that shows up on the embed.
Unless i overread thag cause im on mobile.
Ohhh you mean like a reason for the deletion. Yea I am gonna quickly do that now
Also the bot has to be extracted soon to its own project, due to rate limit problems etc. We need to overwork alot in the bot anyways.
That will mean tho that we cant directly internally call these functions anymore aswell tho.
The way you Grab the user is fine.
The staff member that deletes should be required to enter a message for the deletion tho that shows up on the embed.
Unless i overread thag cause im on mobile.
I added it, but because the axios.delete() doesn't include a data parameter I got the reason from the URL Search Params if that's ok.
If i remember right aswell pings or mentiond inside embeds dont actually trigger a ping so u prob will have to add a ping outside the embed to actually notifie the user.
If i remember right aswell pings or mentiond inside embeds dont actually trigger a ping so u prob will have to add a ping outside the embed to actually notifie the user.
So adding a message before the embed pinging the use that had their pick deleted
Ill test it out later other then that lgtm
Would close #10 and #25 since deletion is already logged internal.
@Arisamiga if u change this i can approve 1/2
Basically condence the embed even more and just make the design little better and named better.
Suggested edit:
diff --git a/src/routes/api/collabs/[id]/picks/[pick_id]/index.ts b/src/routes/api/collabs/[id]/picks/[pick_id]/index.ts
index 5e6d2cb..11a10d1 100644
--- a/src/routes/api/collabs/[id]/picks/[pick_id]/index.ts
+++ b/src/routes/api/collabs/[id]/picks/[pick_id]/index.ts
@@ -1,4 +1,4 @@
-import { CollabStatus, type Pick , type User} from '@prisma/client';
+import { CollabStatus, type Pick, type User } from '@prisma/client';
import type { RequestHandler } from '@sveltejs/kit';
import { existsSync, unlinkSync } from 'fs';
import { DiscordBot } from '../../../../../../bot/discord';
@@ -14,9 +14,9 @@ import type { IDiscordUser } from 'src/database/discord_user';
async function sendEmbedToDiscord(data: {
- pick:Pick,
+ pick: Pick,
user: IDiscordUser,
- reason: String | null,
+ reason: string | null,
}) {
const env = Env.load();
const serverId = env['DISCORD_SERVER_ID'];
@@ -27,45 +27,29 @@ async function sendEmbedToDiscord(data: {
}
const embed: MessageEmbed = new MessageEmbed({
- title: `Character Deletion from **${data.user.username}#${data.user.discriminator}**`,
- description: `Reason: **${data.reason}**`,
+ title: `**Deletion Notification**`,
+ description: `Your character has been deleted for the following reason:\n**${data.reason}**`,
color: 0xff0000,
fields: [
{
- name: 'Pick ID',
- value: data.pick.id,
- inline: true
- },
- {
- name: 'Pick Character',
+ name: 'Picked Character',
value: data.pick.name,
inline: true
},
{
- name: 'Pick User',
+ name: 'Picked by',
value: `<@${data.pick.userId}>`,
inline: true
},
{
- name: 'Deletor',
+ name: 'Deleted by',
value: `<@${data.user.id}>`,
- inline: true
},
{
- name: 'Pick User ID',
- value: `${data.pick.userId}`,
- inline: true
- },
- {
- name: 'Deletor ID',
- value: `${data.user.id}`,
+ name: 'Pick ID',
+ value: data.pick.id,
inline: true
},
- {
- name: 'Original:',
- value: "**"+ data.pick.original.toString() + "**",
- inline: false
- },
]
});
@@ -77,13 +61,13 @@ async function sendEmbedToDiscord(data: {
}
}
-export async function deletePick(pick: Pick, user: IDiscordUser, reason: String | null): Promise<void> {
+export async function deletePick(pick: Pick, user: IDiscordUser, reason: string | null): Promise<void> {
if (!pick) {
throw new Error('Pick not found');
}
const env = Env.load();
- sendEmbedToDiscord({pick, user, reason})
+ sendEmbedToDiscord({ pick, user, reason })
if (pick.image) {
const filePath = path.join(
LGTM. Tested. @lvdlee
Separate the discord embed and actual pick deletion to keep the deletePick function pure, that way it can be reused for all pick deletes, reason or not. The only reason the deletePick function exists is to also delete the corresponding image from the filesystem.
Other than that, looks good.
Separate the discord embed and actual pick deletion to keep the deletePick function pure, that way it can be reused for all pick deletes, reason or not. The only reason the deletePick function exists is to also delete the corresponding image from the filesystem.
Other than that, looks good.
@lvdlee I Separated them and put them so the Function run after deletePick on delete.
Still not really what I meant, but this works too.
I am quite confused. Are you talking about the if ($discord?.admin && pick.userId !== $discord?.id)
?
Sends embed with information of a character that is deleted and also sends the person that deleted the character
Might help with https://github.com/mirage-software/Kabooty/issues/25