button.js
1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const { MessageActionRow, MessageButton, Interaction } = require('discord.js');
// var trans = require('./translate');
var disabled_var={
en:true,
ko:false,
jp:false
};
function func_disabled_var(input_str){
if (input_str == "en"){
disabled_var.en=true;
disabled_var.ko=false;
disabled_var.jp=false;
}
else if (input_str == "ko"){
disabled_var.en=false;
disabled_var.ko=true;
disabled_var.jp=false;
}
else if (input_str == "jp"){
disabled_var.en=false;
disabled_var.ko=false;
disabled_var.jp=true;
}
}
exports.run = async (client, msg, args, prefix) => {
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('korean')
.setLabel('한국어')
.setStyle('PRIMARY')
.setDisabled(disabled_var.ko),
new MessageButton()
.setCustomId('japanese')
.setLabel('일본어')
.setStyle('PRIMARY')
.setDisabled(disabled_var.jp),
new MessageButton()
.setCustomId('english')
.setLabel('영어')
.setStyle('PRIMARY')
.setDisabled(disabled_var.en),
); //버튼 생성
await msg.reply({ content: '번역할 나라를 골라주세요.', components: [row] });
//버튼 출력
client.on('interactionCreate', interaction => {
if (!interaction.isButton()) return;
if(interaction.customId === 'korean'){
global.trans_var ='ko';
func_disabled_var('ko');
}
else if(interaction.customId === 'japanese'){
global.trans_var ='jp';
func_disabled_var('jp');
}
else if(interaction.customId === 'english'){
global.trans_var ='en';
func_disabled_var('en');
}
});
};
exports.config = {
name: '나라',
aliases: [' ', ' ', ' ', ' '],
category: ['translate'],
des: ['채팅 내용에 대한 검색결과를 보여줍니다.'],
use: ['!나라']
};