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

Migrate NameHistory to new Plugin structure

This commit is contained in:
Dark 2020-07-21 00:10:09 +02:00
parent e82dff4fa2
commit b8dfcda06d
6 changed files with 151 additions and 0 deletions

View file

@ -0,0 +1,12 @@
import { Member } from "eris";
import { PluginData } from "knub";
import { NameHistoryPluginType } from "./types";
export async function updateNickname(pluginData: PluginData<NameHistoryPluginType>, member: Member) {
if (!member) return;
const latestEntry = await pluginData.state.nicknameHistory.getLastEntry(member.id);
if (!latestEntry || latestEntry.nickname !== member.nick) {
if (!latestEntry && member.nick == null) return; // No need to save "no nickname" if there's no previous data
await pluginData.state.nicknameHistory.addEntry(member.id, member.nick);
}
}