Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박건희
/
emon_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-07 18:25:50 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1e0708a5e35a5fd8c2f508d97782fb199c0874d5
1e0708a5
1 parent
d9ea4f78
Merge branch 'translator' into 'master'
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
18 deletions
Commands/Translate/button.js
Commands/Translate/translate.js
Commands/Translate/button.js
View file @
1e0708a
const
{
MessageActionRow
,
MessageButton
,
Interaction
}
=
require
(
'discord.js'
);
// var trans = require('./translate');
var
disabled_var
=
{
en
:
true
,
ko
:
false
,
jp
:
false
};
var
label_var
=
{
en
:
'😛'
,
// 초기값 영어(disabled), 버튼 선택시 함수가 돌아가는 것이므로 처음엔 X표시
ko
:
'한국어'
,
jp
:
'일본어'
,
};
var
current_country
=
'영어'
// 초기값 영어
function
trans_disabled_var
(
input_str
){
if
(
input_str
==
"en"
){
disabled_var
.
en
=
true
;
disabled_var
.
ko
=
false
;
disabled_var
.
jp
=
false
;
label_var
.
en
=
'😛'
;
label_var
.
ko
=
'한국어'
;
label_var
.
jp
=
'일본어'
;
current_country
=
'영어'
;
}
else
if
(
input_str
==
"ko"
){
disabled_var
.
en
=
false
;
disabled_var
.
ko
=
true
;
disabled_var
.
jp
=
false
;
label_var
.
en
=
'영어'
;
label_var
.
ko
=
'😛'
;
label_var
.
jp
=
'일본어'
;
current_country
=
'한국어'
;
}
else
if
(
input_str
==
"jp"
){
disabled_var
.
en
=
false
;
disabled_var
.
ko
=
false
;
disabled_var
.
jp
=
true
;
label_var
.
en
=
'영어'
;
label_var
.
ko
=
'한국어'
;
label_var
.
jp
=
'😛'
;
current_country
=
'일본어'
;
}
// 변수가 3개밖에 안되니깐, 가시성위해서 / 어느 언어로부터 바뀌었는지 모르기 때문에, 편하게 변수에 일일이 할당함.
// 변수가 100개였다면, 임시 변수 만들고 추적해서 어느 언어에서 바뀌었는지 확인하고, if(임시변수)써서 이모지 할당하고,
// 그전꺼, 바뀌어야 할 국가변수 바꿈(받은 str값 label_var 배열(?) for 문 돌려서 찾음)
}
exports
.
run
=
async
(
client
,
msg
,
args
,
prefix
)
=>
{
...
...
@@ -8,21 +58,24 @@ exports.run = async (client, msg, args, prefix) => {
.
addComponents
(
new
MessageButton
()
.
setCustomId
(
'korean'
)
.
setLabel
(
'한국어'
)
.
setStyle
(
'PRIMARY'
),
.
setLabel
(
label_var
.
ko
)
.
setStyle
(
'PRIMARY'
)
.
setDisabled
(
disabled_var
.
ko
),
new
MessageButton
()
.
setCustomId
(
'japanese'
)
.
setLabel
(
'일본어'
)
.
setStyle
(
'PRIMARY'
),
.
setLabel
(
label_var
.
jp
)
.
setStyle
(
'PRIMARY'
)
.
setDisabled
(
disabled_var
.
jp
),
new
MessageButton
()
.
setCustomId
(
'english'
)
.
setLabel
(
'영어'
)
.
setStyle
(
'PRIMARY'
),
.
setLabel
(
label_var
.
en
)
.
setStyle
(
'PRIMARY'
)
.
setDisabled
(
disabled_var
.
en
),
);
//버튼 생성
await
msg
.
reply
({
content
:
'번역
할 나라를 골라주세요
.'
,
components
:
[
row
]
});
await
msg
.
reply
({
content
:
'번역
하고 싶은 언어를 골라주세요. 현재 언어는 '
+
current_country
+
'입니다
.'
,
components
:
[
row
]
});
//버튼 출력
client
.
on
(
'interactionCreate'
,
interaction
=>
{
...
...
@@ -30,14 +83,17 @@ exports.run = async (client, msg, args, prefix) => {
if
(
interaction
.
customId
===
'korean'
){
global
.
trans_var
=
'ko'
;
trans_disabled_var
(
'ko'
);
}
else
if
(
interaction
.
customId
===
'japanese'
){
global
.
trans_var
=
'jp'
;
trans_disabled_var
(
'jp'
);
}
else
if
(
interaction
.
customId
===
'english'
){
global
.
trans_var
=
'en'
;
trans_disabled_var
(
'en'
);
}
});
...
...
Commands/Translate/translate.js
View file @
1e0708a
...
...
@@ -21,10 +21,7 @@ exports.run = async (client, msg, args, prefix) => {
}
};
<<<<<<<
HEAD
=======
>>>>>>>
d5a6b9b3343c77c3e74f6ccaeaf88b75094c368c
function
en_translate
(
distext
){
return
translatte
(
String
(
distext
),
{
to
:
'en'
})
.
then
(
res
=>
{
...
...
@@ -64,10 +61,4 @@ exports.config = {
category
:
[
'translate'
],
des
:
[
'채팅 내용에 대한 검색결과를 보여줍니다.'
],
use
:
[
'!번역 <채팅>'
]
};
/*고칠 것
1. 상호작용 실패 알림 뜨는거
2. !번역, 영어상태에서 영어 번역하면 에러 떠서 멈춰버림
3. 꾸미기(?)
*/
\ No newline at end of file
};
\ No newline at end of file
...
...
Please
register
or
login
to post a comment