@elara-services/leveling
Version:
A package for XP/Leveling on Discord.
632 lines (631 loc) • 22.4 kB
TypeScript
/// <reference types="mongoose/types/aggregate" />
/// <reference types="mongoose/types/callback" />
/// <reference types="mongoose/types/collection" />
/// <reference types="mongoose/types/connection" />
/// <reference types="mongoose/types/cursor" />
/// <reference types="mongoose/types/document" />
/// <reference types="mongoose/types/error" />
/// <reference types="mongoose/types/expressions" />
/// <reference types="mongoose/types/helpers" />
/// <reference types="mongoose/types/middlewares" />
/// <reference types="mongoose/types/indexes" />
/// <reference types="mongoose/types/models" />
/// <reference types="mongoose/types/mongooseoptions" />
/// <reference types="mongoose/types/pipelinestage" />
/// <reference types="mongoose/types/populate" />
/// <reference types="mongoose/types/query" />
/// <reference types="mongoose/types/schemaoptions" />
/// <reference types="mongoose/types/schematypes" />
/// <reference types="mongoose/types/session" />
/// <reference types="mongoose/types/types" />
/// <reference types="mongoose/types/utility" />
/// <reference types="mongoose/types/validation" />
/// <reference types="mongoose/types/virtuals" />
/// <reference types="mongoose" />
/// <reference types="mongoose/types/inferschematype" />
import { Leveling } from "..";
import type { AnnounceToggleTypes, CachedOptions, CanvasLeaderboardTypes, CanvasRankProfileTypes, CanvasResponse, CanvasResponseWithQuery, ColorType, LeaderboardCanvasOptions, LeaderboardFormatted, LeaderboardFormattedResponse, LeaderboardOptions, LeaderboardUser, OptionalOptions, ServerToggleTypes, Settings, UserToggles, Users, Weekly } from "../interfaces";
export declare class API {
#private;
constructor(client: Leveling);
get servers(): {
/**
* Get a certain server's data
*/
get: (guildId: string) => Promise<{
status: false;
message: string;
} | {
status: true;
data: import("mongoose").FlattenMaps<Settings & {
_id: import("mongoose").Types.ObjectId;
}>;
}>;
setWebhook: (guildId: string, options: {
name?: string | null;
image?: string | null;
}) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Fetch multiple servers data
*/
fetchAll: (guildIds?: string[]) => Promise<{
status: false;
message: string;
} | {
status: true;
data: never[] | (import("mongoose").FlattenMaps<Settings> & {
_id: import("mongoose").Types.ObjectId;
})[];
}>;
/**
* Toggle on/off certain features for the server.
*/
toggle: (guildId: string, type: ServerToggleTypes) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set the cooldown for XP earned on a certain server or create a custom cooldown for certain roles.
* NOTE: This is in seconds!
*/
cooldown: (guildId: string, seconds: number, roles?: string[]) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set the min/max XP earned for messages on a certain server.
*/
setXP: (guildId: string, options: {
min?: number;
max?: number;
}) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
weekly: {
/**
* Set/Reset a certain channel for the weekly leaderboard announcements
*/
setChannel: (guildId: string, channelId: string) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set/Reset weekly leaderboard ping roles
* These role(s) will get mentioned when a new weekly leaderboard is posted.
*/
setRoles: (guildId: string, roles: string[]) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
};
/**
* Import leaderboards from other bots
*/
import: (guildId: string, targetGuildId: string, type?: "amari" | "mee6") => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
announce: {
/**
* Toggle on/off certain features for a certain server.
*/
toggle: (guildId: string, type: AnnounceToggleTypes) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set/Reset the content/embeds for certain types on a certain server.
*/
setMessage: (guildId: string, type: "dm" | "channel", options: OptionalOptions) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set/Reset the announcement channel for level ups.
*/
setChannel: (guildId: string, channelId: string) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
};
levels: {
/**
* Add a level to a certain server.
* NOTE: (add: Will add roles to the users once they level up, remove: Will remove roles from the user once they level up)
*/
add: (guildId: string, level: number, options?: {
levelName?: string | undefined;
add?: string[] | undefined;
remove?: string[] | undefined;
options?: OptionalOptions | undefined;
} | undefined) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Remove a certain level from a certain server.
*/
remove: (guildId: string, level: number) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set/Reset a certain level's (ADD) roles
* These roles will get added once the user reaches this level
*/
addRoles: (guildId: string, level: number, roles: string[]) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set/Reset a certain level's (REMOVE) roles
* These roles will get removed once the user reaches this level
*/
removeRoles: (guildId: string, level: number, roles: string[]) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set/Reset a certain level's announcement message for a certain server.
*/
setMessage: (guildId: string, options: OptionalOptions, level: number) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
get: (guildId: string, level: number) => Promise<{
status: false;
message: string;
} | {
status: true;
data: {
level: number;
levelName: string;
options: import("..").Options;
roles: {
add: string[];
remove: string[];
};
};
}>;
getLevelName: (guildId: string, level: number) => Promise<{
status: true;
message: string;
}>;
};
multipliers: {
/**
* Add a multiplier to a certain server.
*/
add: (guildId: string, multiplier: number, options?: {
roles?: string[];
channels?: string[];
}) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Remove a multiplier from a certain server.
*/
remove: (guildId: string, multiplier: number) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Add/Remove certain channels from being able to use this multiplier in a certain server.
*/
channels: (guildId: string, multiplier: number, channels: string[]) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Add/Remove certain roles from being able to use this multiplier in a certain server.
*/
roles: (guildId: string, multiplier: number, roles: string[]) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
};
ignore: {
/**
* Toggle on/off certain channels from being ignored in a certain server. (they will not gain XP)
*/
channels: (guildId: string, channels: string[]) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Toggle on/off certain roles from being ignored in a certain server. (they will not gain XP)
*/
roles: (guildId: string, roles: string[]) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Toggle on/off certain users from being ignored in a certain server. (they will not gain XP)
*/
users: (guildId: string, users: string[]) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
};
leaderboard: {
/**
* Get the leaderboard for a certain server.
*/
get: <D>(guildId: string, options?: LeaderboardOptions, board?: D | undefined) => Promise<{
status: false;
message: string;
} | LeaderboardFormattedResponse<LeaderboardUser[]>>;
/**
* Get the formatted leaderboard for a certain server.
* This will fetch the users information to have their Discord info in the returned data.
*/
formatted: <D_1>(guildId: string, options?: LeaderboardOptions, forceStatic?: boolean, board?: D_1 | undefined) => Promise<{
status: false;
message: string;
} | LeaderboardFormattedResponse<LeaderboardFormatted[]>>;
/**
* Set the leaderboard background (or color) for a certain server
* NOTE: Only available to 'canvacord' leaderboard type
*/
setBackground: (guildId: string, options: {
url?: string | null;
color?: string | null;
}) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
};
/**
* Delete all data belonging to a certain server (main data)
*/
delete: (guildId: string) => Promise<{
status: boolean;
message: string;
data: {
data: CachedOptions<Settings> | null;
weekly: CachedOptions<Weekly>[];
users: CachedOptions<Users>[];
};
}>;
users: {
get: (guildId: string) => Promise<{
status: false;
message: string;
} | {
status: true;
data: never[] | (import("mongoose").FlattenMaps<Users> & {
_id: import("mongoose").Types.ObjectId;
})[];
}>;
count: (guildId: string) => Promise<{
status: false;
message: string;
} | {
status: true;
data: {
count: number;
};
}>;
reset: (guildId: string) => Promise<{
status: false;
message: string;
} | {
status: true;
data: {
count: number;
users: never[] | (import("mongoose").FlattenMaps<Users> & {
_id: import("mongoose").Types.ObjectId;
})[];
};
}>;
left: (guildId: string, dry?: boolean) => Promise<{
status: false;
message: string;
} | {
status: true;
data: {
count: number;
deleted: boolean;
};
}>;
};
};
get users(): {
stats: {
/**
* Increments the stats count for the type provided.
* - Supports custom stats counters (default: 'messages', 'voice')
* - 'voice' is total minutes spent in a voice channel.
*/
inc: (userId: string, guildId: string, type: string, count?: number) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Decrements the stats count for the type provided.
* - Supports custom stats counters (default: 'messages', 'voice')
* - 'voice' is total minutes spent in a voice channel.
*/
dec: (userId: string, guildId: string, type: string, count?: number) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
};
/**
* Get a user's rank position for a server.
*/
position: (userId: string, guildId: string, sort?: "ascending" | "descending") => Promise<number>;
/**
* Get a user's profile data for a server.
*/
get: (userId: string, guildId: string) => Promise<{
status: false;
message: string;
} | {
status: true;
data: import("mongoose").FlattenMaps<Users & {
_id: import("mongoose").Types.ObjectId;
}>;
}>;
/**
* Get all profile data for a server
*/
fetchAll: (userId: string) => Promise<{
status: false;
message: string;
} | {
status: true;
data: never[] | (import("mongoose").FlattenMaps<Users> & {
_id: import("mongoose").Types.ObjectId;
})[];
}>;
/**
* Toggle certain features for a user on a server.
*/
toggle: (userId: string, guildId: string, type: UserToggles) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* [WARNING]: This should only be used for internal use, as any XP added will trigger a "levelup" event
*/
appendXP: (userId: string, guildId: string, xp: number, voiceMinutes?: number, handledInternally?: boolean) => Promise<boolean | null>;
/**
* Set a level for a user on a certain server.
*/
setLevel: (userId: string, guildId: string, level: number) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set/Reset a background for a user on a certain server.
*/
setBackground: (userId: string, guildId: string, background?: string) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set/Reset a background for a user on a certain server.
*/
setForeground: (userId: string, guildId: string, foreground?: string) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set/Reset color(s) for a user on a certain server.
*/
setColor: (userId: string, guildId: string, type: ColorType, color?: string | number) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Set XP for a user on a certain server.
*/
setXP: (userId: string, guildId: string, xp: number) => Promise<{
status: false;
message: string;
} | {
status: true;
message: string;
}>;
/**
* Create a user's profile in a certain server.
* NOTE: The package will automatically create it once they send a message or earn xp
*/
create: (userId: string, guildId: string) => Promise<{
status: false;
message: string;
} | {
status: true;
data: import("mongoose").FlattenMaps<Users & {
_id: import("mongoose").Types.ObjectId;
}>;
}>;
delete: {
/**
* Delete all data for a user.
*/
all: (userId: string) => Promise<{
status: false;
message: string;
} | {
status: boolean;
data: never[] | (import("mongoose").Document<unknown, {}, Users> & Users & {
_id: import("mongoose").Types.ObjectId;
})[];
message: string;
}>;
/**
* Delete a user's data for a certain server.
*/
guild: (userId: string, guildId: string) => Promise<{
status: false;
message: string;
} | {
status: boolean;
message: string;
data: import("mongoose").Document<unknown, {}, Users> & Users & {
_id: import("mongoose").Types.ObjectId;
};
}>;
};
/**
* Mass delete certain users data from the system
* NOTE: Deletes ALL the users profiles for ALL servers
*/
purge: (dry: boolean | undefined, users: string[]) => Promise<{
status: false;
message: string;
} | {
status: boolean;
message: string;
data: never[] | (import("mongoose").FlattenMaps<Users> & {
_id: import("mongoose").Types.ObjectId;
})[];
}>;
};
get weekly(): {
/**
* Get a server's weekly data (or a certain weeklyId's info)
*/
get: (guildId: string, weeklyId?: string) => Promise<{
status: false;
message: string;
} | {
status: true;
data: import("mongoose").FlattenMaps<Weekly & {
_id: import("mongoose").Types.ObjectId;
}>;
}>;
/**
* Get all of the weekly data for a server.
*/
fetchAll: (guildId: string) => Promise<{
status: false;
message: string;
} | {
status: true;
data: never[] | (import("mongoose").FlattenMaps<Weekly> & {
_id: import("mongoose").Types.ObjectId;
})[];
}>;
/**
* Get the server's weekly leaderboard data.
*/
leaderboard: (guildId: string, weeklyId?: string, options?: LeaderboardOptions) => Promise<{
status: false;
message: string;
} | LeaderboardFormattedResponse<LeaderboardFormatted[]>>;
};
/**
* Get the rank card for the user for a certain server.
* Returns an image buffer
*/
getRankCard(userId: string, guildId: string, type?: CanvasRankProfileTypes): CanvasResponse;
/**
* Get a server's leaderboard
* Returns an image buffer
*/
getLeaderboard(guildId: string, options?: Omit<LeaderboardCanvasOptions, "background" | "backgroundColor">, type?: CanvasLeaderboardTypes, isWeekly?: boolean, details?: {
title?: string;
subtitle?: string;
image?: string;
backgroundUrl?: string;
backgroundColor?: string;
} | null | undefined, weeklyId?: string): CanvasResponseWithQuery;
}