mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-19 16:15:16 +00:00
Can delete an emoji
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
|
||||
import { CustomEmoji } from "../entities/CustomEmoji";
|
||||
import { DatabaseHelper } from "./DatabaseHelper";
|
||||
import { existsSync, unlinkSync } from "fs";
|
||||
|
||||
const EMOJIS_TABLE = "comunic_custom_emojis";
|
||||
|
||||
@ -62,6 +63,22 @@ export class CustomEmojisHelper {
|
||||
return this.DbToCustomEmoji(row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a custom emoji
|
||||
*
|
||||
* @param e Information about the emoji to delete
|
||||
*/
|
||||
public static async Delete(e: CustomEmoji) {
|
||||
|
||||
if(existsSync(e.sysPath))
|
||||
unlinkSync(e.sysPath)
|
||||
|
||||
await DatabaseHelper.DeleteRows(EMOJIS_TABLE, {
|
||||
id: e.id
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a database entry into a custom emoji
|
||||
*
|
||||
|
Reference in New Issue
Block a user