ronantakizawa/codereview-bench huggingface dataset:
Repository: discordjs/discord.js
File: packages/discord.js/typings/index.d.ts (TypeScript)

Code before:
  reason?: string;
}

export interface SetRolePositionOptions {
  relative?: boolean;
  reason?: string;
}

export type ShardingManagerMode = 'process' | 'worker';

export interface ShardingManagerOptions {
  totalShards?: number | 'auto';
  shardList?: readonly number[] | 'auto';
  mode?: ShardingManagerMode;
  respawn?: boolean;
  silent?: boolean;
  shardArgs?: readonly string[];
  token?: string;
  execArgv?: readonly string[];
}

export interface SharedInteractionResponseOptions {
  withResponse?: boolean;
}

export interface ShowModalOptions extends SharedInteractionResponseOptions {}

export { Snowflake };

export type StageInstanceResolvable = StageInstance | Snowflake;

export interface StartThreadOptions {
  name: string;
  autoArchiveDuration?: ThreadAutoArchiveDuration;
  reason?: string;
  rateLimitPerUser?: number;
}

export type ClientStatus = number;

export type StickerResolvable = Sticker | Snowflake;

export type SystemChannelFlagsResolvable = BitFieldResolvable<SystemChannelFlagsString, number>;

export type StageChannelResolvable = StageChannel | Snowflake;

export interface StageInstanceEditOptions {
  topic?: string;
  privacyLevel?: StageInstancePrivacyLevel;
}


Review comment (suggestion):
```suggestion

// tslint:disable-next-line no-empty-interface
export interface ShowModalOptions extends SharedInteractionResponseOptions {}
```

Code after:
  Reaction,
  GuildScheduledEvent,
  ThreadMember,
}

export interface PartialUser extends Partialize<User, 'username' | 'tag' | 'discriminator'> {}

export type PresenceStatusData = ClientPresenceStatus | 'invisible';

export type PresenceStatus = PresenceStatusData | 'offline';

export interface ReactionCollectorOptions extends CollectorOptions<[MessageReaction, User]> {
  max?: number;
  maxEmojis?: number;
  maxUsers?: number;
}

export interface ReplyOptions {
  messageReference: MessageResolvable;
  failIfNotExists?: boolean;
}

export interface MessageReplyOptions extends Omit<MessageCreateOptions, 'reply'> {
  failIfNotExists?: boolean;
}

export interface ResolvedOverwriteOptions {
  allow: PermissionsBitField;
  deny: PermissionsBitField;
}

export interface RoleData {
  name?: string;
  color?: ColorResolvable;
  hoist?: boolean;
  position?: number;
  permissions?: PermissionResolvable;
  mentionable?: boolean;
  icon?: BufferResolvable | Base64Resolvable | EmojiResolvable | null;
  unicodeEmoji?: string | null;
}

export type RoleMention = '@everyone' | `<@&${Snowflake}>`;

export interface RolePosition {
  role: RoleResolvable;
  position: number;
}

export type RoleResolvable = Role | Snowflake;
Repository: discordjs/discord.js
File: packages/discord.js/typings/index.d.ts (TypeScript)

Code before:
  lockPermissions?: boolean;
  reason?: string;
}

export interface SetRolePositionOptions {
  relative?: boolean;
  reason?: string;
}

export type ShardingManagerMode = 'process' | 'worker';

export interface ShardingManagerOptions {
  totalShards?: number | 'auto';
  shardList?: readonly number[] | 'auto';
  mode?: ShardingManagerMode;
  respawn?: boolean;
  silent?: boolean;
  shardArgs?: readonly string[];
  token?: string;
  execArgv?: readonly string[];
}

// tslint:disable-next-line no-empty-interface
export interface ShowModalOptions {
  withResponse?: boolean;
}

export { Snowflake };

export type StageInstanceResolvable = StageInstance | Snowflake;

export interface StartThreadOptions {
  name: string;
  autoArchiveDuration?: ThreadAutoArchiveDuration;
  reason?: string;
  rateLimitPerUser?: number;
}

export type ClientStatus = number;

export type StickerResolvable = Sticker | Snowflake;

export type SystemChannelFlagsResolvable = BitFieldResolvable<SystemChannelFlagsString, number>;

export type StageChannelResolvable = StageChannel | Snowflake;

export interface StageInstanceEditOptions {
  topic?: string;
  privacyLevel?: StageInstancePrivacyLevel;
}


Review comment (suggestion):
```suggestion
export interface ShowModalOptions {
  withResponse?: boolean;
}
```

Code after:
  deny: PermissionsBitField;
}

export interface RoleData {
  name?: string;
  color?: ColorResolvable;
  hoist?: boolean;
  position?: number;
  permissions?: PermissionResolvable;
  mentionable?: boolean;
  icon?: BufferResolvable | Base64Resolvable | EmojiResolvable | null;
  unicodeEmoji?: string | null;
}

export type RoleMention = '@everyone' | `<@&${Snowflake}>`;

export interface RolePosition {
  role: RoleResolvable;
  position: number;
}

export type RoleResolvable = Role | Snowflake;

export interface RoleSubscriptionData {
  roleSubscriptionListingId: Snowflake;
  tierName: string;
  totalMonthsSubscribed: number;
  isRenewal: boolean;
}

export interface RoleTagData {
  botId?: Snowflake;
  integrationId?: Snowflake;
  premiumSubscriberRole?: true;
  subscriptionListingId?: Snowflake;
  availableForPurchase?: true;
  guildConnections?: true;
}

export interface SetChannelPositionOptions {
  relative?: boolean;
  reason?: string;
}

export interface SetParentOptions {
  lockPermissions?: boolean;
  reason?: string;
}

export interface SetRolePositionOptions {
  relative?: boolean;
Repository: discordjs/discord.js
File: packages/discord.js/src/structures/InteractionCallback.js (JavaScript)

Code before:
  /**
   * The time the original interaction was created at
   * @type {Date}
   * @readonly
   */
  get createdAt() {
    return new Date(this.createdTimestamp);
  }

  /**
   * The channel the original interaction was sent in
   * @type {?TextBasedChannels}
   * @readonly
   */
  get channel() {
    return this.client.channels.cache.get(this.channelId) ?? null;
  }

  /**
   * The guild the original interaction was sent in
   * @type {?Guild}
   * @readonly
   */
  get guild() {
    return this.client.guilds.cache.get(this.guildId) ?? null;
  }
}

module.exports = InteractionCallback;


Review comment (suggestion):
`this.channelId` and `this.guildId` were removed (111b3ddde9bca7f5a0df8f096991ba6ef68d4bd0).

```suggestion
  }
```

Code after:
'use strict';

const { DiscordSnowflake } = require('@sapphire/snowflake');

/**
 * Represents an interaction callback response from Discord
 */
class InteractionCallback {
  constructor(client, data) {
    /**
     * The client that instantiated this.
     * @name InteractionCallback#client
     * @type {Client}
     * @readonly
     */
    Object.defineProperty(this, 'client', { value: client });

    /**
     * The id of the original interaction response
     * @type {Snowflake}
     */
    this.id = data.id;

    /**
     * The type of the original interaction
     * @type {InteractionType}
     */
    this.type = data.type;

    /**
     * The instance id of the Activity if one was launched or joined
     * @type {?string}
     */
    this.activityInstanceId = data.activity_instance_id ?? null;

    /**
     * The id of the message that was created by the interaction
     * @type {?Snowflake}
     */
    this.responseMessageId = data.response_message_id ?? null;

    /**
     * Whether the message is in a loading state
     * @type {?boolean}
     */
    this.responseMessageLoading = data.response_message_loading ?? null;

    /**
     * Whether the response message was ephemeral
     * @type {?boolean}
     */
    this.responseMessageEphemeral = data.response_message_ephemeral ?? null;
  }

  /**
   * The timestamp the original interaction was created at
   * @type {number}
   * @readonly
   */
  get createdTimestamp() {
    return DiscordSnowflake.timestampFrom(this.id);
  }

  /**
   * The time the original interaction was created at
   * @type {Date}
   * @readonly
   */
  get createdAt() {
    return new Date(this.createdTimestamp);
  }
}

module.exports = InteractionCallback;
Repository: discordjs/discord.js
File: packages/discord.js/src/structures/PartialGroupDMChannel.js (JavaScript)

Code before:
    if ('owner_id' in data) {
      /**
       * The user id of the owner of this Group DM Channel
       * @type {?Snowflake}
       */
      this.ownerId = data.owner_id;
    } else {
      this.ownerId ??= null;
    }

    if ('last_message_id' in data) {
      /**
       * The channel's last message id, if one was sent
       * @type {?Snowflake}
       */
      this.lastMessageId = data.last_message_id;
    } else {
      this.lastMessageId ??= null;
    }

    if ('last_pin_timestamp' in data) {
      /**
       * The timestamp when the last pinned message was pinned, if there was one
       * @type {?number}
       */
      this.lastPinTimestamp = Date.parse(data.last_pin_timestamp);
    } else {
      this.lastPinTimestamp ??= null;
    }
  }

  /**
   * The URL to this channel's icon.
   * @param {ImageURLOptions} [options={}] Options for the image URL
   * @returns {?string}
   */
  iconURL(options = {}) {
    return this.icon && this.client.rest.cdn.channelIcon(this.id, this.icon, options);
  }

  /**
   * Fetches the owner of this Group DM Channel.
   * @param {BaseFetchOptions} [options] The options for fetching the user
   * @returns {Promise<User>}
   */
  async fetchOwner(options) {
    if (!this.ownerId) {
      throw new DiscordjsError(ErrorCodes.FetchOwnerId, 'group DM');
    }

    return this.client.users.fetch(this.ownerId, options);

Review comment (suggestion):
This will return `NaN` for null last_pin_timestamp

```suggestion
      this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
```

Code after:
    if ('owner_id' in data) {
      /**
       * The user id of the owner of this Group DM Channel
       * @type {?Snowflake}
       */
      this.ownerId = data.owner_id;
    } else {
      this.ownerId ??= null;
    }

    if ('last_message_id' in data) {
      /**
       * The channel's last message id, if one was sent
       * @type {?Snowflake}
       */
      this.lastMessageId = data.last_message_id;
    } else {
      this.lastMessageId ??= null;
    }

    if ('last_pin_timestamp' in data) {
      /**
       * The timestamp when the last pinned message was pinned, if there was one
       * @type {?number}
       */
      this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
    } else {
      this.lastPinTimestamp ??= null;
    }
  }

  /**
   * The URL to this channel's icon.
   * @param {ImageURLOptions} [options={}] Options for the image URL
   * @returns {?string}
   */
  iconURL(options = {}) {
    return this.icon && this.client.rest.cdn.channelIcon(this.id, this.icon, options);
  }

  /**
   * Fetches the owner of this Group DM Channel.
   * @param {BaseFetchOptions} [options] The options for fetching the user
   * @returns {Promise<User>}
   */
  async fetchOwner(options) {
    if (!this.ownerId) {
      throw new DiscordjsError(ErrorCodes.FetchOwnerId, 'group DM');
    }

    return this.client.users.fetch(this.ownerId, options);
Repository: discordjs/discord.js
File: packages/discord.js/src/structures/GuildAuditLogsEntry.js (JavaScript)

Code before:
'use strict';

const { DiscordSnowflake } = require('@sapphire/snowflake');
const { AuditLogOptionsType, AuditLogEvent } = require('discord-api-types/v10');
const AutoModerationRule = require('./AutoModerationRule');
const { GuildOnboardingPrompt } = require('./GuildOnboardingPrompt');
const { GuildScheduledEvent } = require('./GuildScheduledEvent');
const Integration = require('./Integration');
const Invite = require('./Invite');
const { StageInstance } = require('./StageInstance');
const { Sticker } = require('./Sticker');
const Webhook = require('./Webhook');
const Partials = require('../util/Partials');
const { flatten } = require('../util/Util');

const Targets = {
  /** @deprecated this was never used or a possible value to begin with */
  All: 'All',
  Guild: 'Guild',
  GuildScheduledEvent: 'GuildScheduledEvent',
  Channel: 'Channel',
  User: 'User',
  Role: 'Role',
  Invite: 'Invite',
  Webhook: 'Webhook',
  Emoji: 'Emoji',
  Message: 'Message',
  Integration: 'Integration',
  StageInstance: 'StageInstance',
  Sticker: 'Sticker',
  Thread: 'Thread',
  ApplicationCommand: 'ApplicationCommand',
  AutoModeration: 'AutoModeration',
  GuildOnboarding: 'GuildOnboarding',
  GuildOnboardingPrompt: 'GuildOnboardingPrompt',
  Unknown: 'Unknown',
};

/**
 * The target of a guild audit log entry. It can be one of:
 * * A guild
 * * A channel

Review comment (suggestion):
If this is to target main, this can just be removed and a separate pull request can be made to backport it into v14.

Otherwise, we can keep this as-is, change the base branch to v14, and open another pull request for main.

Code after:
'use strict';

const { DiscordSnowflake } = require('@sapphire/snowflake');
const { AuditLogOptionsType, AuditLogEvent } = require('discord-api-types/v10');
const AutoModerationRule = require('./AutoModerationRule');
const { GuildOnboardingPrompt } = require('./GuildOnboardingPrompt');
const { GuildScheduledEvent } = require('./GuildScheduledEvent');
const Integration = require('./Integration');
const Invite = require('./Invite');
const { StageInstance } = require('./StageInstance');
const { Sticker } = require('./Sticker');
const Webhook = require('./Webhook');
const Partials = require('../util/Partials');
const { flatten } = require('../util/Util');

const Targets = {
  Guild: 'Guild',
  GuildScheduledEvent: 'GuildScheduledEvent',
  Channel: 'Channel',
  User: 'User',
  Role: 'Role',
  Invite: 'Invite',
  Webhook: 'Webhook',
  Emoji: 'Emoji',
  Message: 'Message',
  Integration: 'Integration',
  StageInstance: 'StageInstance',
  Sticker: 'Sticker',
  Thread: 'Thread',
  ApplicationCommand: 'ApplicationCommand',
  AutoModeration: 'AutoModeration',
  GuildOnboarding: 'GuildOnboarding',
  GuildOnboardingPrompt: 'GuildOnboardingPrompt',
  Unknown: 'Unknown',
};

/**
 * The target of a guild audit log entry. It can be one of:
 * * A guild
 * * A channel
 * * A user
 * * A role
Repository: discordjs/discord.js
File: packages/discord.js/src/structures/Subscription.js (JavaScript)

Code before:

    /**
     * The end of the current subscription period
     * @type {Date}
     */
    this.currentPeriodEnd = new Date(data.current_period_end);

    /**
     * The current status of the subscription
     * @type {SubscriptionStatus}
     */
    this.status = data.status;

    if ('canceled_at' in data) {
      /**
       * The timestamp of when the subscription was canceled
       * @type {?number}
       */
      this.canceledTimestamp = data.canceled_at ? Date.parse(data.canceled_at) : null;
    } else {
      this.canceledTimestamp ??= null;
    }

    if ('country' in data) {
      /**
       * ISO3166-1 alpha-2 country code of the payment source used to purchase the subscription.
       * Missing unless queried with a private OAuth scope.
       * @type {?string}
       */
      this.country = data.country;
    } else {
      this.country ??= null;
    }
  }

  /**
   * The date at which this subscription was canceled
   * @type {?Date}
   * @readonly
   */
  get canceledAt() {
    return this.canceledTimestamp && new Date(this.canceledTimestamp);
  }
}

exports.Subscription = Subscription;


Review comment (suggestion):
```suggestion
       * ISO 3166-1 alpha-2 country code of the payment source used to purchase the subscription.
```

Code after:

    /**
     * The timestamp the current subscription period will end at
     * @type {number}
     */
    this.currentPeriodEndTimestamp = Date.parse(data.current_period_end);

    /**
     * The current status of the subscription
     * @type {SubscriptionStatus}
     */
    this.status = data.status;

    if ('canceled_at' in data) {
      /**
       * The timestamp of when the subscription was canceled
       * @type {?number}
       */
      this.canceledTimestamp = data.canceled_at ? Date.parse(data.canceled_at) : null;
    } else {
      this.canceledTimestamp ??= null;
    }

    if ('country' in data) {
      /**
       * ISO 3166-1 alpha-2 country code of the payment source used to purchase the subscription.
       * Missing unless queried with a private OAuth scope.
       * @type {?string}
       */
      this.country = data.country;
    } else {
      this.country ??= null;
    }
  }

  /**
   * The time the subscription was canceled
   * @type {?Date}
   * @readonly
   */
  get canceledAt() {
    return this.canceledTimestamp && new Date(this.canceledTimestamp);
  }

  /**
   * The time the current subscription period will start at
   * @type {Date}
   * @readonly
   */
  get currentPeriodStartAt() {
    return new Date(this.currentPeriodStartTimestamp);
Repository: discordjs/discord.js
File: packages/discord.js/src/client/websocket/handlers/SUBSCRIPTION_DELETE.js (JavaScript)

Code before:
'use strict';

const Events = require('../../../util/Events');

module.exports = (client, { d: data }) => {
  const subscription = client.application.subscriptions.cache._add(data, false);

  client.application.subscriptions.cache.delete(subscription.id);

  /**
   * Emitted whenever a subscription is deleted.
   * @event Client#subscriptionDelete
   * @param {Subscription} subscription The subscription that was deleted
   */
  client.emit(Events.SubscriptionDelete, subscription);
};


Review comment (suggestion):
```suggestion
  const subscription = client.application.subscriptions._add(data, false);
```

Code after:
'use strict';

const Events = require('../../../util/Events');

module.exports = (client, { d: data }) => {
  const subscription = client.application.subscriptions._add(data, false);

  client.application.subscriptions.cache.delete(subscription.id);

  /**
   * Emitted whenever a subscription is deleted.
   * @event Client#subscriptionDelete
   * @param {Subscription} subscription The subscription that was deleted
   */
  client.emit(Events.SubscriptionDelete, subscription);
};
Repository: discordjs/discord.js
File: packages/discord.js/src/structures/ClientApplication.js (JavaScript)

Code before:
      this.roleConnectionsVerificationURL ??= null;
    }

    if ('event_webhooks_url' in data) {
      /**
       * This application's event webhooks URL
       * @type {?string}
       */
      this.eventWebhooksURL = data.event_webhooks_url;
    } else {
      this.eventWebhooksURL ??= null;
    }

    if ('event_webhooks_status' in data) {
      /**
       * This application's event webhooks status
       * @type {?ApplicationWebhookEventStatus}
       */
      this.eventWebhooksStatus = data.event_webhooks_status;
    } else {
      this.eventWebhooksStatus ??= null;
    }

    if ('event_webhooks_types' in data) {
      /**
       * This application's event webhooks types
       * @type {?ApplicationWebhookEventType[]}
       */
      this.eventWebhooksTypes = data.event_webhooks_types;
    } else {
      this.eventWebhooksTypes ??= null;
    }

    /**
     * The owner of this OAuth application
     * @type {?(User|Team)}
     */
    this.owner = data.team
      ? new Team(this.client, data.team)
      : data.owner
        ? this.client.users._add(data.owner)
        : (this.owner ?? null);
  }

  /**
   * The guild associated with this application.
   * @type {?Guild}
   * @readonly
   */
  get guild() {
    return this.client.guilds.cache.get(this.guildId) ?? null;

Review comment (suggestion):
Something like this 

```suggestion
       * This application's subscribed event webhooks types
```

```suggestion
       * List of event webhooks types this application subscribes to
```

Code after:
      this.roleConnectionsVerificationURL ??= null;
    }

    if ('event_webhooks_url' in data) {
      /**
       * This application's URL to receive event webhooks
       * @type {?string}
       */
      this.eventWebhooksURL = data.event_webhooks_url;
    } else {
      this.eventWebhooksURL ??= null;
    }

    if ('event_webhooks_status' in data) {
      /**
       * This application's event webhooks status
       * @type {?ApplicationWebhookEventStatus}
       */
      this.eventWebhooksStatus = data.event_webhooks_status;
    } else {
      this.eventWebhooksStatus ??= null;
    }

    if ('event_webhooks_types' in data) {
      /**
       * List of event webhooks types this application subscribes to
       * @type {?ApplicationWebhookEventType[]}
       */
      this.eventWebhooksTypes = data.event_webhooks_types;
    } else {
      this.eventWebhooksTypes ??= null;
    }

    /**
     * The owner of this OAuth application
     * @type {?(User|Team)}
     */
    this.owner = data.team
      ? new Team(this.client, data.team)
      : data.owner
        ? this.client.users._add(data.owner)
        : (this.owner ?? null);
  }

  /**
   * The guild associated with this application.
   * @type {?Guild}
   * @readonly
   */
  get guild() {
    return this.client.guilds.cache.get(this.guildId) ?? null;
Repository: discordjs/discord.js
File: packages/discord.js/src/structures/ClientApplication.js (JavaScript)

Code before:
      this.botPublic ??= null;
    }

    if ('interactions_endpoint_url' in data) {
      /**
       * This application's interaction endpoint URL.
       * @type {?string}
       */
      this.interactionsEndpointURL = data.interactions_endpoint_url;
    } else {
      this.interactionsEndpointURL ??= null;
    }

    if ('role_connections_verification_url' in data) {
      /**
       * This application's role connection verification entry point URL
       * @type {?string}
       */
      this.roleConnectionsVerificationURL = data.role_connections_verification_url;
    } else {
      this.roleConnectionsVerificationURL ??= null;
    }

    if ('event_webhooks_url' in data) {
      /**
       * This application's event webhooks URL
       * @type {?string}
       */
      this.eventWebhooksURL = data.event_webhooks_url;
    } else {
      this.eventWebhooksURL ??= null;
    }

    if ('event_webhooks_status' in data) {
      /**
       * This application's event webhooks status
       * @type {?ApplicationWebhookEventStatus}
       */
      this.eventWebhooksStatus = data.event_webhooks_status;
    } else {
      this.eventWebhooksStatus ??= null;
    }

    if ('event_webhooks_types' in data) {
      /**
       * This application's event webhooks types
       * @type {?ApplicationWebhookEventType[]}
       */
      this.eventWebhooksTypes = data.event_webhooks_types;
    } else {
      this.eventWebhooksTypes ??= null;

Review comment (suggestion):
Something like this
```suggestion
       * This application's URL to receive event webhooks
```

Code after:
      this.botPublic ??= null;
    }

    if ('interactions_endpoint_url' in data) {
      /**
       * This application's interaction endpoint URL.
       * @type {?string}
       */
      this.interactionsEndpointURL = data.interactions_endpoint_url;
    } else {
      this.interactionsEndpointURL ??= null;
    }

    if ('role_connections_verification_url' in data) {
      /**
       * This application's role connection verification entry point URL
       * @type {?string}
       */
      this.roleConnectionsVerificationURL = data.role_connections_verification_url;
    } else {
      this.roleConnectionsVerificationURL ??= null;
    }

    if ('event_webhooks_url' in data) {
      /**
       * This application's URL to receive event webhooks
       * @type {?string}
       */
      this.eventWebhooksURL = data.event_webhooks_url;
    } else {
      this.eventWebhooksURL ??= null;
    }

    if ('event_webhooks_status' in data) {
      /**
       * This application's event webhooks status
       * @type {?ApplicationWebhookEventStatus}
       */
      this.eventWebhooksStatus = data.event_webhooks_status;
    } else {
      this.eventWebhooksStatus ??= null;
    }

    if ('event_webhooks_types' in data) {
      /**
       * List of event webhooks types this application subscribes to
       * @type {?ApplicationWebhookEventType[]}
       */
      this.eventWebhooksTypes = data.event_webhooks_types;
    } else {
      this.eventWebhooksTypes ??= null;