Sub commands in discord.py? - discord

I’m writing a simple bot for a discord server, and I’m trying to explore a few different ideas and two of them require some kind of response and sub command based on responses. I want people to be able to poll something without it being done through reacting to a bots post. I’m unsure of how to go about this.
I’ll give one as an example.
Ideally, it could be structured something like this.
[initiate poll command] [poll name]
Then to respond, a user could do something like this:
[poll name] [yes/no]
Or for a pseudo-code example:
!start_poll Lets_do_this
!lets_do_this yes
Then if it meets a certain threshold of yes’s, a sub command would execute.

My idea would be to create a dictionary. Whenever someone starts a poll, you would add two keys to the dictionary: "[name]_yes", and "[name]_no". Each key would have an empty list. I would then use a command such as "!vote [poll] [yes/no]" to simplify the coding, and whenever somebody voted, I would add their discord ID to the corresponding list. It would be a good idea to check if their name is already on a list, however. Then if you wanted, you could take the size of each list to see how many people have voted for each. The dictionary would end up looking something like:
{
'lets_do_this_yes': ['Bob', 'Suzy'],
'lets_do_this_no': ['Dan'],
'lets_do_this_instead_yes': ['Dan','Joe'],
'lets_do_this_instead_no': ['Suzy']
}
Note: I haven't used discord.py, but I have experience with Python and Discord.JS
Hopefully this works for you.
Edit: The result example above would not actually have their Discord name, but rather their Discord ID, as that is unique to them where as their name can be changed.

Related

How do I add multiple endings to a surveyjs survey?

I created a survey using surveyjs's online designer and incorporated it into my web app. I would like to add two endings to the survey though.
If user clicks "no" for questions 2,3 or 4, it shows' the message "sorry ... thank you" instead of the default "thank you for ..." that I have as the current ending under the "completedHtml" section.
I essentially want to add two possible endings for the user tied to the logic rules I've set.
I've tried to just create a new "completedHtml[2]" section think (I'm sure the proper term) but I can't figure out how to redirect the logic from just end survey to end with completedHtml2 page.
You can use survey.completedHtmlOnCondition property.
You can see how it is implemented in our NPS example.
Thank you,
SurveyJS Team

Twilio sample react app trying to pass a room name in the URL and put it into a hidden field?

I know this sounds like a big ask, but I'm assuming someone else has already done this and has a simple answer because it seems like an obvious use case.
Twilio has a sample app available on GitHub for their video service. Unfortunately, I don't know much about react, so I was able to make a couple of little changes, but this one has me stumped.
The code is called: Twilio / twilio-video-app-react
https://github.com/twilio/twilio-video-app-react
When you launch the code to enter a video room, you are presented with a form to enter your name and the name of a video room. I need to remove that room name input field and replace it with a hidden variable that was provided in the URL. In other words:
Get a room name variable that was passed as a query parameter on the URL
Make sure the room name is "safe" (alphanumeric) and then put it into a hidden variable in the form
Remove the visible input field (room name) from the form
That would take me two minutes in PHP, and it's probably really easy in react as well, but I can't figure it out. Hope someone can point me in the right direction.

How to make my discord.js bot show how many servers it is in as it's status

I'd like to have my bot have a status that says how many servers it's in.
For example, in 6753421 guilds. I figure you'd make a separate section of code and add ${} to the status with the name of the function in it.
You need to use client.setActivity() and then use the client.guilds.cache.size value.
For example:
client.setActivity(`serving ${client.guilds.cache.size} servers`);

Is there a way to live copy a channel chat from one server to another?

I am trying to create a spreadsheet for a World of Warcraft community, based on certain posts/events happening where we #tag the involved people. We would then normally go to our excel sheet and enter manually the names of the participants and all the rest of the details.
I have been trying to do it with Zapier, and i managed to fix all my rules/steps, but the moment i #tag anyone, the text sent/parsed is " !185020918530048000> " instead of "Loco-Silvermoon" for example.
Please help, any insight would be most welcome.
Anyone got an idea about that? or any Bot/Platform that would work around that? My thought process took me two solutions. Either get a bot to replicate all the chat happening on that channel to another private channel that only i can see and where tagging is not allowed (no idea if that exists or work). OR, get a Bot with a plaintext option that would just send me the text instead of the tagtext.

Where can I find the simple information of the format for uploading questions?

Situation:
I want to train and simple configure the retrieve and rank service.
I just uploaded some PDFs and now I want to upload some questions.
In the documentation I do not find a simple information how the csv file must be structured and which are the must fields and which are not must files.
Something like: "[YOUR QUESTION (MUST)]",[DOCUMENT ID (MUST)], [RANKING (OPTIONAL)]
The document ID you will find in xyz in section xyz.
Inside the help I can not find such kind of help.
https://www.ibm.com/watson/developercloud/doc/retrieve-rank/training_data.shtml#script
Impact:
There is no chance to get a "real" documentation of the configuration outside the tutorial.
Possible Solution:
Provide additional documenation.
Maybe I was not able to find it and someone can guide me to the right place?
Ok, I found the solution for me, by try and error. Following steps do work for me:
1) You need a plain text file and the ending should be *.txt
2) Inside the file you have to write your questions like this:
What is the best place to be?
Why should I travel to the USA?
-> Don't do it like
"What is the best place to be?"
For me the help was missleading, because saying something about CSV files.
You can take a look also in the comment of #dalelane he is right, and highlight the entry text for the upload of the file.

Resources