Skip to content

Commit

Permalink
Add fixes for Loggy - we upload to s3 now
Browse files Browse the repository at this point in the history
  • Loading branch information
reiichi001 committed Feb 11, 2024
1 parent 24a3f3b commit 4ef92a6
Show file tree
Hide file tree
Showing 3 changed files with 2,834 additions and 161 deletions.
31 changes: 27 additions & 4 deletions events/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const {
checkTheMessage,

Check warning on line 16 in events/messageCreate.js

View workflow job for this annotation

GitHub Actions / eslint

'checkTheMessage' is assigned a value but never used
} = require("../modules/checkTheMessage");

const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3");

// The MESSAGE event runs anytime a message is received
// Note that due to the binding of client to every event, every event
// goes `client, other, args` when this function is run.
Expand Down Expand Up @@ -275,10 +277,31 @@ module.exports = async (client, message) => {
});


// set up proxied url for loggy
// console.log(relayedMessage.attachments.first().proxyURL);
// console.log(relayedMessage.attachments.first().url);
const url = `https://wiki.ffxivrp.org/${relayedMessage.channelId}/${relayedMessage.attachments.first().id}/${relayedMessage.attachments.first().name}`;
// We upload these to S3 because Discord killed Franz's proxy
const response = await fetch(attachment.attachment);
const buffer = Buffer.from(await response.arrayBuffer());
const bucketName = "dalamudlogsbucket-franz";

Check failure on line 283 in events/messageCreate.js

View workflow job for this annotation

GitHub Actions / eslint

'fetch' is not defined
const keyName = `${message.guild?.id ?? "directmessage"}/tspack/${message.author.id}-${attachment.name}`

const s3Client = new S3Client({
region: client.config.AWS_REGION,
credentials: {
accessKeyId: client.config.AWS_KEY,
secretAccessKey: client.config.AWS_KEYSECRET,
}
});

await s3Client.send(
new PutObjectCommand({
Bucket: bucketName,
Key: keyName,
Body: buffer,
})
);


const url = `https://dalamudlogsbucket-franz.s3.us-east-2.amazonaws.com/${keyName}`;

// console.log(url);
const base64url = new Buffer.from(url).toString('base64');
const safebase64url = URLSafeBase64.encode(new Buffer.from(url));
Expand Down
Loading

0 comments on commit 4ef92a6

Please sign in to comment.