I have this game where you need to react with the 5 random emojis sent from a list. The problem is that sometimes random.randint() spits out the same emoji twice so its impossible react twice to the same message with the same emoji. Is there a better way of doing multiple random.randints?
async def food_loop():
await client.wait_until_ready()
channel = client.get_channel("523262029440483329")
while not client.is_closed:
foodtime = random.randint(1440, 1880)
food = ['š','š','š','š','š','š','š','š','š','š','š','š','š','š„','š
','š„','š','š„','š„','š½','š¶',
'š„','š','š„','š°','š','š„','š„','š„','š§','š','š','š„','š','š','š','š','š®','šÆ',
'š„','š³','š„','š²','š„','šæ','š±','š','š','š','š','š','š','š ','š¢','š£','š¤','š„','š”',
'š¦','š§','šØ','š©','šŖ','š','š°','š«','š¬','š','š®','š„','ā','šµ','š¶','š¾','š·','šø','š¹','šŗ',
'š„']
food1 = food[random.randint(0,79)]
food2 = food[random.randint(0,79)]
food3 = food[random.randint(0,79)]
food4 = food[random.randint(0,79)]
food5 = food[random.randint(0,79)]
foodmonies = random.randint(350,750)
up = 'order up'
def orderup(m):
return m.content.lower() == up
foodmsg = 'Customer has ordered {}, {}, {}, {}, and {}! Fulfill their order ASAP!'.format(food1, food2, food3, food4, food5)
foodmsgsend = await client.send_message(channel, foodmsg)
foodpay1 = await client.wait_for_reaction(emoji=food1, message=foodmsgsend, timeout=3600,
check=lambda reaction, user: user != client.user)
foodpay2 = await client.wait_for_reaction(emoji=food2, message=foodmsgsend, timeout=3600,
check=lambda reaction, user: user != client.user)
foodpay3 = await client.wait_for_reaction(emoji=food3, message=foodmsgsend, timeout=3600,
check=lambda reaction, user: user != client.user)
foodpay4 = await client.wait_for_reaction(emoji=food4, message=foodmsgsend, timeout=3600,
check=lambda reaction, user: user != client.user)
foodpay5 = await client.wait_for_reaction(emoji=food5, message=foodmsgsend, timeout=3600,
check=lambda reaction, user: user != client.user)
foodguess = await client.wait_for_message(timeout=3600, channel=channel, check=orderup)
if foodpay1 and foodpay2 and foodpay3 and foodpay4 and foodpay5 and foodpay3.user.id in blacklist:
pass
else:
if foodpay1 and foodpay2 and foodpay3 and foodpay4 and foodpay5 and foodguess:
await client.delete_message(foodmsgsend)
await client.send_message(channel, "{} fulfills the order and earns ${}".format(foodpay5.user.mention, foodmonies))
add_dollars(foodpay5.user, foodmonies)
await asyncio.sleep(int(foodtime))
Random numbers can, by definition, be repetitive as any call to randint is independent of the previous one. You can replace the following:
food1 = food[random.randint(0,79)]
food2 = food[random.randint(0,79)]
food3 = food[random.randint(0,79)]
food4 = food[random.randint(0,79)]
food5 = food[random.randint(0,79)]
with this:
food1, food2, food3, food4, food5 = random.sample(food, 5)
From the docs (emphasis mine):
random.sample(population, k)
Return a k length list of unique elements chosen from the population sequence or set.
That being said, it is a better idea to refactor that part and switch to using a list instead of declaring 5 variables (it would've been messier if you needed 50, or 500).
Related
My code runs perfectly but I want my bot to be able to warn members by either id or mention like if i want to warn i can either use id or mention.
Currently i can only warn members by mentioning. IF i use two variables then it will assign the value to wrong variable like if i give it id but the first variable is user_mention variable then it would assign it to that variable.
here is my code
with open('reports.json', encoding='utf-8') as f:
try:
report = json.load(f)
except ValueError:
report = {}
report['users'] = []
#client.command(pass_context = True)
#commands.has_permissions(kick_members=True)
async def warn(ctx,user:discord.User, *reason:str):
# await ctx.send(f"msg sender top role position {ctx.message.author.top_role.position} the other members top role position {user.top_role.position}")
guild = ctx.guild
member = ctx.guild.get_member(user.id)
member_top_role = member.top_role
member_top_role_position = member_top_role.position
requester = ctx.message.author
requester_id = ctx.guild.get_member(requester.id)
requester_top_role = requester_id.top_role
requester_top_role_position = requester_top_role.position
if requester_top_role_position > member_top_role_position:
if not reason:
await client.say("Please provide a reason")
return
reason = ' '.join(reason)
for current_user in report['users']:
if current_user['name'] == user.name:
current_user['reasons'].append(reason)
break
else:
report['users'].append({
'name':user.name,
'reasons': [reason,]
})
with open('reports.json','w+') as f:
json.dump(report,f)
await ctx.send(f"<:classic_check_mark:1055182126103937155> {user.mention} has been warned!")
await user.send(f"<:warning_icon:1055184901919494195> You have been warned from {guild.name}\n\n<:warning_icon:1055184901919494195> Resone: {reason}")
elif requester_top_role_position < member_top_role_position:
await ctx.send(f"<:failed:1055182259054985306> {user.mention} has higher role than you. You can't warn that member!")
#warn.error
async def warn_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send("<:failed:1055182259054985306> You don't have permission to use this command.")
elif isinstance(error, commands.MissingRequiredArgument):
await ctx.send("<:syntax:1055182220140232704> Incorrect argument | --warn <#person> <reason>")
#client.command(pass_context = True)
#commands.has_permissions(kick_members=True)
async def warnings(ctx,user:discord.User):
for current_user in report['users']:
if user.name == current_user['name']:
await ctx.send(f"{user.name} has been reported {len(current_user['reasons'])} times : {','.join(current_user['reasons'])}")
break
else:
await ctx.send(f"{user.name} has never been reported")
you can modify the command functin to take a string as the user, and then use the discord.utils.get function to try to convert the string to a User object.
Try it like this
#client.command(pass_context = True)
#commands.has_permissions(kick_members=True)
async def warn(ctx, user: str, *reason: str):
# Try to convert the user String to a User object
member = discord.utils.get(ctx.guild.members, mention=user)
if not member:
# If the argument is not a mention, try to convert it to a user ID
try:
user_id = int(user)
member = ctx.guild.get_member(user_id)
except ValueError:
pass
if not member:
await ctx.send("Invalid user argument")
return
# Use the `name` attribute of the `Member` object instead of the `str` object
for current_user in report['users']:
if member.name == current_user['name']:
current_user['reasons'].append(reason)
break
else:
report['users'].append({
'name': member.name,
'reasons': [reason,]
})
with open('reports.json', 'w+') as f:
json.dump(report, f)
await ctx.send(f"<:classic_check_mark:1055182126103937155> {member.mention} has been warned!")
await member.send(f"<:warning_icon:1055184901919494195> You have been warned from {guild.name}\n\")
I'm trying to create a reactroles function for my server, I've gone through hundreds of stack overflow and reddit forums to find bits and pieces to make this work but nothing has fixed this last error.
The roles are present on my server and properly defined (as far as i know) in the code but still returns error 10011 Unknown Role
async def on_reaction_add(reaction, user):
ChID = '1018712244843970610'
ctx = await bot.get_context(reaction.message)
#user = ctx.reaction.author
Channel = bot.get_channel(1018712244843970610)
if reaction.message.channel != Channel:
await Channel.send("this is a test for ChID not....")
return
if reaction.emoji == "š":
await ctx.channel.purge(limit=1)
this_member = ctx.message.author
mem = str(this_member.display_name)
await Channel.send(mem+" - this is a test for running....š")
print(this_member)
this_guild = this_member.guild
this_role = discord.utils.get(this_guild.roles, id=1018802229341327370)
await this_member.add_roles(this_member, this_role)
if reaction.emoji == "šØ":
await ctx.channel.purge(limit=1)
this_member = ctx.message.author
mem = str(this_member.display_name)
await Channel.send(mem+" - this is a test for hammer....šØ")
this_guild = this_member.guild
this_role = discord.utils.get(this_guild.roles, id=1018802151679602798)
await this_member.add_roles(this_member, this_role)
if reaction.emoji == "š¦":
await ctx.channel.purge(limit=1)
this_member = ctx.message.author
mem = str(this_member.display_name)
await Channel.send(mem+" - this is a test for duck....š¦")
this_guild = this_member.guild
this_role = discord.utils.get(this_guild.roles, id=1018802188555927572)
await this_member.add_roles(this_member, this_role)
if reaction.emoji == "ā¤ļø":
await ctx.channel.purge(limit=1)
this_member = ctx.message.author
mem = str(this_member.display_name)
await Channel.send(mem+" - this is a test for heart....ā¤ļø")
this_guild = this_member.guild
this_role = discord.utils.get(this_guild.roles, id=1018802188555927572)
await this_member.add_roles(this_member, this_role)
I have tried replacing the ctx in ct.message.author with reaction.message.author but then throws the error 'reaction' has no attribute 'content'
I thought maybe the definition of this_member was the cause of it not being able to define the role but it doesnt seem to be the issue
I used this code, and it works:
#bot.event
async def on_raw_reaction_add(payload):
Channel_id = 1018712244843970610
Channel = bot.get_channel(Channel_id)
data = {"š":["running",1018802229341327370], "šØ":["hammer",1018802229341327370], "š¦":["duck",1018802229341327370], "ā¤":["heart",1018802188555927572]}
if payload.channel_id != Channel_id:
await Channel.send("this is a test for ChID not....")
return
if payload.emoji.name in data:
this_guild = await bot.fetch_guild(payload.guild_id)
all_roles = discord.utils.get(this_guild.roles, name="Bot")
text, role_id = data[payload.emoji.name]
await Channel.purge(limit=1)
this_member = await this_guild.fetch_member(payload.user_id)
mem = str(this_member.display_name)
await Channel.send(mem+" - this is a test for {0}....{1}".format(text, payload.emoji))
print(this_member)
this_role = discord.utils.get(this_guild.roles, id=role_id)
await this_member.add_roles(this_member, this_role)
Raw_reaction_add is for messages older than the start of the bot.
If this does not work, check the Ids of the role.
So I am having a problem. I am making a game where it eliminates you every 5 seconds by taking away your role. When it eliminates you it will DM you. But I am having trouble as some people have DMs off and when the bot tries to DM them it stops the whole process even with the except Exception block, I have tried everything. Is there anything I did wrong here?
from discord.ext import commands
import discord
import time
import datetime
import random
from setup import ROLEID
import asyncio
class Game(commands.Cog):
def __init__(self, client):
self.client = client
async def guessthenumber(self, ctx, channel):
embed = discord.Embed(title='Minigame!',description='Play this game to win immunity!\nI am thinking of a number, 1-20, first to guess it wins immunity for a round!')
await channel.send(embed=embed)
randnum = random.randint(1,20)
openstatus = 'yes'
await channel.send(randnum)
while openstatus == 'yes':
def check(m):
return ctx.author == m.author
msg = await self.client.wait_for('message', timeout=60.0, check=check)
if msg.content == str(randnum) and openstatus == 'yes':
embed=discord.Embed(title="Number has been guessed!",description=f'{msg.author.mention} has guessed the number!')
await channel.send(embed=embed)
openstatus = 'no'
immunes = []
immunes.append(msg.author)
async def choosekick(self, ctx, channel,list_of_players, role):
the_choices = []
listy = list_of_players
choice1 = random.choice(listy)
listy.remove(choice1)
choice2 = random.choice(listy)
the_choices.append(choice1)
the_choices.append(choice2)
embed = discord.Embed(title='Vote Save!',description = f'Choose one of the following people to save!\n{the_choices[0].mention} or {the_choices[1].mention}')
msg = await channel.send(embed=embed)
await msg.add_reaction('1ļøā£')
await msg.add_reaction('2ļøā£')
global t1
t1 = 0
global t2
t2 = 0
await asyncio.sleep(10)
async def on_raw_reaction_add(self,payload):
guild = discord.utils.find(lambda g: g.id==payload.guild_id,self.client.guilds)
if payload.emoji.name == '1ļøā£':
t1 += 1
if payload.emoji.name == '2ļøā£':
t2 +=1
if t1 > t2:
loser = t1
await channel.send(f"{the_choices[1].mention} has been voted out!")
list_of_players.remove[the_choices[1]]
await the_choices[1].remove_roles(role)
await the_choices[1].send('You have been eliminated from the game')
else:
loser = t2
await channel.send(f"{the_choices[0].mention} has been voted out!")
await the_choices[0].remove_roles(role)
await the_choices[0].send('You have been eliminated from the game!')
list_of_players.remove(the_choices[0])
#commands.command()
async def commence(self, ctx):
try:
guild = ctx.guild
role = guild.get_role(ROLEID)
channel = await guild. create_text_channel('Elimination Game')
await channel.set_permissions(ctx.guild.default_role, send_messages=False,view_channel=False)
await channel.set_permissions(role, send_messages=True,view_channel=True)
embed = discord.Embed(title = 'The game has been commenced!', description=f'{role.mention} The elimination process will start in two minutes. This game works as follows.\nA person is eliminated every 3 minutes however there will be minigames to gain immunity! Keep your eye out for them!')
list_of_players = []
await channel.send(embed=embed)
for member in guild.members:
if role in member.roles:
list_of_players.append(member)
list_of_players.remove(self.client.user)
if len(list_of_players) < 45:
skipterval = 1
else:
skipterval = len(list_of_players) // 45
divided_point = len(list_of_players)//4
og_list = len(list_of_players)-divided_point
while len(list_of_players) >og_list:
await asyncio.sleep(5)
print(skipterval)
for loser in range(0,skipterval):
print('ii')
holder = random.choice(list_of_players)
eliminated_player = holder
list_of_players.remove(eliminated_player)
await eliminated_player.remove_roles(role)
embed = discord.Embed(title = 'Elimination!',description=f'{eliminated_player.mention} has been eliminated out of the game!')
await channel.send(embed=embed)
await eliminated_player.send('You have been eliminated from the game!')
print('dones')
randgame = random.randint(1,2)
if randgame == 1:
await self.guessthenumber(ctx, channel)
nextgame = 2
elif randgame == 2:
await self.choosekick(ctx,channel,list_of_players,role)
nextgame = 1
og_list = len(list_of_players) //4 + len(list_of_players) //4
embed = discord.Embed(title='Game Resumed!',description='The game has been resumed eliminations are starting...')
await channel.send(embed=embed)
if nextgame==1:
self.guessthenumber(ctx,channel)
if nextgame==2:
self.choosekick(ctx,channel,list_of_players,role)
except Exception:
pass
def setup(client):
client.add_cog(Game(client))
I have a for loop that runs through a list of questions creating an embed for each question. It is meant to then wait for an answer and then ask the next question. I then upload the answers to a mongodb database (after running some checks to ensure they are valid answers.
The issue I am having is that sometimes (3 in 10 tries) it will ask two questions directly after one another without giving any time to respond to the first. I have played around with sleep() but found it still happens.
Would appreciate any help you can offer!
import re
import datetime
from copy import deepcopy
import emojis
import asyncio
import discord
import math
import random
from discord.ext import commands, tasks
from dateutil.relativedelta import relativedelta
from utils.util import GetMessage
from time import sleep
"""
product = ['Name': 'Example_Name', 'Description': 'Example Description', 'Quantity in stock': 10, 'Price': 400]
Name =product[0]
Description = product[1]
Quantity = product[2]
Price= product[3]
"""
class Shop(commands.Cog):
def __init__(self, bot):
self.bot = bot
#commands.Cog.listener()
async def on_ready(self):
print(f"{self.__class__.__name__} Cog has been loaded\n-----")
#commands.command(
name='ShopAddProduct',
#aliases=['w'],
description="List all the Shops",
#usage = "[User] <Name>"
)
#commands.has_role("Server Player")
#commands.has_permissions(send_messages=True)
async def ShopAddProduct(self, ctx):
member = ctx.author
channel = await member.create_dm()
await channel.send("Lets add a product. Answer the following questions to add a product to your shop")
questionList = [
["What is your shop called?","Enter the Name of your shop"],
["What is the product called?","Enter what your product is called"],
["Describe your product","Enter a description"],
["How many of them do you have ready to sell?","Enter how many you have in stock"],
["how much are you selling them for?","Enter how many credits you want for this product."]
]
answers = {}
for i, question in enumerate(questionList):
#answer = await GetMessage(self.bot, ctx, question[0], question[1])
embed = discord.Embed(
title=f"{question[0]}",
description =f"{question[1]}",
)
embed.set_thumbnail(url=ctx.guild.icon_url)
sent = await channel.send(embed=embed)
try:
answer = await self.bot.wait_for(
"message",
timeout=60,
check=lambda message: isinstance(message.channel, discord.channel.DMChannel)
)
except asyncio.TimeoutError:
await sent.delete()
await channel.send("Cancelling due to timeout.", delete_after=10)
sleep(2)
answers[i] = answer.content
embed = discord.Embed(name="Add Product")
for key, value in answers.items():
embed.add_field(name=f"Question: `{questionList[key][0]}`", value=f"Answer: `{value}`", inline=False)
m = await channel.send("Are these all valid?", embed=embed)
await m.add_reaction("ā
")
await m.add_reaction("š½")
try:
reaction, member = await self.bot.wait_for(
"reaction_add",
timeout=60,
check=lambda reaction, user: user == ctx.author
and reaction.message.channel == channel
)
except asyncio.TimeoutError:
await channel.send("Confirmation Failure. Please try again.")
return
if str(reaction.emoji) not in ["ā
", "š½"] or str(reaction.emoji) == "š½":
await channel.send("Cancelling Product Addition!")
#check answers validity
check = await self.bot.shop.find_by_id(answers[0])
if check == None:
await channel.send(f"The shop `{answers[0]}` does not exist! Please try again.")
return
if not answers[3].isdigit():
#not isinstance(answers[3],int):
await channel.send(f"The quantity you submitted (`{answers[3]}`) must be whole number (integer)! Please try again.")
return
if not answers[4].isdigit():
#not isinstance(answers[4],int):
await channel.send(f"The price you submitted (`{answers[4]}`) must be whole number (integer)! Please try again.")
return
shopcheck = await self.bot.shopCatalogue.find_by_id(answers[0])
productlist = shopcheck['Products']
print(productlist)
product = [answers[1], answers[2], int(answers[3]), int(answers[4])]
productlist.append(product)
print(product)
print(productlist)
data = {
'_id': shopcheck['_id'],
'Products': productlist
}
guild=ctx.guild
await self.bot.shopCatalogue.upsert(data)
embed = discord.Embed(
title=f"Product Added to Shop Catalogue!",
#description =,
)
embed.add_field(
name=f"Product:",
value=answers[1],
inline=True
)
embed.add_field(
name=f"Description:",
value=answers[2],
inline=True
)
embed.add_field(
name=f"Quantity:",
value=answers[3],
inline=False
)
embed.add_field(
name=f"Price:",
value=answers[4],
inline=True
)
embed.set_thumbnail(url=ctx.guild.icon_url)
sent = await channel.send(embed=embed)
def setup(bot):
bot.add_cog(Shop(bot))
I've seen this error before, it's happens when the bots message sends fast enough to pass the check, easy fix just make sure that only you can answer to the messages
# add this
def check(message):
channel_id = message.channel.id
author_id = message.author.id
return channel_id == ctx.channel.id and author_id == ctx.author.id
# change this
reaction, member = await self.bot.wait_for(
"reaction_add",
timeout=60,
check=check
)
DISCORD.PY
I try to create an command for a poll system and encounter a problem. Command is as follows:
#commands.command(pass_context = True)
async def poll(self, ctx, question, *options: str):
author = ctx.message.author
server = ctx.message.server
if not author.server_permissions.manage_messages: return await self.bot.say(DISCORD_SERVER_ERROR_MSG)
if len(options) <= 1:
await self.bot.say("```Error! A poll must have more than one option.```")
return
if len(options) > 2:
await self.bot.say("```Error! Poll can have no more than two options.```")
return
if len(options) == 2 and options[0] == "yes" and options[1] == "no":
reactions = ['š', 'š']
else:
reactions = ['š', 'š']
description = []
for x, option in enumerate(options):
description += '\n {} {}'.format(reactions[x], option)
embed = discord.Embed(title = question, color = 3553599, description = ''.join(description))
react_message = await self.bot.say(embed = embed)
for reaction in reactions[:len(options)]:
await self.bot.add_reaction(react_message, reaction)
embed.set_footer(text='Poll ID: {}'.format(react_message.id))
await self.bot.edit_message(react_message, embed=embed)
My question is: How can I make the question I ask using the command to have more words. If I use more words now, I read them as options and get an error.
Ex 1: /poll You are human yes no (only read "you" as a question, and the rest are options.)
Ex 2: /poll You are human yes no (that's what I want)
Thank you!
When calling the command, putting a string in quotes will cause it to be treated as one argument:
/poll "You are human" yes no
You can do:
#bot.command()
async def poll(ctx, question, option1=None, option2=None):
if option1==None and option2==None:
await ctx.channel.purge(limit=1)
message = await ctx.send(f"```New poll: \n{question}```\n**ā
= Yes**\n**ā = No**")
await message.add_reaction('ā')
await message.add_reaction('ā
')
elif option1==None:
await ctx.channel.purge(limit=1)
message = await ctx.send(f"```New poll: \n{question}```\n**ā
= {option1}**\n**ā = No**")
await message.add_reaction('ā')
await message.add_reaction('ā
')
elif option2==None:
await ctx.channel.purge(limit=1)
message = await ctx.send(f"```New poll: \n{question}```\n**ā
= Yes**\n**ā = {option2}**")
await message.add_reaction('ā')
await message.add_reaction('ā
')
else:
await ctx.channel.purge(limit=1)
message = await ctx.send(f"```New poll: \n{question}```\n**ā
= {option1}**\n**ā = {option2}**")
await message.add_reaction('ā')
await message.add_reaction('ā
')
but now you must do /poll hello-everyone text text
if you want to to not have the "-" you must do:
#bot.command()
async def poll(ctx, *, question):
await ctx.channel.purge(limit=1)
message = await ctx.send(f"```New poll: \nā
= Yes**\n**ā = No**")
await message.add_reaction('ā')
await message.add_reaction('ā
')
But in this one you can't have your own options...
use :
/poll "You are human" yes no
here, "You are human" is one string "yes" "no" are other two strings.
another better way to do it is:
#commands.command(pass_context = True)
async def poll(self, ctx, option1: str, option2: str, *, question):
or, you can use wait_for
#commands.command(pass_context = True)
async def poll(self, ctx, *options: str):
...
question = await self.bot.wait_for('message', check=lambda message: message.author == ctx.author)
...
it is working
#commands.has_permissions(manage_messages=True)
#commands.command(pass_context=True)
async def poll(self, ctx, question, *options: str):
if len(options) > 2:
await ctx.send('```Error! Syntax = [~poll "question" "option1" "option2"] ```')
return
if len(options) == 2 and options[0] == "yes" and options[1] == "no":
reactions = ['š', 'š']
else:
reactions = ['š', 'š']
description = []
for x, option in enumerate(options):
description += '\n {} {}'.format(reactions[x], option)
poll_embed = discord.Embed(title=question, color=0x31FF00, description=''.join(description))
react_message = await ctx.send(embed=poll_embed)
for reaction in reactions[:len(options)]:
await react_message.add_reaction(reaction)
#create a yes/no poll
#bot.command()
#the content will contain the question, which must be answerable with yes or no in order to make sense
async def pollYN(ctx, *, content:str):
print("Creating yes/no poll...")
#create the embed file
embed=discord.Embed(title=f"{content}", description="React to this message with ā
for yes, ā for no.", color=0xd10a07)
#set the author and icon
embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url)
print("Embed created")
#send the embed
message = await ctx.channel.send(embed=embed)
#add the reactions
await message.add_reaction("ā
")
await message.add_reaction("ā")
for your code to treat the text in the user's message as one string, use "content:str" in your command arguments
I know my code isn't very dynamic and pretty but i did that and it's functional.
#client.command()
async def poll(ctx):
options = ['1ļøā£ Yes Or No', '2ļøā£ Multiple Choice']
embed = discord.Embed(title="What type of poll you want ?" , description="\n".join(options), color=0x00ff00)
msg_embed = await ctx.send(embed=embed)
reaction = await client.wait_for("reaction_add", check=poll)
if (reaction[0].emoji == '1ļøā£'):
user = await client.fetch_user(ctx.author.id)
msg = await user.send("What is your question ?")
question = await client.wait_for("message", check=lambda m: m.author == ctx.author)
answers = ['\n\u2705 Yes\n', '\u274C No']
new_embed = discord.Embed(title="Poll : " + question.content, description="\n".join(answers), color=0x00ff00)
await msg_embed.edit(embed=new_embed)
await msg_embed.remove_reaction('1ļøā£', user)
await msg_embed.add_reaction('\N{WHITE HEAVY CHECK MARK}')
await msg_embed.add_reaction('\N{CROSS MARK}')
elif (reaction[0].emoji == '2ļøā£'):
user = await client.fetch_user(ctx.author.id)
msg = await user.send("What is your question ?")
question = await client.wait_for("message", check=lambda m: m.author == ctx.author)
msg = await user.send("What are the choices ? (Four compulsory choices, separated by comma)")
choices = await client.wait_for("message", check=lambda m: m.author == ctx.author)
choices = choices.content.split(',')
if (len(choices) > 4):
await msg_embed.delete()
await user.send("You can't have more than four choices")
return
if (len(choices) < 4):
await msg_embed.delete()
await user.send("You can't have less than four choices")
return
answers = ['1ļøā£ '+ choices[0] + '\n', '2ļøā£ '+ choices[1] + '\n', '3ļøā£ '+ choices[2] + '\n', '4ļøā£ '+ choices[3] + '\n']
new_embed = discord.Embed(title=question.content, description="\n ".join(answers), color=0x00ff00)
await msg_embed.edit(embed=new_embed)
await msg_embed.remove_reaction('2ļøā£', user)
await msg_embed.add_reaction('1ļøā£')
await msg_embed.add_reaction('2ļøā£')
await msg_embed.add_reaction('3ļøā£')
await msg_embed.add_reaction('4ļøā£')