pip install omegle-node
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 |
const Discord = require('discord.js'); const client = new Discord.Client( { disableEveryone : true }); const config = require('./config.json') const prefix = config.prefix const token = config.token const fs = require('fs'); client.commands = new Discord.Collection(); client.categories = fs.readdirSync("./commands/") const commandFiles = fs.readdirSync(`./commands/`).filter(file => file.endsWith('.js')).map(cmd=>{ let pull = require(`./commands/${cmd}`) client.commands.set(pull.name,pull) console.log("\x1b[32m%s\x1b[0m", `| ${pull.name} | √ |`) }); client.once('ready', () =>{ console.log(`${client.user.tag} is now Online!`); }); client.on('message', message => { if(message.author.bot) return; if(!message.content.toLowerCase().startsWith(prefix)) return; const args = message.content.slice(prefix.length).trim().split(/ +/g); const commandName = args.shift().toLowerCase(); if(!client.commands.has(commandName)) return; const command = client.commands.get(commandName); if(!command) return; try { command.run(client, message, args) } catch(error){ console.log(error) message.reply("There was an issue running that command"); } }); client.login(token) |
commands/connect.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 |
const Omegle = require('omegle-node'); const Disc = require('discord.js') const OClient = new Omegle(); module.exports = { name: "connect", run: async (client, message, args) => { let Params = args.join(" ").split(" "); let CachedMessages = []; let ConEmbed = new Disc.MessageEmbed(); ConEmbed.setTitle("Connection Established"); ConEmbed.setDescription(`Connection To Omegle Established.`); ConEmbed.setColor("GREEN"); let UFoundEmbed = new Disc.MessageEmbed(); UFoundEmbed.setTitle("User Found"); UFoundEmbed.setDescription(`Now Speaking To Stranger.`); UFoundEmbed.setColor("GREEN"); let FSesEmbed = new Disc.MessageEmbed(); FSesEmbed.setTitle("Finding New Session"); FSesEmbed.setDescription(`Attempting To Find Another Session.`); FSesEmbed.setColor("ORANGE"); let UDiscEmbed = new Disc.MessageEmbed(); UDiscEmbed.setTitle("Stranger Disconnected"); UDiscEmbed.setColor("RED"); UDiscEmbed.setTimestamp() let MDiscEmbed = new Disc.MessageEmbed(); MDiscEmbed.setTitle("Disconnected"); MDiscEmbed.setDescription(`Do You Wish To Find Another Session?`); MDiscEmbed.setColor("RED"); MDiscEmbed.setFooter("Send Yes To Find Another Session Or No To Cancel") let CEmbed = new Disc.MessageEmbed(); CEmbed.setTitle("Talking To Stranger"); let SMSG = await message.channel.send("Connecting..."); Params[0] != null ? OClient.connect(Params[0]) : OClient.connect(); const MCollect = new Disc.MessageCollector(message.channel, (m => m.author.id === message.author.id)); OClient.on('gotID', async function(id) { SMSG.edit(ConEmbed); console.log(id) }); OClient.on('omerror', function(err) { console.error(err); }); OClient.on('strangerDisconnected', () => { OClient.disconnect(); SMSG.delete(); MCollect.stop(); message.channel.send(UDiscEmbed) message.guild.channels.cache.find(r => r.name === "cached-messages-for-omegle").send(`${message.author.tag} Omegle Chat:\n` + ````` + CachedMessages.join("\n") + `````); CachedMessages = []; delete require.cache[require.resolve(`./connect.js`)]; try { const newCommand = require(`./connect.js`); message.client.commands.set(newCommand.name, newCommand); } catch (error) { console.error(error); } }); OClient.on('gotMessage', function(msg) { let date = new Date(); CachedMessages.push(`Stranger Said: ${msg} | ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`); if (CachedMessages.length > 20) CachedMessages.shift() CEmbed.setDescription(````${CachedMessages.join("\n")}````); SMSG.edit(CEmbed); OClient.startTyping(); }); OClient.on('connected', async function() { SMSG.edit(UFoundEmbed); MCollect.on('collect', m => { if (m.content.toLowerCase() === "disconnect" && OClient.connected) { SMSG.delete(); message.guild.channels.cache.find(r => r.name === "cached-messages-for-omegle").send(`${message.author.tag} Omegle Chat:\n` + ````` + CachedMessages.join("\n") + `````); OClient.disconnect(); MCollect.stop(); CachedMessages = []; delete require.cache[require.resolve(`./connect.js`)]; try { const newCommand = require(`./connect.js`); message.client.commands.set(newCommand.name, newCommand); } catch (error) { console.error(error); } return; } let date = new Date(); OClient.send(m.content) CachedMessages.push(`You Said: ${m.content} | ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`); if (CachedMessages.length > 20) CachedMessages.shift() CEmbed.setDescription(````${CachedMessages.join("\n")}````); SMSG.edit(CEmbed); return; }) }); } } |