김연수

Merge branch 'revert-2924f704' into 'master'

Revert "Merge branch 'translator' into 'master'"

This reverts merge request !4

See merge request !5
1 -const { MessageActionRow, MessageButton, Interaction } = require('discord.js');
2 -
3 -// var trans = require('./translate');
4 -
5 -exports.run = async (client, msg, args, prefix) => {
6 -
7 - const row = new MessageActionRow()
8 - .addComponents(
9 - new MessageButton()
10 - .setCustomId('korean')
11 - .setLabel('한국어')
12 - .setStyle('PRIMARY'),
13 -
14 - new MessageButton()
15 - .setCustomId('japanese')
16 - .setLabel('일본어')
17 - .setStyle('PRIMARY'),
18 -
19 - new MessageButton()
20 - .setCustomId('english')
21 - .setLabel('영어')
22 - .setStyle('PRIMARY'),
23 - ); //버튼 생성
24 -
25 - await msg.reply({ content: '번역할 나라를 골라주세요.', components: [row] });
26 - //버튼 출력
27 -
28 - client.on('interactionCreate', interaction => {
29 - if (!interaction.isButton()) return;
30 -
31 - if(interaction.customId === 'korean'){
32 - global.trans_var ='ko';
33 - }
34 -
35 - else if(interaction.customId === 'japanese'){
36 - global.trans_var ='jp';
37 - }
38 -
39 - else if(interaction.customId === 'english'){
40 - global.trans_var ='en';
41 - }
42 -
43 - });
44 -};
45 -
46 -
47 -exports.config = {
48 - name: '나라',
49 - aliases: [' ', ' ', ' ', ' '],
50 - category: ['translate'],
51 - des: ['채팅 내용에 대한 검색결과를 보여줍니다.'],
52 - use: ['!나라']
53 -};
...\ No newline at end of file ...\ No newline at end of file
emon_bot @ 73db82ca
1 -Subproject commit 73db82ca09f26d4cdc84d04c9f3228fe1f5e7511
1 -const translatte = require('translatte');
2 -
3 -global.trans_var ='en';
4 -
5 -exports.run = async (client, msg, args, prefix) => {
6 - if (args[0]) { // 명령어 뒤에 입력값이 있을 경우 (ex. !<명령어> <채팅>)
7 - if(trans_var=='en'){
8 - en_translate(args[0]).then(transed_text=> {msg.reply(transed_text)})
9 - }
10 -
11 - else if(trans_var=='jp'){
12 - jp_translate(args[0]).then(transed_text=> {msg.reply(transed_text)})
13 - }
14 -
15 - else if(trans_var=="ko"){
16 - ko_translate(args[0]).then(transed_text=> {msg.reply(transed_text)})
17 - }
18 - }
19 - else {
20 - msg.reply("메세지를 다시 확인해주세요.");
21 - }
22 -};
23 -
24 -
25 -function en_translate(distext){
26 - return translatte(String(distext), {to: 'en'})
27 - .then(res => {
28 - return res.text;
29 - }).catch(err => {
30 - console.error(err);
31 - throw err;
32 - });
33 -}
34 -
35 -function jp_translate(distext){
36 - return translatte(String(distext), {to: 'ja'})
37 - .then(res => {
38 - return res.text;
39 - }).catch(err => {
40 - console.error(err);
41 - throw err;
42 - });
43 -}
44 -
45 -
46 -function ko_translate(distext){
47 - return translatte(String(distext), {to: 'ko'})
48 - .then(res => {
49 - return res.text;
50 - }).catch(err => {
51 - console.error(err);
52 - throw err;
53 - });
54 -}
55 -
56 -
57 -
58 -exports.config = {
59 - name: '번역',
60 - aliases: [' ', ' ', ' ', ' '],
61 - category: ['translate'],
62 - des: ['채팅 내용에 대한 검색결과를 보여줍니다.'],
63 - use: ['!번역 <채팅>']
64 -};
65 -
66 -/*고칠 것
67 -1. 상호작용 실패 알림 뜨는거
68 -2. !번역, 영어상태에서 영어 번역하면 에러 떠서 멈춰버림
69 -3. 꾸미기(?)
70 -*/
...\ No newline at end of file ...\ No newline at end of file