노영우

initial

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