3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 20:35:02 +00:00

Port Censor and Spam plugins to use GuildSavedMessages events

This commit is contained in:
Dragory 2018-11-24 17:12:36 +02:00
parent fbb1ee4719
commit 1a6e680d81
4 changed files with 237 additions and 114 deletions

View file

@ -73,6 +73,16 @@ export class GuildSavedMessages extends BaseRepository {
.getOne();
}
getUserMessagesByChannelAfterId(userId, channelId, afterId) {
return this.messages
.createQueryBuilder()
.where("guild_id = :guild_id", { guild_id: this.guildId })
.where("user_id = :user_id", { user_id: userId })
.where("channel_id = :channel_id", { channel_id: channelId })
.where("id > :afterId", { afterId })
.getMany();
}
async create(data) {
try {
await this.messages.insert(data);
@ -128,7 +138,7 @@ export class GuildSavedMessages extends BaseRepository {
}
);
this.events.emit("edit", [newMessage, oldMessage]);
this.events.emit("update", [newMessage, oldMessage]);
}
async saveEditFromMsg(msg: Message) {