Skip to content

Commit

Permalink
refactor(GuildBanManager): Add deprecation warning for `deleteMessage…
Browse files Browse the repository at this point in the history
…Days` (#8659)

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

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
Jiralite and kodiakhq[bot] committed Sep 24, 2022
1 parent 1486bc9 commit e993122
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/discord.js/src/managers/GuildBanManager.js
@@ -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');
Expand All @@ -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}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e993122

Please sign in to comment.