-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
67 lines (61 loc) · 2.62 KB
/
index.js
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
require("dotenv").config();
const {Client, GatewayIntentBits, EmbedBuilder} = require("discord.js");
const client = new Client({
intents: Object.values(GatewayIntentBits).reduce((a, b) => a | b)
});
const embed = new EmbedBuilder()
.setColor(0x000000)
client.on("ready", () => {
console.log(`READY\n${client.user.tag}(${client.user.id})`);
});
client.on("messageUpdate", (oldMessage, newMessage) => {
if (oldMessage.author.id === client.user.id && newMessage.embeds[0] === undefined) {
oldMessage.edit({embeds: [oldMessage.embeds[0]]});
}
//TODO メッセージ編集検知機能追加
else {
if (oldMessage.author.avatarURL()) {
embed.setAuthor({name: `${oldMessage.author.username}`, iconURL: `${oldMessage.author.avatarURL()}`});
} else if (oldMessage.author.avatarURL() === null) {
embed.setAuthor({
name: `${oldMessage.author.username}`, iconURL: "https://cdn.discordapp.com/embed/avatars/1.png"
});
} else {
console.log("アバターアイコンで例外が発生しました");
}
}
});
client.on("messageDelete", message => {
embed.setTimestamp(message.createdTimestamp);
if (message.author.avatarURL()) {
embed.setAuthor({name: `${message.author.username}`, iconURL: `${message.author.avatarURL()}`});
} else if (message.author.avatarURL() === null) {
embed.setAuthor({
name: `${message.author.username}`, iconURL: "https://cdn.discordapp.com/embed/avatars/1.png"
});
} else {
console.log("アバターアイコンで例外が発生しました");
}
if (message.author.id === client.user.id) {
message.channel.send({content: "**メッセージが削除されました**", embeds: [message.embeds[0]]});
return;
} else if (message.author.bot) {
return;
}
//TODO 添付ファイルの処理
if (message.content) {
embed.setDescription(`${message.content}`);
if (message.attachments.size) {
embed.setDescription(`${message.content}\n${message.attachments.map(attachment => attachment.url).join("\n")}`);
}
} else if (message.attachments.size) {
embed.setDescription(`${message.attachments.map(attachment => attachment.url).join("\n")}`);
} else {
console.log("送信コンテンツで例外が発生しました");
}
message.channel.send({content: "**メッセージが削除されました**", embeds: [embed]});
});
//TODO スラッシュコマンド類
//TODO スクリーンショット機能
//TODO コンフィグ類
client.login(process.env.TOKEN);