Toggle navigation
Toggle navigation
This project
Loading...
Sign in
유병우
/
lostark-discord-bot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
남우성
2022-06-06 23:31:06 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1430da0b8fb7d35db6a000b544bde3654f4e4942
1430da0b
1 parent
57546a9d
Create guide command
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
commands/guide.js
commands/guide.js
View file @
1430da0
...
...
@@ -4,5 +4,52 @@ 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
){
const
rade_name
=
interaction
.
options
.
getString
(
'레이드'
);
const
getHtml
=
async
()
=>
{
try
{
return
await
axios
.
get
(
"https://lostark.inven.co.kr/"
)
}
catch
(
error
){
console
.
error
(
error
);
}
}
await
getHtml
()
.
then
(
html
=>
{
const
$
=
cheerio
.
load
(
html
.
data
);
const
$radeList
=
$
(
"div.menu_item01 div.item_body ul.list"
).
children
(
"li.row"
);
let
rade_info
=
[];
let
rade_url
=
[];
$radeList
.
each
(
function
(
i
,
elem
){
if
(
$
(
this
).
text
().
indexOf
(
rade_name
)
!=
-
1
){
rade_info
.
push
(
$
(
this
).
text
());
rade_url
.
push
(
$
(
this
).
find
(
'a'
).
attr
(
'href'
));
}
})
let
rade_print
=
""
;
for
(
var
i
=
0
;
i
<
rade_info
.
length
;
i
++
){
rade_print
+=
`[
${
rade_info
[
i
]}
](
${
rade_url
[
i
]}
)\n`
;
}
const
guideembed
=
new
MessageEmbed
()
.
setColor
(
'#6FF3E0'
)
.
setTitle
(
"공략 정보"
)
.
setDescription
(
rade_print
)
interaction
.
reply
({
embeds
:
[
guideembed
],
allowedMentions
:
{
repliedUser
:
false
}
});
})
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment