Skip to content

Commit

Permalink
don't use non-ephemeral functions if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Feb 6, 2024
1 parent 0df3ad9 commit e5a9043
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
9 changes: 5 additions & 4 deletions src/client/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ function hasPermission(type: PermissionType, warnUser = true): boolean {
return out;
}

async function ephemeralReply(options: InteractionReplyOptions) {
function ephemeralReply(options: InteractionReplyOptions) {
// it's already deferred so we delete the non-ephemeral message
await this.deleteReply().catch(() => {});
return this.followUp({ ...options, ephemeral: true });
return this.deleteReply()
.then(() => this.followUp({ ...options, ephemeral: true }))
.catch(() => {});
}

async function complete() {
function complete() {
return this.reply({ content: "** **", fetchReply: true })
.then((message: Message) => message.delete())
.catch(() => {});
Expand Down
4 changes: 3 additions & 1 deletion src/helpers/functions/missing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ export async function updateVoiceChannel(client: Client, results: MissingData) {
const { data: packProgress } = await axios
.get(`${client.tokens.apiUrl}settings/discord.channels.pack_progress`)
// fix for "Error: socket hang up", I know it's stupid but it works somehow
.catch(() => axios.get(`https://api.faithfulpack.net/v2/settings/discord.channels.pack_progress`));
.catch(() =>
axios.get(`https://api.faithfulpack.net/v2/settings/discord.channels.pack_progress`),
);

const channel = client.channels.cache.get(packProgress[results.pack][results.edition]);
// channel doesn't exist or can't be fetched, return early
Expand Down
12 changes: 6 additions & 6 deletions src/helpers/images/ColorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default class ColorManager {
const diff = max - min;

let h: number;
if (diff == 0) h = 0;
if (!diff) h = 0;
else
switch (max) {
case r:
Expand All @@ -164,7 +164,7 @@ export default class ColorManager {
break;
}

const s = max == 0 ? 0 : diff / max;
const s = max === 0 ? 0 : diff / max;
const v = max;

return { h: +h.toFixed(0), s: +(s * 100).toFixed(1), v: +(v * 100).toFixed(1) };
Expand All @@ -191,10 +191,10 @@ export default class ColorManager {
y = Math.round(((y - k) / (1 - k)) * 10000) / 100;
k = Math.round(k * 10000) / 100;

c = isNaN(c) ? 0 : c;
m = isNaN(m) ? 0 : m;
y = isNaN(y) ? 0 : y;
k = isNaN(k) ? 0 : k;
c ||= 0;
m ||= 0;
y ||= 0;
k ||= 0;

return {
c: Math.round(c),
Expand Down

0 comments on commit e5a9043

Please sign in to comment.