Skip to content

Commit

Permalink
fix optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Nov 26, 2023
1 parent e217a3a commit 8157951
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/commands/fun/coin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const command: SlashCommand = {
res > 0.5
? "https://database.faithfulpack.net/images/bot/coin_heads.png?w=240&enlarge=1"
: res < 0.5
? "https://database.faithfulpack.net/images/bot/coin_tails.png?w=240&enlarge=1"
: "https://database.faithfulpack.net/images/bot/coin_edge.png?w=240&enlarge=1",
? "https://database.faithfulpack.net/images/bot/coin_tails.png?w=240&enlarge=1"
: "https://database.faithfulpack.net/images/bot/coin_edge.png?w=240&enlarge=1",
)
.setColor(colors.coin);

Expand Down
48 changes: 26 additions & 22 deletions src/helpers/functions/errorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ export const logConstructor = (
log.type === "slashCommand"
? `${log.type} [${log.data.commandName}]`
: log.type === "guildMemberUpdate"
? `${log.type} | ${log.data.user.username} ${
log.data.reason === "added" ? "joined" : "left"
} ${log.data.guild.name}`
: log.type === "message"
? `${log.type} | ${
log.data.author ? (log.data.author.bot ? "BOT" : "USER") : "Unknown (likely bot)"
} | ${log.data.author ? log.data.author.username : "Unknown"}`
: log.type,
? `${log.type} | ${log.data.user.username} ${
log.data.reason === "added" ? "joined" : "left"
} ${log.data.guild.name}`
: log.type === "message"
? `${log.type} | ${
log.data.author
? log.data.author.bot
? "BOT"
: "USER"
: "Unknown (likely bot)"
} | ${log.data.author ? log.data.author.username : "Unknown"}`
: log.type,
)
.replace(
"%templateCreatedTimestamp%",
Expand All @@ -72,14 +76,14 @@ export const logConstructor = (
log.data.url
? log.data.url
: log.data.message
? log.data.message.url // interaction
: log.data.guildId && log.data.channelId
? `https://discord.com/channels/${log.data.guildId}/${log.data.channelId}/${
log.data.messageId ? log.data.messageId : ""
}` // slash command constructed url
: log.data.guild
? `Guild ID is ${log.data.guild.id}`
: "Unknown",
? log.data.message.url // interaction
: log.data.guildId && log.data.channelId
? `https://discord.com/channels/${log.data.guildId}/${log.data.channelId}/${
log.data.messageId ? log.data.messageId : ""
}` // slash command constructed url
: log.data.guild
? `Guild ID is ${log.data.guild.id}`
: "Unknown",
)

.replace("%templateChannelType%", log.data.channel ? log.data.channel.type : "Not relevant")
Expand All @@ -90,12 +94,12 @@ export const logConstructor = (
? "Empty"
: log.data.content
: log.data.customId
? log.data.customId // button
: log.data.options
? `Parameters: ${JSON.stringify(log.data.options._hoistedOptions)}` // slash commands interaction
: log.type === "guildMemberUpdate"
? "Not relevant"
: "Unknown",
? log.data.customId // button
: log.data.options
? `Parameters: ${JSON.stringify(log.data.options._hoistedOptions)}` // slash commands interaction
: log.type === "guildMemberUpdate"
? "Not relevant"
: "Unknown",
)
.replace(
"%templateEmbeds%",
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/images/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export async function tile(origin: ImageSource, options: TileOptions = {}): Prom
* x x x x x x . x . . x . . . .
*/

if (options?.random == "rotation") {
if (options.random == "rotation") {
// grid to get all possible rotation states matched with each other
// specific configuration originally by Pomi108
const angles = [
Expand All @@ -87,7 +87,7 @@ export async function tile(origin: ImageSource, options: TileOptions = {}): Prom
else {
for (let x = 0; x < 3; ++x) {
for (let y = 0; y < 3; ++y) {
if (options?.random == "flip" && Math.random() < 0.5)
if (options.random == "flip" && Math.random() < 0.5)
drawMirroredImage(x * input.width, y * input.height);
else ctx.drawImage(input, x * input.width, y * input.height);
}
Expand Down Expand Up @@ -160,6 +160,6 @@ export async function tileToAttachment(
const buf = await tile(origin, options);
// image too big so we returned early
if (!buf) return null;
if (options.magnify) return await magnifyToAttachment(buf);
if (options?.magnify) return await magnifyToAttachment(buf);
return new AttachmentBuilder(buf, { name });
}

0 comments on commit 8157951

Please sign in to comment.