I'm having issues sending multiple embeds in one response and I'm not entirely sure if it's my fault (mostly likely) or a bug with discord.py.
I have a list of embeds I'm trying to follow up on an initial deferral. However, my bot only seems to ever send one embed, rather than sending the full list. The full code is here but the important bits I'll describe below:
My bot asks the discord API to defer it's response in order to conduct the multitude of REST API requests, searching and parsing it has to do. This theoretically buys me 15 minutes to respond to the user's request properly
# Send directory contents if no search term given
await interaction.response.defer(thinking=True)
It then does a bunch of parsing and ends up with a dictionary of some discord.File's and embeds. The embeds are created using the basic discord.Embed format to the responses variable:
{'files': [], 'embeds': [<discord.embeds.Embed object at 0x106f3b0a0>, <discord.embeds.Embed object at 0x106f3aef0>, <discord.embeds.Embed object at 0x106f3b250>]}
I then try to send this dictionary in a reply but it only ever seems to send one embed:
print(f"SENDING RESPONSES: {responses}...")
await interaction.followup.send(embeds=responses["embeds"], files=responses["files"])
See image for the singular response in the Discord UI
Can someone please clarify for me what I should be doing or if this is a genuine bug or documentation issue in discord.py?
Thanks
Now resolved thanks to the owner of discord.py
Related
What I'm trying to understand is how Discord.py creates and sends responses from their on_message function.
Take this as an example:
#client.event()
async def on_message(message):
print(message.content)
I'm trying to understand how Discord.py retrieves new messages from Discord without refreshing the channel histories for every single channel in every single server to scan for new messages which would surely hit Discord's rate limit.
Is there a way to scan for new messages with Discord's API using fetch or post requests? I am not trying get a solution on how to scan new messages using an already made library. I want to achieve this using only the requests module in python.
I'm trying to understand how Discord.py retrieves new messages from Discord without refreshing the channel histories for every single channel in every single server to scan for new messages which would surely hit Discord's rate limit.
Discord bots establish a websocket connection with Discord's servers, which is essentially a (secure) two-way tunnel. This means that once the connection is up, Discord can send events to you. Instead of you having to manually fetch every single channel, Discord tells you "Hey, a message was created", and the payload attached will give all the additional info about it.
The Discord (not discord.py) docs have detailed info about how everything works behind the scenes, to help the people creating the Bot libraries for you. For example, this section details which types of events Discord can send to you. To see how something is constructed, click on one of the event types and read up on the data that Discord provides.
Is there a way to scan for new messages with Discord's API using fetch or post requests? I am not trying get a solution on how to scan new messages using an already made library. I want to achieve this using only the requests module in python.
Not really, unless you do in fact send a GET for every single channel, which will get you ratelimited. There's really no reason to ever use only GET/POST requests (other than Webhooks, where you just send a POST with your info to send a message to a channel without a bot).
If you'd like to read up on Discord's API, the docs I linked contain a full spec of everything, so you could try to do whatever your heart desires (... and the API supports).
My goal is to make a Telegram Bot using Python that does the following:
The user types a command
The bot explains what the user should type next.
The user types certain information
I use that info to fetch a value in a python dictionary.
The bot replies with that info
I have already created the bot and set the command. The problem is that I don't know how to keep the bot "listening" . I have looked up in the docs but I have only found getUpdates, which gets the user's responses but only when you hit run.
res=requests.get(url=f"https://api.telegram.org/bot{bot_token}/getUpdates")
I would like to set a webhook, and I know there is a method for this but I'm not shure about how this works.
When you are a PHP programmer, setting the webhook through a URL and using setWebhook would do the trick and telegram will send the result to this link whenever a user sends an update to the bot. But, Python programmers have to use a different approach, I think. The main, and while, the easiest approach to make the bot listen permanently to the request is to python-telegram-bot module.
There are a few links that can help to build your first pythonic bot that can respond to users' updates.:
Python-Telegram-Bot Repository, which is the repository of the module.
A few examples of bots created using this module, can give you insight into the process of creating your first bot.
A conversation bot
I have 2 discord client instances a bot and a user account. I have already figured out how to copy messages from one channel to another channel, basically a on_message event. However, I want to know if there is a way I can use the user account to fetch the messages, I've tried fetching messages in different guilds but they didn't work because the bot was not in the server and the bot is fetching messages. I've tried using the user account instance to do it but it didn't really work.
The comments were there as a guide for myself because I'm not that familiar with Python it's fairly new to me. If anyone knows how I can use the user account to get or fetch the messages I'd appreciate the help...
PS: I know that some of the code isn't needed, I haven't removed anything that isn't needed. I wanted to actually finish the project before inspecting it.
I just wanted to know that I have tried this myself and it is not possible. Because from discord.py's Docs. Which you can find down below, does not allow users (user account) to transfer data to a bot since you would need to request from discord API which leads to user getting banned (Very quickly) theere are some work arrounds but I would suggest not doing so since self botting is against the TOS of discord
https://discordpy.readthedocs.io/en/stable/
EDIT: Another thing is that discord API blocks users from fetching or getting anything using a user account with discord.py
I'm creating a Reddit bot with praw, and I want to have the bot do things based on private messages sent to it. I searched the documentation for a bit, but couldn't find anything on reading private messages, only sending them. I want to get both the title and the content of the message. So how can I do this?
Didn't find it in the docs, but a friend who knows a bit of raw helped me out.
Use for message in r.inbox.messages() (where r is an instance of reddit) to get the messages.
Use message.text to get the content, and message.subject to get the title.
I built a Slack bot and tried to make my bot interact with another bot in the a channel, but it seems not working.
For example, I want to use the voting function of Polly (a Slack bot).
Regular users like me send /polly "Which is better?" "Tacos" "Pizza" message and Polly will create a Slack poll in a channel. But when I made my bot send the same message in the same channel (I use python-slackclient and chat.postMessage method), the message just like a simple text, in other words, it didn't trigger Polly.
So, in a channel, how can a Slack bot interact with another bot and trigger some functions of it?
Did anybody ever do something like this?
update
https://github.com/ErikKalkoken/slackApiDoc/blob/master/chat.command.md
I tried this method but got another problem...
The error message is
{'error': 'missing_scope',
'needed': 'post',
'ok': False,
'provided': 'identify,bot:basic'}
The Oauth token requires "post" scope, but official documents show that "post" scope is deprecated. How do I make my token have "post" scope?
I have tried to make two bots interact and didn't find it to work. Slack somehow recognizes the source of the message and if the message is sent by a bot or an app, it fails to respond to it. I have even tried to post the message as a user through the slack API but did not get it to work.
However, Bots can use the chat.command method to invoke a slash command.
Unofficial documentation can be found here:
https://github.com/ErikKalkoken/slackApiDoc/blob/master/chat.command.md
You are correct that the undocumented chat.command requires the post scope to work, which is not available in the standard OAuth process (e.g. you can not choose it as scope on the Slack app config site.)
The only currently working solution that I know of it to use a legacy token.
See also this answer.