Skip to content

Commit

Permalink
upgrade to const
Browse files Browse the repository at this point in the history
  • Loading branch information
Starman3787 committed Jul 14, 2024
1 parent 5ab4e75 commit c81d2bd
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ class Client extends EventsEmitter {
body,
);

let messages = [];
const messages = [];
for (let i = 0; i < data.length; i++)
messages.push(new Message(this, data[i], data[i].channel_id, guild_id));

Expand Down Expand Up @@ -758,7 +758,7 @@ class Client extends EventsEmitter {
body,
);
if (data.length != 0) {
let members = [];
const members = [];

for (let i = 0; i < data.length; i++)
members.push(
Expand Down
4 changes: 2 additions & 2 deletions src/gateway/eventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class EventHandler {
} @ ${this.ws.time()} => THREAD_LIST_SYNC ${data.guild_id}`,
);

let threads = [];
const threads = [];
for (let i = 0; i < data.threads.length; i++)
threads.push(new Thread(this._client, data.threads[i], data.guild_id));

Expand Down Expand Up @@ -543,7 +543,7 @@ class EventHandler {
} @ ${this.ws.time()} => MESSAGE_DELETE_BULK ${data.guild_id}`,
);

let messages = [];
const messages = [];
for (let i = 0; i < data.ids.length; i++)
messages.push(
getMessage(
Expand Down
2 changes: 1 addition & 1 deletion src/gateway/structures/_updatePresence.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function _updatePresence(
afk = false,
since = null,
) {
let activities = [];
const activities = [];

if (name)
activities.push({
Expand Down
6 changes: 3 additions & 3 deletions src/managers/ChannelMessageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ChannelMessageManager {
async fetch(options) {
if (typeof options == "object") {
if (this.cache.size != 0) {
let cachedMessages = [];
const cachedMessages = [];
this.cache.forEach((key, value) => {
if (options.before && value.id < options.before)
cachedMessages.push(value);
Expand All @@ -49,7 +49,7 @@ class ChannelMessageManager {
[this.channel.id],
body,
);
let messages = [];
const messages = [];
for (let i = 0; i < data.length; i++)
messages.push(
new Message(
Expand Down Expand Up @@ -87,7 +87,7 @@ class ChannelMessageManager {
this.channel.id,
]);

let messages = [];
const messages = [];
for (let i = 0; i < data.length; i++)
messages.push(
new Message(
Expand Down
7 changes: 3 additions & 4 deletions src/managers/GuildMemberManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,11 @@ class GuildMemberManager {
* @param {BigInt | String} user_id The id of the member to get.
* @returns {Member}
*/
async localFetch(user_id) {
localFetch(user_id) {
const cached = this.cache.get(user_id.toString());
if (cached) return cached;

const stored = await this.retrieve(user_id);
if (stored) return stored;
return this.retrieve(user_id);
}

/**
Expand Down Expand Up @@ -172,7 +171,7 @@ class GuildMemberManager {
body,
);
if (data.length != 0) {
let members = [];
const members = [];

for (let i = 0; i < data.length; i++)
members.push(
Expand Down
2 changes: 1 addition & 1 deletion src/managers/GuildScheduledEventManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GuildScheduledEventManager {
[this.guild.id],
);

let eventsList = [];
const eventsList = [];

for (let i = 0; i < data.length; i++)
eventsList.push(new ScheduledEvent(this._client, data[i]));
Expand Down
6 changes: 3 additions & 3 deletions src/rest/betterRequestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ class BetterRequestHandler {
new Date().getTime() / 1000 > bucket.reset + this.latency)
) {
const serialize = (obj) => {
let str = [];
const str = [];
for (let p in obj)
if (Object.prototype.hasOwnProperty.call(obj, p))
str.push(`${encodeURIComponent(p)}=${encodeURIComponent(obj[p])}`);
return str.join("&");
};

let headers = {
const headers = {
Authorization: this.authorization,
"User-Agent": `DiscordBot (${require("../../package.json").repository.url.slice(
4,
Expand Down Expand Up @@ -327,7 +327,7 @@ class BetterRequestHandler {

this._client.emit("debug", `REMOVE ${hash} from request queue`);
} else {
let retryNextIn =
const retryNextIn =
Math.ceil(bucket.reset - new Date().getTime() / 1000) + this.latency;

setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/rest/getBucket.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
async function getBucket(client, localRatelimitCache, hash) {
if (client.redis) {
try {
let rawBucket = (await client.redis.get(`gluon.paths.${hash}`)) || "{}";
const rawBucket = (await client.redis.get(`gluon.paths.${hash}`)) || "{}";

return JSON.parse(rawBucket);
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ class Guild {
* @type {String}
*/
get system_channel_flags() {
let flags = [];
const flags = [];

if ((this._attributes & (0b1 << 0)) == 0b1 << 0)
flags.push("SUPPRESS_JOIN_NOTIFICATIONS");
Expand Down Expand Up @@ -806,7 +806,7 @@ class Guild {
this.id,
]);

let channels = [];
const channels = [];
for (let i = 0; i < data.length; i++)
channels.push(cacheChannel(this._client, data[i], this.id.toString()));

Expand Down
2 changes: 1 addition & 1 deletion src/structures/Member.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Member {
get roles() {
if (this._client.cacheRoles != true) return [];

let roles = [];
const roles = [];

roles.push(this.guild.roles.cache.get(String(this._guild_id)));

Expand Down
2 changes: 1 addition & 1 deletion src/util/deepCompare.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function deepCompare(object0, object1) {
const keys1 = Object.keys(object1);
const keys = [...new Set(keys0.concat(keys1))];

let updatedFields = [];
const updatedFields = [];

for (let i = 0; i < keys.length; i++) {
if (object0[keys[i]] != object1[keys[i]]) updatedFields.push(keys[i]);
Expand Down
4 changes: 2 additions & 2 deletions src/util/updateGuildPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function updatePreferences(client, guild) {
}

function updateSingleGuildPreferences(client, guild) {
let currentGuild = client.guilds.cache.get(guild.id);
const currentGuild = client.guilds.cache.get(guild.id);
if (!currentGuild) return;
currentGuild._cache_options = 0;
if (guild.options.serverLog == null) {
Expand All @@ -32,7 +32,7 @@ function updateSingleGuildPreferences(client, guild) {
j < guild.options.additionalServerLogOptions.ignoreChannels.length;
j++
) {
let currentGuildChannel = currentGuild.channels.cache.get(
const currentGuildChannel = currentGuild.channels.cache.get(
guild.options.additionalServerLogOptions.ignoreChannels[j]
);
if (!currentGuildChannel) continue;
Expand Down

0 comments on commit c81d2bd

Please sign in to comment.