function to receive interaction
This commit is contained in:
12
src/api.ts
12
src/api.ts
@@ -1,4 +1,5 @@
|
||||
import * as cheerio from 'cheerio';
|
||||
import { CommandInteraction } from 'discord.js';
|
||||
import { IncomingMessage } from 'http';
|
||||
import http from 'https';
|
||||
|
||||
@@ -148,4 +149,15 @@ export async function getPlayer(name: string): Promise<uniteApiData|null> {
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function getPlayerInteraction(interaction: CommandInteraction): Promise<void> {
|
||||
let username = interaction.options.getString('username', true);
|
||||
interaction.deferReply();
|
||||
|
||||
let data = await getPlayer(username);
|
||||
if (data === null)
|
||||
await interaction.reply('Unable to find user');
|
||||
else
|
||||
await interaction.reply('```\n'+JSON.stringify(data, null, 2)+'\n```');
|
||||
}
|
||||
|
||||
//await getPlayer('IanWhysp')
|
||||
Reference in New Issue
Block a user