Open Jessomadic opened 5 years ago
Ok so I have been able to cut down the amount of post from the whole channel to just one. by removing async function sendMessages(messages, channel, webhook, author) { if (inactive(channel.id)) return; let last; if (messages && messages.size) { const backward = messages.array().reverse(); for (let i = 0; i < backward.length; i++) { if (inactive(channel.id, backward[i].channel.id)) break; await sendMessage(backward[i], channel, webhook, last ? last.author.id : author); last = backward[i]; } } }
The problem is the one it post is the first in the server vs the most recent....
Do you only want to repost the one message before the previous, or do you want to repost every message as new ones come as well? The live option should repost any new messages from one channel to another as long as the bot is online. I never thought of adding an option for just one message, but I just want to make sure this is what you are trying to do
We just need the most recent Message. Would the live option be able to sort itself based on Keywords?
We just need the most recent Message. Would the live option be able to sort itself based on Keywords?
We need it to act like a Librarian if you will. Something to be able to archive posts from one channel and be able to sort it in the right one from more than 20
This is not the final we will be reworking it once we get a sorting ability
While you are at it getting rid of the info dump would work best for us as well
I think I understand now. Sorry about the delay between my comments, it will probably take a while for me to update this bot as I'm working on other stuff at the moment. In the meantime, if you want to get rid of the annoying info dump, then it should go away if you remove these lines. There may also be bots offering this functionality already
I think I understand now. Sorry about the delay between my comments, it will probably take a while for me to update this bot as I'm working on other stuff at the moment. In the meantime, if you want to get rid of the annoying info dump, then it should go away if you remove these lines. There may also be bots offering this functionality already
Oh, it's all good. As a Game Dev I understand you have to do these projects in your free time out of a passion vs a Job. Take the time you need. I will see what I can on making it work myself thus I have Forked your project
Sorry to bother you again, I know this is probably annoying, but could you elaborate on this librarian sort of feature?
It seems that you are looking to fetch the first message before the one in which you type the channel to repost to. It seems strange if the only message you are reposting is already there. It would probably take far less time to manually select and copy the message contents rather than type a painfully long command.
I am also a bit unsure of what you mean by keywords. Initially I thought you meant the bot would sort through messages as they are posted, checking if the contents contain a string, and if so, reposting them in a specific channel. However, when re-reading, I am not sure if this is what you mean. I think you may want it to check the contents of the previous message and then repost it to the appropriate channel instead, with only that one message? This way the channel name would not need to be typed.
Again, sorry to be annoying without adding anything, but this detail will help when I get round to it.
Also, until I add it, I think you could repost only one message by modifying these lines. I think it might repost one message if it was modified to this:
const messages = await from.fetchMessages({ limit: 2 }).catch(async function() {
await to.send("**Can't read messages!**").catch(console.error);
});
const last = messages && messages.last();
if (last) {
await sendMessage(last, to, webhook);
} else {
await to.send("**Repost Complete!**").catch(console.error);
}
This is untested, but hopefully it might work. limit: 2
might not be correct, but I am hoping this will skip the message containing the command.
No! You are being very helpful! I should have been more precise in my explanation. When I said, librarian, I was referring to the part of their job where they have to put items (books, movies, games, etc) Back where they belong. So if we are in the General Chat and someone posts a photo that should go in a NSFW channel with a #NSFW have the bot see that tag and put it in the #NSFW channel. To Archive it if you will. But We don't want it to do it to everything in the channel only the post that has the command that activates the bot (In this case being the #NSFW tag). So stating this you were correct in your initial thought of what I was trying to say! Thank you for taking your time to work on this for us! And don't worry you are not annoying at all. Ps. Here is a video of the changes not working :( https://www.youtube.com/watch?v=FnjXKvnXI1Q&feature=youtu.be Edit 1: If you have any more question please ask them!
I think I understand now - the tags are something like trigger words. Also, I think the change may not be working because in the video, line 305 includes after: "0"
in fetchMessages
. If this is included, Discord.js tries to get the message after message 0, which will be the first one in the channel.
Yes, you are correct in the statement about Trigger words. Let me test this other fix for it. What would be the number I should Type for that 0 then? Or should I remove that factor? Edit 1: Looks like removing the "after:0" made it repost the last thing typed. in this case that being the /repost to command lol. But it also shot back a DeprecationWarning as a result
Removing it completely should retrieve the latest message (if I remember correctly)
const messages = await from.fetchMessages({ limit: 2 }).catch(async function() {
Removing that line makes the script fail to run Edit: never mind. I forgot to remove the ;); that was a few lines down and works now
New error. The bot runs but after using a command it is unable to read the messages
for now it works if just the "after: "0""
part is removed from the
const messages = await from.fetchMessages({ limit: 2, after: "0" }).catch(async function() {
Any update on this?
Sorry, I didn't see this comment until today. Does the bot have view message history permission? This only happens if the bot is unable to read the first message, so by removing after: "0"
, it will be getting the latest message. If it does not error when retrieving the latest message, then it probably does not have permission to read previous messages.
Try changing lines 361-363 to this:
const messages = await from.fetchMessages({ limit: 1, after: "0" }).catch(console.error);
This should give a more descriptive error in the console, which will probably help a lot more.
I have the bot all set up but the issue is that I would like to make it so that it only reposts the previous post
IE: Hi How is everyone doing today /repost to Channel Hello
Then it and only it shows up in "Channel Hello". As it stands right now it just copies the whole channel that it's in and pastes it in another. But we have many channels set up based on what should go where in an Archive kind of fashion and this would be a fantastic time saver for us