update
This commit is contained in:
parent
9a53fceaee
commit
1efec85494
@ -1,3 +0,0 @@
|
|||||||
TOKEN=MTA2MjM4NjI4MjM1MDc3NjQzMA.GxffCt.RWpwcdgSS7zl4aivcXSL3vRL06lcfnmDIx_1Q0
|
|
||||||
TOPIC_HASH=64ae5b405f523f45c7ee68287ff89c281c5d297fe2fce622d51650fad7975178
|
|
||||||
CHANNEL=928115276438978632
|
|
@ -1,45 +0,0 @@
|
|||||||
const Discord = require('discord.js');
|
|
||||||
const Hyperswarm = require('hyperswarm');
|
|
||||||
const b4a = require('b4a');
|
|
||||||
const crypto = require('hypercore-crypto');
|
|
||||||
|
|
||||||
client = new Discord.Client({intents: 32767})
|
|
||||||
const swarm = new Hyperswarm();
|
|
||||||
let channel
|
|
||||||
|
|
||||||
let topic;
|
|
||||||
|
|
||||||
client.on('ready', () => {
|
|
||||||
console.log(`Logged in as ${client.user.tag}!`);
|
|
||||||
})
|
|
||||||
|
|
||||||
topic = b4a.from("64ae5b405f523f45c7ee68287ff89c281c5d297fe2fce622d51650fad7975178", 'hex') // Generate a random topic
|
|
||||||
|
|
||||||
// Join the swarm network with the topic
|
|
||||||
swarm.join(topic, {
|
|
||||||
lookup: true, // Enable peer discovery
|
|
||||||
announce: true // Enable peer announcement
|
|
||||||
});
|
|
||||||
|
|
||||||
swarm.on('connection', (conn, info) => {
|
|
||||||
console.log(`Connected to a peer for topic ${topic.toString('hex')}`);
|
|
||||||
|
|
||||||
conn.on('data', data => {
|
|
||||||
// Send the message from the topic to the Discord channel
|
|
||||||
client.channels.cache.get("818514972610134069").send(b4a.toString(data));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('message', msg => {
|
|
||||||
if (msg.channel.id === '818514972610134069') {
|
|
||||||
// Send the message from the Discord channel to the topic
|
|
||||||
swarm.peers(topic, (err, peers) => {
|
|
||||||
peers.forEach(peer => {
|
|
||||||
const conn = swarm.connection(peer);
|
|
||||||
conn.write(b4a.fromString(msg.content));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
client.login("MTA2MjM4NjI4MjM1MDc3NjQzMA.GxffCt.RWpwcdgSS7zl4aivcXSL3vRL06lcfnmDIx_1Q0");
|
|
Loading…
Reference in New Issue
Block a user