davidmckenzie / discord-selfrelay

Relay messages from one Discord server to another via a selfbot and webhook
The Unlicense
3 stars 2 forks source link

cleaning #2

Open bonald opened 5 years ago

bonald commented 5 years ago

1- Some embed contains footer with source channel info. To remove it add this code: if (embed['footer']) delete embed['footer'];

2- Some message contain mentions like @user-role. If user role is not in the destination server, the @deleted-role appears. To remove mention from message add this code:

let messageParse = message.content;
let roles = message.mentions.roles;
let members = message.mentions.members;
if (messageParse.match(Discord.MessageMentions.ROLES_PATTERN) || messageParse.match(Discord.MessageMentions.USERS_PATTERN)) {
                roles.forEach((value) => {
                    messageParse = messageParse.replace(Discord.MessageMentions.ROLES_PATTERN, '');
                });
                members.forEach((value) => {
                    messageParse = messageParse.replace(Discord.MessageMentions.USERS_PATTERN, '');
                });
            }
bonald commented 5 years ago

to remove "undefined" when attachment is posted without a comment, add this code:

               if (attachArray.length > 0) {
               ...
              if (message.content && message.content != '') {
                post_data.content += '\n' + attach.url;
                } else {
                post_data.content = '\n' + attach.url;
                }
davidmckenzie commented 5 years ago

Wanna submit PR? :)

just-rich commented 3 years ago

does this not work anymore? im getting this;

`node:internal/modules/cjs/loader:1170 throw err; ^

SyntaxError: C:\Users*USER*\OneDrive\Desktop\discord-selfrelay-master\auth.json: Unexpected token # in JSON at position 234 at parse () ←[90m at Object.Module._extensions..json (node:internal/modules/cjs/loader:1167:22)←[39m ←[90m at Module.load (node:internal/modules/cjs/loader:981:32)←[39m ←[90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)←[39m ←[90m at Module.require (node:internal/modules/cjs/loader:1005:19)←[39m ←[90m at require (node:internal/modules/cjs/helpers:94:18)←[39m at Object. (C:\Users\Rich\OneDrive\Desktop\discord-selfrelay-master\bot.js:2:12) ←[90m at Module._compile (node:internal/modules/cjs/loader:1101:14)←[39m ←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)←[39m ←[90m at Module.load (node:internal/modules/cjs/loader:981:32)←[39m`

davidmckenzie commented 3 years ago

Consider it abandoned - I don't have the means to test this now and have not touched it in a very long time. That said your error is probably because there's a comment in the json file - json doesn't support comments.