button.js
1.18 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
const { MessageActionRow, MessageButton, Interaction } = require('discord.js');
// var trans = require('./translate');
exports.run = async (client, msg, args, prefix) => {
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('korean')
.setLabel('한국어')
.setStyle('PRIMARY'),
new MessageButton()
.setCustomId('japanese')
.setLabel('일본어')
.setStyle('PRIMARY'),
new MessageButton()
.setCustomId('english')
.setLabel('영어')
.setStyle('PRIMARY'),
); //버튼 생성
await msg.reply({ content: '번역할 나라를 골라주세요.', components: [row] });
//버튼 출력
client.on('interactionCreate', interaction => {
if (!interaction.isButton()) return;
if(interaction.customId === 'korean'){
global.trans_var ='ko';
}
else if(interaction.customId === 'japanese'){
global.trans_var ='jp';
}
else if(interaction.customId === 'english'){
global.trans_var ='en';
}
});
};
exports.config = {
name: '나라',
aliases: [' ', ' ', ' ', ' '],
category: ['translate'],
des: ['채팅 내용에 대한 검색결과를 보여줍니다.'],
use: ['!나라']
};