diff --git a/src/client/websocket/handlers/READY.js b/src/client/websocket/handlers/READY.js
index 08d4241..f32b378 100644
--- a/src/client/websocket/handlers/READY.js
+++ b/src/client/websocket/handlers/READY.js
@@ -97,7 +97,9 @@ module.exports = async (client, { d: data }, shard) => {
};
client.emit(
Events.DEBUG,
- `${chalk.greenBright('[OK]')} Patched ${chalk.cyanBright('VoiceConnection.prototype.configureNetworking')} [${chalk.bgMagentaBright('@discordjs/voice')} - ${chalk.redBright('v0.11.0')}]`,
+ `${chalk.greenBright('[OK]')} Patched ${chalk.cyanBright(
+ 'VoiceConnection.prototype.configureNetworking',
+ )} [${chalk.bgMagentaBright('@discordjs/voice')} - ${chalk.redBright('v0.11.0')}]`,
);
/* eslint-enable */
}
diff --git a/src/managers/GuildBanManager.js b/src/managers/GuildBanManager.js
index e67fd43..e0a40d9 100644
--- a/src/managers/GuildBanManager.js
+++ b/src/managers/GuildBanManager.js
@@ -1,11 +1,14 @@
'use strict';
+const process = require('node:process');
const { Collection } = require('@discordjs/collection');
const CachedManager = require('./CachedManager');
const { TypeError, Error } = require('../errors');
const GuildBan = require('../structures/GuildBan');
const { GuildMember } = require('../structures/GuildMember');
+let deprecationEmittedForDays = false;
+
/**
* Manages API methods for GuildBans and stores their cache.
* @extends {CachedManager}
@@ -126,6 +129,9 @@ class GuildBanManager extends CachedManager {
* Options used to ban a user from a guild.
* @typedef {Object} BanOptions
* @property {number} [days=0] Number of days of messages to delete, must be between 0 and 7, inclusive
+ * This property is deprecated. Use `deleteMessageSeconds` instead.
+ * @property {number} [deleteMessageSeconds=0] Number of seconds of messages to delete,
+ * must be between 0 and 604800 (7 days), inclusive
* @property {string} [reason] The reason for the ban
*/
@@ -142,15 +148,30 @@ class GuildBanManager extends CachedManager {
* .then(banInfo => console.log(`Banned ${banInfo.user?.tag ?? banInfo.tag ?? banInfo}`))
* .catch(console.error);
*/
- async create(user, options = { days: 0 }) {
+ async create(user, options = {}) {
if (typeof options !== 'object') throw new TypeError('INVALID_TYPE', 'options', 'object', true);
const id = this.client.users.resolveId(user);
if (!id) throw new Error('BAN_RESOLVE_ID', true);
+
+ if (typeof options.days !== 'undefined' && !deprecationEmittedForDays) {
+ process.emitWarning(
+ 'The days option for GuildBanManager#create() is deprecated. Use the deleteMessageSeconds option instead.',
+ 'DeprecationWarning',
+ );
+
+ deprecationEmittedForDays = true;
+ }
+
await this.client.api
.guilds(this.guild.id)
.bans(id)
.put({
- data: { delete_message_days: options.days },
+ data: {
+ delete_message_seconds:
+ typeof options.deleteMessageSeconds !== 'undefined'
+ ? options.deleteMessageSeconds
+ : (options.days ?? 0) * 24 * 60 * 60,
+ },
reason: options.reason,
});
if (user instanceof GuildMember) return user;
diff --git a/src/managers/GuildMemberManager.js b/src/managers/GuildMemberManager.js
index 0880fef..09c4a76 100644
--- a/src/managers/GuildMemberManager.js
+++ b/src/managers/GuildMemberManager.js
@@ -394,7 +394,7 @@ class GuildMemberManager extends CachedManager {
* .then(banInfo => console.log(`Banned ${banInfo.user?.tag ?? banInfo.tag ?? banInfo}`))
* .catch(console.error);
*/
- ban(user, options = { days: 0 }) {
+ ban(user, options) {
return this.guild.bans.create(user, options);
}
@@ -442,7 +442,76 @@ class GuildMemberManager extends CachedManager {
*/
fetchBruteforce(options) {
// eslint-disable-next-line
- let dictionary = [' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', '[', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'];
+ let dictionary = [
+ ' ',
+ '!',
+ '"',
+ '#',
+ '$',
+ '%',
+ '&',
+ "'",
+ '(',
+ ')',
+ '*',
+ '+',
+ ',',
+ '-',
+ '.',
+ '/',
+ '0',
+ '1',
+ '2',
+ '3',
+ '4',
+ '5',
+ '6',
+ '7',
+ '8',
+ '9',
+ ':',
+ ';',
+ '<',
+ '=',
+ '>',
+ '?',
+ '@',
+ '[',
+ ']',
+ '^',
+ '_',
+ '`',
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i',
+ 'j',
+ 'k',
+ 'l',
+ 'm',
+ 'n',
+ 'o',
+ 'p',
+ 'q',
+ 'r',
+ 's',
+ 't',
+ 'u',
+ 'v',
+ 'w',
+ 'x',
+ 'y',
+ 'z',
+ '{',
+ '|',
+ '}',
+ '~',
+ ];
let limit = 100;
let delay = 500;
if (options.dictionary) dictionary = options.dictionary;
diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js
index 0db6cc9..6fd1131 100644
--- a/src/structures/GuildMember.js
+++ b/src/structures/GuildMember.js
@@ -465,8 +465,8 @@ class GuildMember extends Base {
* @param {BanOptions} [options] Options for the ban
* @returns {Promise}
* @example
- * // ban a guild member
- * guildMember.ban({ days: 7, reason: 'They deserved it' })
+ * // Ban a guild member, deleting a week's worth of messages
+ * guildMember.ban({ deleteMessageSeconds: 60 * 60 * 24 * 7, reason: 'They deserved it' })
* .then(console.log)
* .catch(console.error);
*/
diff --git a/typings/index.d.ts b/typings/index.d.ts
index 2c57c3b..c59dc16 100644
--- a/typings/index.d.ts
+++ b/typings/index.d.ts
@@ -3771,7 +3771,7 @@ export class GuildMemberManager extends CachedManager>;
- public fetchBruteforce(options?: BruteforceOptions): Promise>
+ public fetchBruteforce(options?: BruteforceOptions): Promise>;
public kick(user: UserResolvable, reason?: string): Promise;
public list(options?: GuildListMembersOptions): Promise>;
public prune(options: GuildPruneMembersOptions & { dry?: false; count: false }): Promise;
@@ -4858,7 +4858,9 @@ export interface AwaitReactionsOptions extends ReactionCollectorOptions {
}
export interface BanOptions {
+ /** @deprecated Use {@link deleteMessageSeconds} instead. */
days?: number;
+ deleteMessageSeconds?: number;
reason?: string;
}