Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/discord.js/src/managers/GuildBanManager.js
Original file line number Diff line number Diff line change
@@ -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