66 lines
1.6 KiB
TypeScript
66 lines
1.6 KiB
TypeScript
import { SlashCommandBuilder } from "discord.js";
|
|
|
|
export type TCommand = {
|
|
data: SlashCommandBuilder;
|
|
execute: Function;
|
|
};
|
|
export type TUser = {
|
|
discord: string; // id
|
|
minecraft: string[]; //uuid
|
|
};
|
|
export type TData = {
|
|
blacklist: TUser[];
|
|
members: TUser[];
|
|
};
|
|
export enum EUserType {
|
|
Unregistered,
|
|
Blacklisted,
|
|
Member,
|
|
}
|
|
export function check_user_type_by_discord_id(
|
|
data: TData,
|
|
discord_id: string
|
|
): EUserType {
|
|
for (let discord_search_point in data["blacklist"]) {
|
|
if (data.blacklist[discord_search_point].discord === discord_id) {
|
|
return EUserType.Blacklisted;
|
|
}
|
|
}
|
|
for (let discord_search_point in data["members"]) {
|
|
if (data.blacklist[discord_search_point].discord === discord_id) {
|
|
return EUserType.Member;
|
|
}
|
|
}
|
|
return EUserType.Unregistered;
|
|
}
|
|
|
|
export function check_user_type_by_minecraft_uuid(
|
|
data: TData,
|
|
minecraft_uuid: string
|
|
): EUserType {
|
|
for (let discord_search_point in data.blacklist) {
|
|
for (let minecraft_search_point in data.blacklist[discord_search_point]
|
|
.minecraft) {
|
|
if (
|
|
data.blacklist[discord_search_point].minecraft[
|
|
minecraft_search_point
|
|
] === minecraft_uuid
|
|
) {
|
|
return EUserType.Blacklisted;
|
|
}
|
|
}
|
|
}
|
|
for (let discord_search_point in data.members) {
|
|
for (let minecraft_search_point in data.members[discord_search_point]
|
|
.minecraft) {
|
|
if (
|
|
data.members[discord_search_point].minecraft[minecraft_search_point] ===
|
|
minecraft_uuid
|
|
) {
|
|
return EUserType.Member;
|
|
}
|
|
}
|
|
}
|
|
return EUserType.Unregistered;
|
|
}
|