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-09 11:36:41 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
32db7b4dea1f25a7a3f5eee2a0d40a6a62d5c609
32db7b4d
1 parent
fd695ffb
Fixed some errors
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
30 deletions
Commands/Translate/button.js
Commands/Translate/translate.js
package-lock.json
package.json
Commands/Translate/button.js
View file @
32db7b4
const
{
MessageActionRow
,
MessageButton
,
Interaction
}
=
require
(
'discord.js'
);
var
disabled_var
=
{
en
:
true
,
ko
:
false
,
...
...
@@ -11,39 +10,32 @@ var label_var={
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개밖에 안되니깐, 가시성위해서 / 어느 언어로부터 바뀌었는지 모르기 때문에, 편하게 변수에 일일이 할당함.
...
...
@@ -51,9 +43,7 @@ function trans_disabled_var(input_str){
// 변수가 100개였다면, 임시 변수 만들고 추적해서 어느 언어에서 바뀌었는지 확인하고, if(임시변수)써서 이모지 할당하고,
// 그전꺼, 바뀌어야 할 국가변수 바꿈(받은 str값 label_var 배열(?) for 문 돌려서 찾음)
}
exports
.
run
=
async
(
client
,
msg
,
args
,
prefix
)
=>
{
const
row
=
new
MessageActionRow
()
.
addComponents
(
new
MessageButton
()
...
...
@@ -61,23 +51,19 @@ exports.run = async (client, msg, args, prefix) => {
.
setLabel
(
label_var
.
ko
)
.
setStyle
(
'PRIMARY'
)
.
setDisabled
(
disabled_var
.
ko
),
new
MessageButton
()
.
setCustomId
(
'japanese'
)
.
setLabel
(
label_var
.
jp
)
.
setStyle
(
'PRIMARY'
)
.
setDisabled
(
disabled_var
.
jp
),
new
MessageButton
()
.
setCustomId
(
'english'
)
.
setLabel
(
label_var
.
en
)
.
setStyle
(
'PRIMARY'
)
.
setDisabled
(
disabled_var
.
en
),
);
//버튼 생성
await
msg
.
reply
({
content
:
'번역하고 싶은 언어를 골라주세요. 현재 언어는 '
+
current_country
+
'입니다.'
,
components
:
[
row
]
});
//버튼 출력
client
.
on
(
'interactionCreate'
,
interaction
=>
{
if
(
!
interaction
.
isButton
())
return
;
...
...
@@ -90,7 +76,6 @@ exports.run = async (client, msg, args, prefix) => {
global
.
trans_var
=
'jp'
;
trans_disabled_var
(
'jp'
);
}
else
if
(
interaction
.
customId
===
'english'
){
global
.
trans_var
=
'en'
;
trans_disabled_var
(
'en'
);
...
...
@@ -102,8 +87,8 @@ exports.run = async (client, msg, args, prefix) => {
exports
.
config
=
{
name
:
'나라'
,
aliases
:
[
' '
,
' '
,
' '
,
' '
],
category
:
[
'
t
ranslate'
],
des
:
[
'
채팅 내용에 대한 검색결과를 보여줍
니다.'
],
aliases
:
[],
category
:
[
'
T
ranslate'
],
des
:
[
'
봇이 띄워주는 버튼을 눌러서 번역할 언어(나라)를 선택합
니다.'
],
use
:
[
'!나라'
]
};
\ No newline at end of file
...
...
Commands/Translate/translate.js
View file @
32db7b4
...
...
@@ -4,16 +4,18 @@ global.trans_var ='en';
exports
.
run
=
async
(
client
,
msg
,
args
,
prefix
)
=>
{
if
(
args
[
0
])
{
// 명령어 뒤에 입력값이 있을 경우 (ex. !<명령어> <채팅>)
const
word
=
args
.
join
(
' '
);
if
(
trans_var
==
'en'
){
en_translate
(
args
[
0
]
).
then
(
transed_text
=>
{
msg
.
reply
(
transed_text
)})
en_translate
(
word
).
then
(
transed_text
=>
{
msg
.
reply
(
transed_text
)})
}
else
if
(
trans_var
==
'jp'
){
jp_translate
(
args
[
0
]
).
then
(
transed_text
=>
{
msg
.
reply
(
transed_text
)})
jp_translate
(
word
).
then
(
transed_text
=>
{
msg
.
reply
(
transed_text
)})
}
else
if
(
trans_var
==
"ko"
){
ko_translate
(
args
[
0
]
).
then
(
transed_text
=>
{
msg
.
reply
(
transed_text
)})
ko_translate
(
word
).
then
(
transed_text
=>
{
msg
.
reply
(
transed_text
)})
}
}
else
{
...
...
@@ -57,8 +59,8 @@ function ko_translate(distext){
exports
.
config
=
{
name
:
'번역'
,
aliases
:
[
' '
,
' '
,
' '
,
' '
],
category
:
[
'
t
ranslate'
],
aliases
:
[],
category
:
[
'
T
ranslate'
],
des
:
[
'채팅 내용에 대한 검색결과를 보여줍니다.'
],
use
:
[
'!번역 <채팅>'
]
};
\ No newline at end of file
...
...
package-lock.json
View file @
32db7b4
This diff is collapsed. Click to expand it.
package.json
View file @
32db7b4
{
"dependencies"
:
{
"config.json"
:
"^0.0.4"
,
"discord.js"
:
"^13.6.0"
,
<<<<<<<
HEAD
=======
"puppeteer"
:
"^14.1.1"
,
"puppeteer-core"
:
"^14.1.1"
,
>>>>>>>
d
5
a
6
b
9
b
3343
c
77
c
3
e
74
f
6
ccaeaf
88
b
75094
c
368
c
"discord.js"
:
"^13.8.0"
,
"puppeteer"
:
"^14.3.0"
,
"tesseract.js"
:
"^2.1.5"
,
"translatte"
:
"^3.0.1"
}
...
...
Please
register
or
login
to post a comment