fix: twitter just crashing oh my god i hate it

This commit is contained in:
2022-12-12 16:47:48 +01:00
parent 18b3a291e2
commit eba657a24d

View File

@@ -3,29 +3,31 @@ import axios from 'axios';
import schema from '../schemas/twitter.js';
export default async function twitternotifications(client: Client) {
const db = await schema.findOne({ user: 'elpady' });
const request = (
await axios
.get(
'https://api.twitter.com/2/tweets/search/recent?query=from%3AMaraTuring',
{
headers: {
Authorization: `Bearer ${process.env.TWITTER}`,
},
}
)
.then((res) => res.data)
).data[0].id;
const fetchTextChannel = (await (
await client.guilds.fetch(process.env.GUILDID!)
).channels.fetch(process.env.SOCIALS_CHANNEL!)) as TextChannel;
if (request === db?.id) return;
else {
db!.id = request;
await db?.save();
const message = await fetchTextChannel.send({
content: `Nuevo tweet de Mara Turing, corre a verlo! https://twitter.com/MaraTuring/status/${request}`,
});
message.react('<:Pog:1030169609178976346>');
}
try {
const db = await schema.findOne({ user: 'elpady' });
const request = (
await axios
.get(
'https://api.twitter.com/2/tweets/search/recent?query=from%3AMaraTuring',
{
headers: {
Authorization: `Bearer ${process.env.TWITTER}`,
},
}
)
.then((res) => res.data)
).data[0].id;
const fetchTextChannel = (await (
await client.guilds.fetch(process.env.GUILDID!)
).channels.fetch(process.env.SOCIALS_CHANNEL!)) as TextChannel;
if (request === db?.id) return;
else {
db!.id = request;
await db?.save();
const message = await fetchTextChannel.send({
content: `Nuevo tweet de Mara Turing, corre a verlo! https://twitter.com/MaraTuring/status/${request}`,
});
message.react('<:Pog:1030169609178976346>');
}
} catch (err) {}
}