-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from felipecornejo1/formatting-n-cleanup
Formatting con prettier y eliminación de comments
- Loading branch information
Showing
4 changed files
with
246 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": true, | ||
"jsxSingleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.