fix: Make emoji importing warn you if the emoji already exists earlier

This commit is contained in:
Jesse Wierzbinski 2023-12-02 20:55:17 -10:00
parent 38e390c418
commit ab74c17ebd
No known key found for this signature in database

34
cli.ts
View file

@ -921,23 +921,6 @@ switch (command) {
let emojisCreated = 0; let emojisCreated = 0;
for (const [name, path] of Object.entries(pack_response)) { for (const [name, path] of Object.entries(pack_response)) {
// Get emoji URL, as it can be relative
const emoji = Bun.file(`${tempDirectory}/${path}`);
const content_type = emoji.type;
const hash = await uploadFile(emoji as File, config);
if (!hash) {
console.log(
`${chalk.red(``)} Failed to upload emoji ${name}`
);
process.exit(1);
}
const finalUrl = getUrl(hash, config);
// Check if emoji already exists // Check if emoji already exists
const existingEmoji = await client.emoji.findFirst({ const existingEmoji = await client.emoji.findFirst({
where: { where: {
@ -955,6 +938,23 @@ switch (command) {
continue; continue;
} }
// Get emoji URL, as it can be relative
const emoji = Bun.file(`${tempDirectory}/${path}`);
const content_type = emoji.type;
const hash = await uploadFile(emoji as File, config);
if (!hash) {
console.log(
`${chalk.red(``)} Failed to upload emoji ${name}`
);
process.exit(1);
}
const finalUrl = getUrl(hash, config);
// Create emoji // Create emoji
await client.emoji.create({ await client.emoji.create({
data: { data: {