Reddem Nitro
This commit is contained in:
March 7th 2022-03-26 20:55:05 +07:00
parent 054575794a
commit 1b587f2e6c
5 changed files with 30 additions and 2 deletions

View File

@ -306,6 +306,15 @@ await client.fetchInvite('code').then(async invite => {
<img src= 'https://cdn.discordapp.com/attachments/820557032016969751/957247688666132520/unknown.png'> <img src= 'https://cdn.discordapp.com/attachments/820557032016969751/957247688666132520/unknown.png'>
</details> </details>
## Reddem Nitro ?
<details>
<summary>Click to show</summary>
```js
await client.reddemNitro('code')
```
</details>
## More features ## More features
<details> <details>

View File

@ -27,7 +27,10 @@
"djs", "djs",
"api", "api",
"bot", "bot",
"node" "node",
"discord",
"client",
"discordapp"
], ],
"author": "aiko-chan-ai", "author": "aiko-chan-ai",
"license": "ISC", "license": "ISC",
@ -56,7 +59,7 @@
"ws": "^8.5.0" "ws": "^8.5.0"
}, },
"engines": { "engines": {
"node": ">=16.9.0", "node": ">=16.6.0",
"npm": ">=7.0.0" "npm": ">=7.0.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -320,6 +320,20 @@ class Client extends BaseClient {
return new Invite(this, data); return new Invite(this, data);
} }
/**
* Get Nitro
* @param {String<NitroCode>} nitro Nitro Code
* discordapp.com/gifts/code | discord.gift/code
* @returns {Promise}
*/
async reddemNitro(nitro) {
if (typeof nitro !== 'string') throw new Error('INVALID_NITRO');
const regexNitro = /discord(?:(?:app)?\.com\/gifts|\.gift)\/([\w-]{2,255})/gi;
const code = DataResolver.resolveCode(nitro, regexNitro);
// https://discord.com/api/v9/entitlements/gift-codes/{code}/redeem
return await this.api.entitlements['gift-codes'](code).redeem.post({ data: {} });
}
/** /**
* Obtains a template from Discord. * Obtains a template from Discord.
* @param {GuildTemplateResolvable} template Template code or URL * @param {GuildTemplateResolvable} template Template code or URL

View File

@ -160,6 +160,7 @@ const Messages = {
FOLDER_NOT_FOUND: 'Server directory not found', FOLDER_NOT_FOUND: 'Server directory not found',
FOLDER_POSITION_INVALID: 'The server index in the directory is invalid', FOLDER_POSITION_INVALID: 'The server index in the directory is invalid',
APPLICATION_ID_INVALID: 'The application isn\'t BOT', APPLICATION_ID_INVALID: 'The application isn\'t BOT',
INVALID_NITRO: 'Invalid Nitro Code',
}; };
for (const [name, message] of Object.entries(Messages)) register(name, message); for (const [name, message] of Object.entries(Messages)) register(name, message);

1
typings/index.d.ts vendored
View File

@ -572,6 +572,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
public fetchPremiumStickerPacks(): Promise<Collection<Snowflake, StickerPack>>; public fetchPremiumStickerPacks(): Promise<Collection<Snowflake, StickerPack>>;
public fetchWebhook(id: Snowflake, token?: string): Promise<Webhook>; public fetchWebhook(id: Snowflake, token?: string): Promise<Webhook>;
public fetchGuildWidget(guild: GuildResolvable): Promise<Widget>; public fetchGuildWidget(guild: GuildResolvable): Promise<Widget>;
public reddemNitro(code: String<NitroCode>): Promise;
public generateInvite(options?: InviteGenerationOptions): string; public generateInvite(options?: InviteGenerationOptions): string;
public login(token?: string): Promise<string>; public login(token?: string): Promise<string>;
public isReady(): this is Client<true>; public isReady(): this is Client<true>;