gapi / gupi

A TypeScript NodeJS API Wrapper for Guilded.gg API.

Currently unstable and in active dev. Use with caution.
The name is gapi but silly google took that name so on npm we use gupi
Design Goals
- Amazing Scalability!
- Great developer experience!
- Extremely flexible/dynamic!
Features
Usage
Beginner/Basic
import { Client } from 'gupi';
new Client({ email: 'emailhere', password: 'passwordhere' })
.on('ready', () => console.log('Successfully connected to gateway'))
.on('messageCreate', message => {
if (message.content === '!ping') {
message.send(`Ping MS: ${Date.now() - message.timestamp}ms`);
}
})
.on('unknown', console.log)
.connect();
BotClient (Full Command Framework)
// index.ts
import { BotClient } from 'gupi';
import configs from './configs';
// Start it up!
const client = new BotClient(configs).on('ready', () => console.log('Successfully connected to gateway')).connect();
// src/commands/avatar.ts
import { Command, CommandArgument, Message, User, Embed } from 'gupi';
export default class extends Command {
name = 'avatar';
aliases = ['pfp'];
description = '🖼️ View the avatar image for a user or the server.';
arguments = [
{ name: 'server', type: 'string', literals: ['server'], required: false },
{ name: 'user', type: 'user', required: false },
] as CommandArgument[];
async execute(message: Message, args: { user?: User; server?: 'server' }) {
// BY DEFAULT WE USE THE USERS OWN URL
let url = message.author.dynamicAvatarURL({ type: 'Large' });
// IF THE USER WANTED THE SERVER AVATAR USE IT
if (args.server && message.team) url = message.team.dynamicAvatarURL({ type: 'Large' });
// IF A USER WAS REQUESTED, THEN WE USE THAT
if (args.user) url = args.user.dynamicAvatarURL({ type: 'Large' });
return message.send(
new Embed()
.setAuthor(message.author)
.setDescription(`[${message.translate('commands/avatar:DOWNLOAD_LINK')}](${url})`)
.setImage(url),
);
}
}

Advanced Customizations
Everything below this is to showcase examples of advanced features! They are intentionally written in a way that is confusing to a beginner developer, as it is not meant for you. This is an extreme edge case scenario for bots that scale really big!
// Cache Control!
// Set to 0 to disable caching. Apply to any desired Collection.
client.users.maxSize = 1000;
client.connect();
评论