loawa.js
1.13 KB
const { SlashCommandBuilder } = require('@discordjs/builders');
const open = require('open');
const axios = require("axios");
const cheerio = require("cheerio");
module.exports = {
data: new SlashCommandBuilder()
.setName('로아와')
.setDescription('캐릭터의 로아와 정보를 브라우저로 엽니다.')
.addStringOption((option)=>
option
.setName("닉네임")
.setDescription("캐릭터의 닉네임")
.setRequired(true)
),
async execute(interaction) {
async function getHTML() {
try {
return await axios.get(encodeURI(`https://lostark.game.onstove.com/Profile/Character/${interaction.options.getString("닉네임")}`));
} catch (error) {
console.error(error);
}
};
await getHTML().then(html=>{
const $ = cheerio.load(html.data);
open(`https://loawa.com/char/${interaction.options.getString("닉네임")}`);
interaction.reply({content: `${interaction.options.getString("닉네임")}의 로아와 정보로 이동합니다.`, allowedMentions: {repliedUser: false}});
});
},
};