Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting con prettier y eliminación de comments #9

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": true,
"singleQuote": true,
"jsxSingleQuote": true
}
73 changes: 35 additions & 38 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,56 @@
import dotenv from 'dotenv';
dotenv.config();
import pkg, { Interaction, InteractionCollector, InteractionCollectorOptions } from 'discord.js';
import pkg, { Interaction } from 'discord.js';
import { processPostRequest } from './scrapeProfileData';
const { Client, IntentsBitField, AttachmentBuilder } = pkg;

const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
]
})
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
],
});

client.on('ready', (c) => {
console.log(`✅ ${c.user.tag} is online `)
})

// client.on('messageCreate', (message) => {
// console.log(message.content)
// if (message.author.bot) return
// if (message.content === 'Hola' || message.content === 'hola') {
// message.reply('Hola!!')
// }
// })
console.log(`✅ ${c.user.tag} is online `);
});

client.on('interactionCreate', async (interaction: Interaction) => {
if (!interaction.isChatInputCommand()) return;
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}

if (interaction.commandName === 'perfil') {
const url = interaction.options.get('url')?.value as string;
if (interaction.commandName === 'perfil') {
const url = interaction.options.get('url')?.value as string;

await interaction.deferReply();
await interaction.deferReply();

console.log("url enviada por el usuario: ", url)
console.log('url enviada por el usuario: ', url);

const res = await processPostRequest(url);
const res = await processPostRequest(url);

console.log("datos obtenidos: ", res);
console.log('datos obtenidos: ', res);

const resString = JSON.stringify(res, null, 2);
if (resString.length <= 2000) {
await interaction.editReply(resString);
} else {
const buffer = Buffer.from(resString, 'utf-8');
const attachment = new AttachmentBuilder(buffer, { name: 'profile.json' });
await interaction.editReply({ content: 'The response is too large to display here. Please see the file.', files: [attachment] });
}
const resString = JSON.stringify(res, null, 2);
if (resString.length <= 2000) {
await interaction.editReply(resString);
} else {
const buffer = Buffer.from(resString, 'utf-8');
const attachment = new AttachmentBuilder(buffer, {
name: 'profile.json',
});
await interaction.editReply({
content:
'The response is too large to display here. Please see the file.',
files: [attachment],
});
}

}
});

client.login(process.env.TOKEN);

client.login(process.env.TOKEN)
Loading
Loading