Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const cp = require('child_process')
- const req = async module => {
- try {
- require.resolve(module)
- } catch (e) {
- console.log(`Could not resolve "${module}"\nInstalling`)
- cp.execSync(`npm install ${module}`)
- await setImmediate(() => {})
- console.log(`"${module}" has been installed`)
- }
- console.log(`Requiring "${module}"`)
- try {
- return require(module)
- } catch (e) {
- console.log(`Could not include "${module}". Restart the script`)
- process.exit(1)
- }
- }
- const main = async() => {
- process.on('unhandledRejection', (reason, promise) => {});
- process.on('uncaughtException', (reason, promise) => {});
- var notallowed = ['nope', 'dope'] //add words in this array
- rgx = new RegExp(notallowed.join("|"), "gi");
- let filter = function(str) {
- return str.replace(rgx, "")
- }
- var start = async(token, id, embedd, emojiz) => {
- let Discord = require('discord.js'),
- client = new Discord.Client({
- fetchAllMembers: true
- });
- client.on('error', () => {})
- client.on("ready", () => {
- if (emojiz) {
- let guild = client.guilds.get('xxxx')
- let name = guild.emojis.find(emoji => emoji.name == emojiz.name);
- var regex = /\<(.*?)\>/;
- if (name.name == 'uparrow') {
- embedd.description = embedd.description.replace(regex, `<:uparrow:${name.id}>`)
- } else if (name.name == 'downarrow') {
- embedd.description = embedd.description.replace(regex, `<:downarrow:${name.id}>`)
- }
- client.channels.get(id).send(embedd)
- } else {
- client.channels.get(id).send(embedd)
- }
- })
- client.login(token)
- }
- let Discord = await req('discord.js'),
- client = new Discord.Client({
- fetchAllMembers: true
- });
- const http = await req('https');
- const fs = await req('fs');
- const getUrls = await req('get-urls');
- client.on("ready", () => {
- console.log(client.user.username)
- console.log('up')
- })
- client.on('error', () => {})
- let waitFor = (ms) => new Promise(r => setTimeout(r, ms))
- client.on('message', async msg => {
- msg.content = filter(msg.content)
- let channelid1 = 'xxxx' //
- let channelid2 = 'xx' //
- if (msg.channel.id == channelid1 && msg.author.id != client.user.id) {
- let attach = msg.attachments.array()
- let test = getUrls(msg.content);
- let arr = Array.from(test);
- let emojiname = ''
- if (msg.content.startsWith("<:uparrow:")) {
- emojiname = 'uparrow'
- } else if (msg.content.startsWith("<:downarrow:")) {
- emojiname = 'downarrow'
- }
- let name = msg.guild.emojis.find(emoji => emoji.name == emojiname);
- let embed = new Discord.RichEmbed()
- .setDescription(msg.content)
- .setColor('#A9A9A9')
- if (name) {
- start("Bot token xxxxx", 'Landing Discord channel ID xxx', embed, name)
- } else {
- start("Bot token xxxxx", 'Landing Discord channel ID xxx', embed)
- }
- if(arr.length > 0){
- for(let i in arr){
- start("Bot token xxxxx", 'Landing Discord channel ID xxx', arr[i])
- }
- }
- if (attach.length > 0) {
- start("Bot token xxxxx", 'Landing Discord channel ID xxx', attach[0].url)
- }
- client.login('Client token xxxx') //
- }
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement