mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
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:
@@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const process = require('node:process');
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
const { makeURLSearchParams } = require('@discordjs/rest');
|
const { makeURLSearchParams } = require('@discordjs/rest');
|
||||||
const { Routes } = require('discord-api-types/v10');
|
const { Routes } = require('discord-api-types/v10');
|
||||||
@@ -8,6 +9,8 @@ const { TypeError, Error, ErrorCodes } = require('../errors');
|
|||||||
const GuildBan = require('../structures/GuildBan');
|
const GuildBan = require('../structures/GuildBan');
|
||||||
const { GuildMember } = require('../structures/GuildMember');
|
const { GuildMember } = require('../structures/GuildMember');
|
||||||
|
|
||||||
|
let deprecationEmittedForDeleteMessageDays = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages API methods for GuildBans and stores their cache.
|
* Manages API methods for GuildBans and stores their cache.
|
||||||
* @extends {CachedManager}
|
* @extends {CachedManager}
|
||||||
@@ -152,6 +155,17 @@ class GuildBanManager extends CachedManager {
|
|||||||
if (typeof options !== 'object') throw new TypeError(ErrorCodes.InvalidType, 'options', 'object', true);
|
if (typeof options !== 'object') throw new TypeError(ErrorCodes.InvalidType, 'options', 'object', true);
|
||||||
const id = this.client.users.resolveId(user);
|
const id = this.client.users.resolveId(user);
|
||||||
if (!id) throw new Error(ErrorCodes.BanResolveId, true);
|
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), {
|
await this.client.rest.put(Routes.guildBan(this.guild.id, id), {
|
||||||
body: {
|
body: {
|
||||||
delete_message_seconds:
|
delete_message_seconds:
|
||||||
|
|||||||
Reference in New Issue
Block a user