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

@@ -320,6 +320,20 @@ class Client extends BaseClient {
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.
* @param {GuildTemplateResolvable} template Template code or URL

View File

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