Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김건우
/
studyChatBot
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
김건우
2021-11-23 19:57:58 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4842f876b485301d7ee82a39ab35d05e6663bbfa
4842f876
1 parent
41a75b85
Add config.json
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
chatBot.js
config.json
chatBot.js
View file @
4842f87
const
{
prefix
,
token
}
=
require
(
'./config.json'
);
const
Discord
=
require
(
"discord.js"
)
const
client
=
new
Discord
.
Client
()
var
fs
=
require
(
'fs'
);
//파일입출력 모듈
...
...
@@ -7,6 +8,7 @@ var now = new Date(); // 현재날짜 및 시간 객체
//로그인 콘솔 출력
client
.
on
(
"ready"
,
()
=>
{
console
.
log
(
`Logged in as
${
client
.
user
.
tag
}
!`
)
...
...
@@ -20,11 +22,20 @@ client.on("message", msg => {
//prefix로 시작하지 않는경우 통과 를 위한 명령어
if
(
!
msg
.
content
.
startsWith
(
prefix
)
||
msg
.
author
.
bot
)
return
;
const
args
=
msg
.
content
.
slice
(
prefix
.
length
).
split
(
" "
);
const
command
=
args
.
shift
().
toLowerCase
();
//prefix로 시작하지 않는경우 통과 를 위한 명령어 end
//테스트 조건문
if
(
msg
.
content
===
"ping"
)
{
if
(
command
===
"ping"
)
{
msg
.
reply
(
"Pong!"
)
}
if
(
msg
.
content
===
"!
현재시간"
)
{
if
(
command
===
"
현재시간"
)
{
msg
.
reply
(
now
.
getHours
()
+
"시 "
+
now
.
getMinutes
()
+
"분"
);
}
// 테스트 조건문 end
...
...
@@ -33,7 +44,7 @@ client.on("message", msg => {
//공부시작 시간 체크
if
(
msg
.
content
===
"!
공부시작"
)
{
if
(
command
===
"
공부시작"
)
{
var
data
=
String
(
now
.
getHours
())
+
"."
+
String
(
now
.
getMinutes
());
console
.
log
(
msg
.
author
.
id
);
...
...
@@ -50,7 +61,7 @@ client.on("message", msg => {
//공부끝 시간 체크
if
(
msg
.
content
===
"!
공부끝"
)
{
if
(
command
===
"
공부끝"
)
{
var
fileName
=
msg
.
author
.
id
+
".txt"
;
try
{
...
...
@@ -109,8 +120,9 @@ client.on("message", msg => {
})
//디스코드 봇 토큰
client
.
login
(
'OTA3OTU2NjY1MTEzMDE4NDA4.YYuuiQ.Rn2yQ9lGPLr_24sky29TWQHLOYA'
);
\ No newline at end of file
client
.
login
(
token
);
\ No newline at end of file
...
...
config.json
0 → 100644
View file @
4842f87
{
"prefix"
:
"~"
,
"token"
:
""
}
\ No newline at end of file
Please
register
or
login
to post a comment