message.edit() takes 1 positional argument but 2 were given - discord.py

I'm migrating a discord bot to the new discord.py api, there's a part of editing messages, and its giving me that error..
output = "new text"
await message.edit(output)
Doc
am I reading the docs wrong? sry not a python literate, just helping a friend

The documentation states that there are multiple fields which can be specified. In your case, you need to have content=output for the message to be edited.
Hope that helps!

Related

Is it possible to assign a slash command or some other shortcutr to auto populate message in Slack?

I am little unsure whether the question suits here or SuperUser, but I have decided to post it here first.
While using Slack, I have encountered multiple situations in which I need to post same content to multiple channel / people. Let me explain with an example;
Hi Bill, please provide your;
First Name :
Last Name :
Age :
Email :
I will be sending (DM) the same question not just to Bill alone, but to others as well. What I can do now is that I can copy this message to notepad, or pin it in slack, and copy paste the content (and modify the name) every time I want to send the message to someone.
I am looking for something like a template, which pops up (if i type some command or press a button) and I can modify the content if necessary. I tried integrating slash commands and Slack app, but then I realized that the approach is wrong.
Is there any way to achieve this?
Useful links
https://slack.com/apps/AJGJWCYPQ-templates?tab=more_info

How do I make my bot mention rather than print <#[userid]>?

I'm trying to make a python discord bot that takes in a mention as an input, which is working, but when it comes to the output, the title doesn't mention the user, but the description in the embed does (screenshot attached). How do I make it mention rather than printing <#[userid]>? Thanks in advance.
You can not mention role/user/channel in embed's title and embed's field name
Use the description or field's value, that's where mentions work

BotComposer, how to iterate through the characters of a string using lg language?

We need to extract a number from a phrase. For example:
"hey, 1234" -> "1234"
"ok, 4567" -> "4567"
"b3456f" -> "3456"
But we don't found how to iterate through a string using only language generator of the Bot Composer.
We try things like:
join(foreach(createArray("ab c"), x, concat(x, '-')), '')
But with no result... is there any prebuild function that converts a simple string on an array of chars, so we can iterate char by char using foreach?
Thanks!
As far as I know, this currently isn't possible as there's no way to iterate over a string or split a string into a new array by character. I've opened a GitHub issue to request it as an enhancement.
For:
"hey, 1234" -> "1234"
"ok, 4567" -> "4567"
You can use split().
Unfortunately, you're out of luck for your "b3456f" -> "3456" example, unless you know it's going to come in that exact format, in which case, you could use substring().
You could maybe look into using a Regex to do this, if you know the formats will be pretty controlled, but another option is to look at the LUIS language understanding services from Microsoft, which are built exactly for understanding different parts of a text message, especially in a bot context. Here's a link to getting started with this, for C# (on the menu just below in this link, is a Node example if that's what you need).
There's also a tag here on Stack Overflow focused just on LUIS, if you run into trouble or need any more help.
Hope that helps
[Update] I re-read your question and I see now it's about BotComposer, not a custom developed bot. As a result, the sample I linked to is not valid, but LUIS certainly is. I haven't used Bot Composer myself, but LUIS is integrated as part of it - see here.

Handling incorrect responses to chatbot questions

I am using Microsoft Bot Framework to develop chatbot and my questions is that how can I handle incorrect responses from a user.
Suppose bot asks for name of user and he or she replies "don't know".
I have seen in boiler plate code of bot framework that it handles minimum length validation, but how can I handle this logical checking.
Thanks in advance.
I am assuming you are using the v4 C# SDK, let me know if this is not correct and I can update my answer for node or v3 for you.
This Sample Does exactly what you are trying to do It has a validator that checks the length of the user's input and reprompts if the length is too short. You can see this in this method
In general name validation is fairly difficult because names can be very diverse and contain special characters like "-", "'", and others. Using a prompt with a custom validator should give you the opportunity to at least add some validation like length and numerical character checking.
An expected answer normally has a known format. If bot is asking a name then the name would not have numbers and special characters.. You can do a quick check if the words returned by user are part of standard english words (there are plenty libraries having this list of words). You can even pass the returned sentence to LUIS and see if you get a known intent, and then you can disqualify the answer.

How to create a character counter bot in api.ai?

I'm an absolute knob when it comes to programming, so I ask of your help.
Essentially I'm trying to use the api.ai interface to create a character counter (in slack) where when a user says something like "hi" the bot will respond with "2".
So far I understand that I'm supposed to use an entity in order to achieve this transformation, and I have tried mapping reference words like "hi" with the synonym "2". However, the entity transformation ends up having the bot spew out exactly what the user initially said (ex. "hi"), instead of my desired outcome ("2").
Am I going about this wrong, or am I supposed to use an already existing entity to in my new entity? I apologize in advance as I literally picked this thing up yesterday, so I don't know much about it.
Any help is appreciated!
You cannot write logic in api.ai, meaning you cannot write a function that takes as input a message and returns the number of characters.
What you would need, I believe, is to integrate the api.ai with an external web service where you can write your business logic.
Have a look at Slack + Webhook Integration Example https://docs.api.ai/docs/slack-webhook-integration-guideline
However, if you just want to count the number of chars in a message, I do not see the need for api.ai.

Resources