Im not able to send a single message from my bot using Discord JS as of v12.
I think before the update (v11) was able just by calling the channel.send('text here') but now I do not how to do it.
In detail: I want to send a message upon the bot connection and not only when someone sends a message; meaning that Im only able to send a message using the client.on('message', msg =>()
You can send messages anytime, as long as the bot is connected and ready.
The only reason why you say you "can't" send messages outside of the message event is because in the message event, you listen for a message event and respond to that message in the same channel.
You want to know how to send a message without a pre-existing message.
Go to the desired channel, right-click it, and click Copy ID. (If Developer Mode isn't on, turn it on in user settings.)
If you are using discord.js v12, use client.channels.cache.get('theChannelID').send('yourmessage'); or if you are using discord.js v11, delete the cache part.
Hope this helps.
If you want to message the same channel of the user's mess, try using message.channel.send(content)
Related
In a Discord server I manage, there is a channel "Tutorials", where people can share tutorials for tools they might find useful.
The "rule" of this channel is that if we have a question about a tutorial, we need to answer inside a thread and not in the channel discussion (to avoid the important message being lost in history).
I updated the description of the channel, but this is not enough, because not everybody read it ;)
So I would like to set a way to make the user sure before they publish their message, for instance, my idea is when they try to send a message to the channel, a hidden message pops up telling "are you sure you want to do this ?" to recall the rule to the user.
Is there such a feature in Discord (or with a bot) ? Until now my researches were unsuccessful.
Is there a way to read the messages on a discord channel using discord.py without running the client? The use case is, I have a lambda function that runs slash commands so that I don't have to have a permanent machine listening. This works fine. I want to make a slash command to read all the messages in the channel and save the attachments in the messages in the channel. All the examples I have seen are to make text bots declaring the commands and end with:
client.run('your-token-here')
Which means it needs to be constantly up. Is this possible?
I am trying to pipe notifications from various online services into a Discord server using Webhooks. The problem is, discord doesn't render the message that is received by a webhook the way I need. It omits some information that I would like to display.
Is it possible to receive the raw JSON information from a webhook when it arrives, then process it and post into a channel?
My thinking was: I can create a new bot, then subscribe to some kind of webhook_message_received event and process it the way I want. Turns out, there's no such event (or I don't know where to look).
There's not much information online, so I would appreciate any advice.
So i want to do a command, where if you enter, it sends a Dino emoji and a "sent by (User)" in a specific channel.
Now i need to know, is it possible to count every message in this channel and put it in the dino message?
Like the first dino ever would get
"dino #1, sent by #User"
I would not recommend using the number of messages in the channel for counting. Instead I would use some kind of data storage (JSON file, SQLite, SQL Database, etc) to store the count on the bot side. Fetching all the messages in a channel is a lot of requests to Discord and in some cases could be considered API abuse on Discord's end.
We are using #RabbitListener just fine to process one message after another and sending generated emails, using JavaMail to some SMTP.
Now there is request to close the connection to SMTP after specific count of messages. I have read something about ChannelAwareMessageListener and manual ack. This way you can acknowledge all batch messages with single ack, but I need to be able to just read some messages and then confirm only those which will be sent successfully to SMTP the others need to be dead-lettered.
Any other ideas how to close SMTP connection after count of messages?
Keep a list to the unack'd delivery tags, then use channel.basicAck(goodTag, false) and basicReject(badTag, false) when you are ready.
You should only do that on the listener thread.