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:
parent
e82dff4fa2
commit
b8dfcda06d
6 changed files with 151 additions and 0 deletions
12
backend/src/plugins/NameHistory/updateNickname.ts
Normal file
12
backend/src/plugins/NameHistory/updateNickname.ts
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue