Skip to content

Commit

Permalink
bweh
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed May 2, 2024
1 parent 7fc2702 commit 6d52dbc
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions src/handlers/log.handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import {
ActionRow, ActionRowBuilder,
ActionRow,

Check failure on line 2 in src/handlers/log.handler.ts

View workflow job for this annotation

GitHub Actions / lint

'ActionRow' is defined but never used
ActionRowBuilder,
ActionRowData,

Check failure on line 4 in src/handlers/log.handler.ts

View workflow job for this annotation

GitHub Actions / lint

'ActionRowData' is defined but never used
ButtonBuilder,
ButtonStyle,
EmbedBuilder,
Events,
inlineCode,
MessageActionRowComponentData, MessagePayload, MessageReplyOptions,
MessageActionRowComponentData,

Check failure on line 10 in src/handlers/log.handler.ts

View workflow job for this annotation

GitHub Actions / lint

'MessageActionRowComponentData' is defined but never used
MessagePayload,
MessageReplyOptions,
} from 'discord.js';

// log providers
Expand Down Expand Up @@ -171,27 +174,27 @@ export const logHandler: Handler = (client) => {
});

let responseData = {
"success": false,
"id": "error",
"url": "https://mclo.gs/error",
"raw": "https://api.mclo.gs/1/raw/error"
success: false,
id: 'error',
url: 'https://mclo.gs/error',
raw: 'https://api.mclo.gs/1/raw/error',
};

let actionRowData
let actionRowData;

if (attachment) {
const formData: FormData = new FormData();
formData.append("content", log)
formData.append('content', log);
const data: RequestInit = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: formData
}
await fetch("https://api.mclo.gs/1/log", data)
.then(res => res.json())
.then(data => responseData = data);
body: formData,
};
await fetch('https://api.mclo.gs/1/log', data)
.then((res) => res.json())
.then((data) => (responseData = data));

if (responseData.success) {
const logLink = new ButtonBuilder()
Expand All @@ -201,8 +204,11 @@ export const logHandler: Handler = (client) => {
.setURL(responseData.raw)
.setStyle(ButtonStyle.Link);

actionRowData = new ActionRowBuilder<ButtonBuilder>()
.addComponents(logLink, rawLogLink)
actionRowData =
new ActionRowBuilder<ButtonBuilder>().addComponents(
logLink,
rawLogLink
);
}
}

Expand All @@ -215,11 +221,11 @@ export const logHandler: Handler = (client) => {
const issues = await findIssues(parsedLog);

const messageData: MessagePayload | MessageReplyOptions = {
embeds: [logInfoEmbed]
}
embeds: [logInfoEmbed],
};

if (responseData.success) {
messageData.components?.push(actionRowData!)
messageData.components?.push(actionRowData!);
}

if (!issues.length) {
Expand All @@ -237,7 +243,7 @@ export const logHandler: Handler = (client) => {
.setFields(...issues)
.setColor('Red');

messageData.embeds?.push(issuesEmbed)
messageData.embeds?.push(issuesEmbed);
await message.reply(messageData);
return;
} catch (error) {
Expand Down

0 comments on commit 6d52dbc

Please sign in to comment.