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 14:16:02 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
537fba1601bacf061f5d043f0e0507b54ca96b06
537fba16
1 parent
1e0708a5
merge translator' into 'master'
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
27 deletions
Commands/Translate/button.js
Commands/Translate/translate.js
index.js
Commands/Translate/button.js
View file @
537fba1
...
...
@@ -10,50 +10,43 @@ var label_var={
ko
:
'한국어'
,
jp
:
'일본어'
,
};
var
current_country
=
'영어'
// 초기값 영어
var
country_var
=
'영어'
// 초기값 영어
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
=
'영어'
;
country_var
=
'영어'
;
}
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
=
'한국어'
;
country_var
=
'한국어'
;
}
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
=
'일본어'
;
country_var
=
'일본어'
;
}
// 변수가 3개밖에 안되니깐, 가시성위해서 / 어느 언어로부터 바뀌었는지 모르기 때문에, 편하게 변수에 일일이 할당함.
// 변수가 100개였다면, 임시 변수 만들고 추적해서 어느 언어에서 바뀌었는지 확인하고, if(임시변수)써서 이모지 할당하고,
// 그전꺼, 바뀌어야 할 국가변수 바꿈(받은 str값 label_var 배열(?) for 문 돌려서 찾음)
}
exports
.
run
=
async
(
client
,
msg
,
args
,
prefix
)
=>
{
const
row
=
new
MessageActionRow
()
.
addComponents
(
new
MessageButton
()
...
...
@@ -61,23 +54,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
]
});
await
msg
.
reply
({
content
:
'번역하고 싶은 언어를 골라주세요. 현재 언어는 '
+
country_var
+
'입니다.'
,
components
:
[
row
]
});
//버튼 출력
client
.
on
(
'interactionCreate'
,
interaction
=>
{
if
(
!
interaction
.
isButton
())
return
;
...
...
@@ -90,11 +79,34 @@ 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'
);
}
msg
.
reply
({
content
:
'변경되었습니다. 현재 언어는 '
+
country_var
+
'입니다.'
});
interaction
.
update
({
components
:
[
new
MessageActionRow
()
.
addComponents
(
new
MessageButton
()
.
setCustomId
(
'korean'
)
.
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
),
)
]
})
});
};
...
...
@@ -102,8 +114,8 @@ exports.run = async (client, msg, args, prefix) => {
exports
.
config
=
{
name
:
'나라'
,
aliases
:
[
'
'
,
' '
,
' '
,
'
'
],
category
:
[
'
t
ranslate'
],
des
:
[
'
채팅 내용에 대한 검색결과를 보여줍
니다.'
],
aliases
:
[
'
모드'
,
'언어변경 '
,
'언어 변경 '
,
'skfk
'
],
category
:
[
'
T
ranslate'
],
des
:
[
'
봇이 띄워주는 버튼을 눌러서 번역할 언어(나라)를 선택합
니다.'
],
use
:
[
'!나라'
]
};
\ No newline at end of file
...
...
Commands/Translate/translate.js
View file @
537fba1
...
...
@@ -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
:
[
'
translate'
,
'qjsdur
'
],
category
:
[
'
T
ranslate'
],
des
:
[
'채팅 내용에 대한 검색결과를 보여줍니다.'
],
use
:
[
'!번역 <채팅>'
]
};
\ No newline at end of file
...
...
index.js
View file @
537fba1
const
{
Client
,
Intents
}
=
require
(
'discord.js'
);
const
Discord
=
require
(
"discord.js"
);
const
{
token
}
=
require
(
'config.json'
);
const
{
token
}
=
require
(
'
./
config.json'
);
const
fs
=
require
(
'fs'
);
const
client
=
new
Client
({
intents
:
[
Intents
.
FLAGS
.
GUILDS
,
Intents
.
FLAGS
.
GUILD_MESSAGES
]
});
...
...
Please
register
or
login
to post a comment