-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
256 lines (246 loc) · 8.31 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
const http = require("http");
http
.createServer(function (req, res) {
res.write("index.js is active.\nPleace check it.");
res.end();
})
.listen(8080);
// Discord bot implements
const {
Client,
GatewayIntentBits,
ButtonBuilder,
ActionRowBuilder,
ButtonStyle,
MessageFlags,
} = require("discord.js");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessages,
],
});
require("dotenv").config();
const prefix = "spu!";
const token = process.env.token;
// botが準備できれば発動され、 上から順に処理される。
client.on("ready", () => {
// コンソールにReady!!と表示
console.log("Ready!!");
// ステータスを設定する
setInterval(() => {
client.user.setActivity({
name: `Planet-bot server support`,
});
}, 10000);
client.channels.cache.get("889486664760721418").send("起動しました!");
// readyイベントここまで
});
// botがメッセージを受信すると発動され、 上から順に処理される。
client.on("messageCreate", async (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(" ");
const command = args.shift().toLowerCase();
if (command === "help") {
message.channel.send({
embeds: [
{
title: "HELP",
description: "ないよう",
color: 0x227fff,
timestamp: new Date(),
thumbnail: {
url: "attachment://logo.png",
},
footer: {
text: "This bot is made by Hoshimikan6490",
icon_url: "attachment://me.png",
},
},
],
files: [
{
attachment: "images/logo.png",
name: "logo.png",
},
{
attachment: "images/me.png",
name: "me.png",
},
],
});
} else if (command === "member_role") {
if (
message.author.id == "728495196303523900" ||
message.author.id == "839803902026579968"
) {
if (message.guild.id === "889474199704436776") {
message.delete();
const member_role = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("join")
.setLabel("参加する")
.setStyle(ButtonStyle.Success)
.setEmoji("📝")
);
message.channel.send({
embeds: [
{
title: "📖利用規約📖",
description:
"①__**すべての人に敬意をもって接しましょう**__。ハラスメントや糾弾、セクシズム(性差別)、レイシズム(人種差別)、ヘイトスピーチは一切認められていません。\n②__**スパム行為や、宣伝行為(サーバーへの招待、広告掲載など)は禁止**__です。他のメンバーへのDM送信による場合も含みます。\n③__**閲覧注意(NSFW)コンテンツやわいせつなコンテンツは禁止**__されています。これには裸体・性行為・ハードな暴力シーンなどを描いた文章・画像・リンク、そのほか見た人を不快にさせる露骨なコンテンツが含まれます。\n④スタッフは、__ユーザーの個人間の問題に一切関与しません__。該当の当事者間での対応をお願いします。\nルール違反行為や、安全を脅かされるように感じる場面を見かけたら、スタッフにご報告ください。",
color: 0x498205,
thumbnail: {
url: "attachment://logo.png",
},
footer: {
text: "↓このボタンをおして、参加しましょう!↓",
icon_url: "attachment://me.png",
},
},
],
files: [
{
attachment: "images/logo.png",
name: "logo.png",
},
{
attachment: "images/me.png",
name: "me.png",
},
],
components: [member_role],
});
} else {
message.channel.send({
embeds: [
{
title: "🚫エラー!!",
description:
"ここはサポートサーバーではありません。恥ずかしいと思うので、スポイラーにしておきましたw",
color: 0xff0000,
},
],
flags: MessageFlags.Ephemeral,
});
}
} else {
message.channel.send({
embeds: [
{
title: "🚫エラー!!",
description:
"権限が不足しています。このコマンドはBOTAdmin限定機能です。",
color: 0xff0000,
},
],
flags: MessageFlags.Ephemeral,
});
}
} else if (command === "role_panel") {
if (
message.author.id == "728495196303523900" ||
message.author.id == "839803902026579968"
) {
if (message.guild.id === "889474199704436776") {
message.delete();
const announce_role = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("role1")
.setLabel("アナウンスロール")
.setStyle(ButtonStyle.Primary)
.setEmoji("📢")
);
message.channel.send({
embeds: [
{
title: "⚒ロール設定⚒",
description:
"<@&951364197600591882>:ちょっとだけ重要なアナウンス時にメンションを受け取れます。\n\n __**※外したい場合は、もう1度ボタンを押してください**__",
color: 0x498205,
thumbnail: {
url: "attachment://logo.png",
},
},
],
files: [
{
attachment: "images/logo.png",
name: "logo.png",
},
],
components: [announce_role],
});
} else {
message.channel.send({
embeds: [
{
title: "🚫エラー!!",
description:
"ここはサポートサーバーではありません。恥ずかしいと思うので、スポイラーにしておきましたw",
color: 0xff0000,
},
],
flags: MessageFlags.Ephemeral,
});
}
} else {
message.channel.send({
embeds: [
{
title: "🚫エラー!!",
description:
"権限が不足しています。このコマンドはBOTAdmin限定機能です。",
color: 0xff0000,
},
],
flags: MessageFlags.Ephemeral,
});
}
}
});
client.on("interactionCreate", async (interaction) => {
if (interaction.customId === "join") {
if (interaction.member.roles.cache.has("889474498699595826")) {
await interaction.reply({
content: "あなたは既に参加済みです",
flags: MessageFlags.Ephemeral,
});
} else {
interaction.member.roles.add("889474498699595826");
await interaction.reply({
content: "参加手続きが完了しました。",
flags: MessageFlags.Ephemeral,
});
await client.channels.cache.get("889756065531564052").send({
embeds: [
{
title: "📥認証ログ",
description: `<@${interaction.user.id}> の参加手続きが完了しました。`,
color: 0x33ff33,
timestamp: new Date(),
},
],
});
return;
}
} else if (interaction.customId === "role1") {
if (interaction.member.roles.cache.has("951364197600591882")) {
interaction.member.roles.remove("951364197600591882");
await interaction.reply({
content: "<@" + interaction.user.id + ">からロールを剝奪しました",
flags: MessageFlags.Ephemeral,
});
} else {
interaction.member.roles.add("951364197600591882");
await interaction.reply({
content: "<@" + interaction.user.id + ">にロールを付与しました",
flags: MessageFlags.Ephemeral,
});
}
return;
}
});
// botログイン
client.login(token);