-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaScript
More file actions
71 lines (63 loc) · 2.61 KB
/
Copy pathJavaScript
File metadata and controls
71 lines (63 loc) · 2.61 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
let Discord;
let Database;
if (typeof window !== "undefined") {
Discord = DiscordJS;
Database = EasyDatabase;
} else {
Discord = require("discord.js");
Database = require("easy-json-database");
}
const delay = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms));
const s4d = {
Discord,
client: null,
tokenInvalid: false,
reply: null,
joiningMember: null,
database: new Database("./db.json"),
checkMessageExists() {
if (!s4d.client) throw new Error('You cannot perform message operations without a Discord.js client')
if (!s4d.client.readyTimestamp) throw new Error('You cannot perform message operations while the bot is not connected to the Discord API')
}
};
s4d.client = new s4d.Discord.Client({
fetchAllMembers: true
});
s4d.client.on('raw', async (packet) => {
if (['MESSAGE_REACTION_ADD', 'MESSAGE_REACTION_REMOVE'].includes(packet.t)) {
const guild = s4d.client.guilds.cache.get(packet.d.guild_id);
if (!guild) return;
const member = guild.members.cache.get(packet.d.user_id) || guild.members.fetch(d.user_id).catch(() => {});
if (!member) return;
const channel = s4d.client.channels.cache.get(packet.d.channel_id);
if (!channel) return;
const message = channel.messages.cache.get(packet.d.message_id) || await channel.messages.fetch(packet.d.message_id).catch(() => {});
if (!message) return;
s4d.client.emit(packet.t, guild, channel, message, member, packet.d.emoji.name);
}
});
var Server_Name, Server_Owner_ID, Server_ID;
s4d.client.login('ODQyMzY1OTMwNzI1OTY1ODU2.YJ0QaA.40jBIQD4IViH5Pr1eYUzbzfQDNs').catch((e) => {
s4d.tokenInvalid = true;
s4d.tokenError = e;
});
s4d.client.on('guildMemberAdd', async (param1) => {
s4d.joiningMember = param1;
s4d.client.channels.cache.get('798412625397809182').send(String('A New Member Joined'));
s4d.joiningMember = null
});
s4d.client.on('ready', async () => {
Server_Name = 'Scratch Community';
Server_Owner_ID = '767078695466696725';
Server_ID = '798412255393611816';
s4d.client.channels.cache.get('798412625397809182').send(String('ScratchBot Is Connected'));
});
s4d.client.on('message', async (s4dmessage) => {
if ((s4dmessage.content) == '!Meow') {
s4dmessage.react('🐱');
} else if ((s4dmessage.content) == '!Credits') {
s4d.client.channels.cache.find((channel) => channel.name === 'scratchbot').send(String('Created By PlanetSat0rn'));
s4d.client.channels.cache.find((channel) => channel.name === 'scratchbot').send(String('Created Using Scratch For Discord'));
}
});
s4d;