-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot3.js
More file actions
133 lines (104 loc) · 3.67 KB
/
bot3.js
File metadata and controls
133 lines (104 loc) · 3.67 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const { Client, Intents, MessageEmbed, MessageAttachment } = require('discord.js');
const fetch = require('node-fetch');
const token = require("../token.json");
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES
]
});
// 시간을 불러오는 함수
function addZero(num) {
if (num < 10) {
num = "0" + num;
}
return num;
}
// 시간을 불러오는 함수
function getCurrentTime() {
var date = new Date();
var year = date.getFullYear();
var month = addZero(date.getMonth() + 1);
var day = addZero(date.getDate());
var hour = addZero(date.getHours());
var minute = addZero(date.getMinutes());
var second = addZero(date.getSeconds());
var currentTime = year + "년 " + month + "월 " + day + "일 " + hour + "시 " + minute + "분 " + second +"초";
return currentTime;
}
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag} || `+new Date());
client.user.setActivity('- help', { type: 'PLAYING' });
});
client.on('messageCreate', msg => {
if (msg.author.bot) return;
if (msg.content == "- help") {
const embed = new MessageEmbed()
.setTitle("ㅡㅡㅡㅡ help list ㅡㅡㅡㅡ")
.setColor('#FFBF00')
.setDescription("help list")
.addField("1. - ranking", " 현재 랭킹 정보를 보여줍니다.")
.addField("2. - time", " 현재 시간 정보를 보여줍니다.");
msg.channel.send({ embeds: [embed] });
/*
reply = 답신
msg.reply("- ranking");
channel.send = 해당 체널에 메시지
msg.channel.send("- ranking");
*/
}
if (msg.content == "- time") {
const embed = new MessageEmbed()
.setTitle("현재 시간")
.setColor('#FFBF00')
.setDescription(getCurrentTime());
msg.channel.send({ embeds: [embed] });
}
/*
const file = msg.attachments.first()?.url;
if (!file) return console.log('No attached file found');
try {
msg.channel.send('Reading the file! Fetching data...');
// fetch the file from the external URL
const response = await fetch(file);
// if there was an error send a message with the status
if (!response.ok)
return msg.channel.send(
'There was an error with fetching the file:',
response.statusText,
);
// take the response stream and read it to completion
const text = await response.text();
if (text) {
msg.channel.send(`\`\`\`${text}\`\`\``);
}
} catch (error) {
console.log(error);
}
*/
/*
if (msg.content == "- rank") {
const file = msg.attachments.first()?.url;
if (!file) return console.log('No attached file found');
try {
msg.channel.send('Reading the file! Fetching data...');
// fetch the file from the external URL
const response = await fetch(file);
// if there was an error send a message with the status
if (!response.ok)
return msg.channel.send(
'There was an error with fetching the file:',
response.statusText,
);
// take the response stream and read it to completion
const text = await response.text();
if (text) {
msg.channel.send(`\`\`\`${text}\`\`\``);
}
} catch (error) {
console.log(error);
}
}
*/
});
client.login(token.token);