mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
feat: discord bot scanning messages
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
{
|
||||
"discord": {
|
||||
"token": "YOUR-BOT-TOKEN-HERE"
|
||||
}
|
||||
},
|
||||
|
||||
"server": {
|
||||
"port": 3000,
|
||||
"host": "192.168.1.6"
|
||||
},
|
||||
|
||||
"responses": [
|
||||
{
|
||||
"label": "DOWNLOAD",
|
||||
"threshold": 0.85,
|
||||
"text": "you wanted peevanced"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -9,10 +9,10 @@ const helper = new HelperClient(config);
|
||||
|
||||
helper.connect();
|
||||
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
|
||||
|
||||
client.on(Events.MessageCreate, async (msg) => {
|
||||
|
||||
helper.scanText(msg.content, `${msg.channelId}/${msg.id}`);
|
||||
});
|
||||
|
||||
client.on(Events.InteractionCreate, async (interaction) => {
|
||||
@@ -22,7 +22,29 @@ client.on(Events.InteractionCreate, async (interaction) => {
|
||||
// The ReVanced Helper events.
|
||||
|
||||
helper.on('aiResponse', async (aiRes) => {
|
||||
const response = config.responses.find(res => res.label === aiRes.predictions[0].label);
|
||||
if (!response) return;
|
||||
|
||||
if (Number(aiRes.predictions[0].score) >= response.threshold) {
|
||||
const ids = aiRes.id.split('/');
|
||||
let channel = client.channels.cache.get(ids[0]);
|
||||
|
||||
if (!channel) {
|
||||
await client.channels.fetch(ids[0]);
|
||||
channel = client.channels.cache.get(ids[0]);
|
||||
}
|
||||
|
||||
let message = channel.messages.cache.get(ids[1]);
|
||||
|
||||
if (!message) {
|
||||
await channel.messages.fetch(ids[1]);
|
||||
message = channel.messages.cache.get(ids[1]);
|
||||
}
|
||||
|
||||
message.reply(response.text);
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
helper.on('ocrResponse', async (aiRes) => {
|
||||
|
||||
@@ -15,7 +15,7 @@ class HelperClient extends EventEmitter {
|
||||
});
|
||||
|
||||
this.client.on('data', (data) => {
|
||||
const eventData = deserialize(data);
|
||||
const eventData = deserialize(data, { allowObjectSmallerThanBufferSize: true });
|
||||
|
||||
switch (eventData.op) {
|
||||
case 2: {
|
||||
|
||||
@@ -23,7 +23,7 @@ global.ft = ft;
|
||||
|
||||
const server = createServer(async (client) => {
|
||||
client.on('data', async (data) => {
|
||||
const eventData = deserialize(data);
|
||||
const eventData = deserialize(data, { allowObjectSmallerThanBufferSize: true });
|
||||
|
||||
switch(eventData.op) {
|
||||
case 1: {
|
||||
|
||||
Reference in New Issue
Block a user