-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
185 lines (148 loc) · 4.7 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
const { Client, GatewayIntentBits, ActivityType, Collection } = require('discord.js');
const fs = require('fs');
const axios = require('axios');
// index.js (CommonJS)
const darkModule = require('./dark.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.MessageContent,
],
});
// Define the commands collection
client.commands = new Collection();
// Load command files from the same directory
const commandFiles = fs.readdirSync('./').filter(file => file.endsWith('.js') || file.endsWith('.mjs'));
for (const file of commandFiles) {
const command = require(`./${file}`);
client.commands.set(command.name, command);
}
const prefix = '/'; // Your bot's prefix
// Import and execute the register function to register slash commands
const registerCommands = require('./register');
registerCommands(client);
client.on('ready', async () => {
console.log(`✅ ${client.user.tag} is online.`);
});
// Handle interactions
client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
// Dynamically import and execute the command based on its name
try {
const command = require(`./${commandName}.js`);
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply('Command not found.');
}
});
let status = [
{
name: 'with my cats :3',
},
{
name: 'as your caretaker',
type: ActivityType.Watching,
},
{
name: 'raining ⛈️ on Spotify',
type: ActivityType.Listening,
url: 'https://open.spotify.com/playlist/5mlDOWPtFIwDfL609woNG4?si=84c9ab4a66e14753',
},
];
client.on('ready', async () => {
console.log(`✅ ${client.user.tag} is online.`);
setInterval(() => {
const random = Math.floor(Math.random() * status.length);
const selectedStatus = status[random];
client.user.setActivity(selectedStatus.name, {
type: selectedStatus.type,
url: selectedStatus.url,
});
}, 10000);
});
client.on('messageCreate', async message => {
if (message.author.bot) return;
// Check if the bot was mentioned in the message
const botMention = message.mentions.users.has(client.user.id);
if (botMention) {
// Handle the bot mention and send a reply here
const replyProbability = 0.1; // Adjust the probability here (e.g., 0.5 for 50% chance of replying)
if (Math.random() < replyProbability) {
const randomResponseIndex = Math.floor(Math.random() * 4); // Generate a random number between 0 and 3
let response;
switch (randomResponseIndex) {
case 0:
response = 'Hello babes!';
break;
case 1:
response = 'Hi, how are you cutiee?';
break;
case 2:
response = 'Hey, love';
break;
default:
response = 'Greetings!';
}
message.reply(response);
}
}
// Check for the !say command
if (message.content.startsWith(`${prefix}say`)) {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
if (commandName === 'say') {
const messageToRepeat = args.join(' ');
message.channel.send(messageToRepeat);
}
}
});
client.login(''); // Replace with your actual bot token
const config = {
api_token: "", // Replace this with your API token.
bot_token: "", // Replace this with your bot token.
};
const smartestchatbot = require("smartestchatbot");
const scb = new smartestchatbot.Client(config.api_token);
client.on("messageCreate", (message) => {
if (message.channel.name == "wine-ai-chatbot") {
// The bot will only look for messages with the channel named "chatbot"
if (message.author.bot) return;
message.content = message.content
.replace(/@(everyone)/gi, "everyone")
.replace(/@(here)/gi, "here");
if (message.content.includes(`@`)) {
return message.reply({
content: "**:x: Please dont mention anyone**",
allowedMentions: { repliedUser: true },
});
}
message.channel.sendTyping();
if (!message.content)
return message.reply({
content: "Please say something.",
allowedMentions: { repliedUser: true },
});
scb
.chat(
{
message: message.content,
name: client.user.username,
master: "Wine.",
user: message.author.id,
},
"en"
)
.then((reply) => {
message.reply({
content: reply,
allowedMentions: { repliedUser: true },
});
});
message.channel.sendTyping();
}
});