refactor(GuildBanManager): Add deprecation warning for deleteMessageDays (#8659)

refactor(GuildBanManager): add deprecation warning for `deleteMessageDays`

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Jiralite
2022-09-24 15:45:30 +01:00
committed by GitHub
parent 1486bc9336
commit e9931229ae

View File

@@ -1,5 +1,6 @@
'use strict';
const process = require('node:process');
const { Collection } = require('@discordjs/collection');
const { makeURLSearchParams } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v10');
@@ -8,6 +9,8 @@ const { TypeError, Error, ErrorCodes } = require('../errors');
const GuildBan = require('../structures/GuildBan');
const { GuildMember } = require('../structures/GuildMember');
let deprecationEmittedForDeleteMessageDays = false;
/**
* Manages API methods for GuildBans and stores their cache.
* @extends {CachedManager}
@@ -152,6 +155,17 @@ class GuildBanManager extends CachedManager {
if (typeof options !== 'object') throw new TypeError(ErrorCodes.InvalidType, 'options', 'object', true);
const id = this.client.users.resolveId(user);
if (!id) throw new Error(ErrorCodes.BanResolveId, true);
if (typeof options.deleteMessageDays !== 'undefined' && !deprecationEmittedForDeleteMessageDays) {
process.emitWarning(
// eslint-disable-next-line max-len
'The deleteMessageDays option for GuildBanManager#create() is deprecated. Use the deleteMessageSeconds option instead.',
'DeprecationWarning',
);
deprecationEmittedForDeleteMessageDays = true;
}
await this.client.rest.put(Routes.guildBan(this.guild.id, id), {
body: {
delete_message_seconds: