Discord.py if not working to check boolean
up vote
0
down vote
favorite
Here's my little problem:
if start == False:
start = True
players_list.append(ctx.message.author.id)
await self.client.send_message(channel, '**Session created by ** Wait another player to join..'.format(ctx.message.author))
start boolean in that if caused an error bcs I put start = True
inside that if
Entire code:
import discord
from discord.ext import commands
players_list =
wolves_list =
villagers_list =
start = False
class Werewolf:
def __init__(self, client):
self.client = client
@commands.command(pass_context = True)
async def playww(self, ctx):
channel = ctx.message.channel
if start == False:
start = True
players_list.append(ctx.message.author.id)
await self.client.send_message(channel, '**Session created by ** Wait another player to join..'.format(ctx.message.author))
else:
await self.client.send_message(channel, '**Session already created!**')
@commands.command(pass_context = True)
async def joinww(self, ctx):
channel = ctx.message.channel
id_player = ctx.message.author.id
if start == True:
if id_player not in players_list:
players_list.append(id_player)
await self.client.send_message(channel, '**** joined the game!'.format(ctx.message.author))
else:
await self.client.send_message(channel, '**** already inside player list!'.format(ctx.message.author))
else:
await self.client.send_message(channel, 'Create session first by `-playww` command!')
def setup(client):
client.add_cog(Werewolf(client))
Any ideas?
python discord discord.py
add a comment |
up vote
0
down vote
favorite
Here's my little problem:
if start == False:
start = True
players_list.append(ctx.message.author.id)
await self.client.send_message(channel, '**Session created by ** Wait another player to join..'.format(ctx.message.author))
start boolean in that if caused an error bcs I put start = True
inside that if
Entire code:
import discord
from discord.ext import commands
players_list =
wolves_list =
villagers_list =
start = False
class Werewolf:
def __init__(self, client):
self.client = client
@commands.command(pass_context = True)
async def playww(self, ctx):
channel = ctx.message.channel
if start == False:
start = True
players_list.append(ctx.message.author.id)
await self.client.send_message(channel, '**Session created by ** Wait another player to join..'.format(ctx.message.author))
else:
await self.client.send_message(channel, '**Session already created!**')
@commands.command(pass_context = True)
async def joinww(self, ctx):
channel = ctx.message.channel
id_player = ctx.message.author.id
if start == True:
if id_player not in players_list:
players_list.append(id_player)
await self.client.send_message(channel, '**** joined the game!'.format(ctx.message.author))
else:
await self.client.send_message(channel, '**** already inside player list!'.format(ctx.message.author))
else:
await self.client.send_message(channel, 'Create session first by `-playww` command!')
def setup(client):
client.add_cog(Werewolf(client))
Any ideas?
python discord discord.py
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Here's my little problem:
if start == False:
start = True
players_list.append(ctx.message.author.id)
await self.client.send_message(channel, '**Session created by ** Wait another player to join..'.format(ctx.message.author))
start boolean in that if caused an error bcs I put start = True
inside that if
Entire code:
import discord
from discord.ext import commands
players_list =
wolves_list =
villagers_list =
start = False
class Werewolf:
def __init__(self, client):
self.client = client
@commands.command(pass_context = True)
async def playww(self, ctx):
channel = ctx.message.channel
if start == False:
start = True
players_list.append(ctx.message.author.id)
await self.client.send_message(channel, '**Session created by ** Wait another player to join..'.format(ctx.message.author))
else:
await self.client.send_message(channel, '**Session already created!**')
@commands.command(pass_context = True)
async def joinww(self, ctx):
channel = ctx.message.channel
id_player = ctx.message.author.id
if start == True:
if id_player not in players_list:
players_list.append(id_player)
await self.client.send_message(channel, '**** joined the game!'.format(ctx.message.author))
else:
await self.client.send_message(channel, '**** already inside player list!'.format(ctx.message.author))
else:
await self.client.send_message(channel, 'Create session first by `-playww` command!')
def setup(client):
client.add_cog(Werewolf(client))
Any ideas?
python discord discord.py
Here's my little problem:
if start == False:
start = True
players_list.append(ctx.message.author.id)
await self.client.send_message(channel, '**Session created by ** Wait another player to join..'.format(ctx.message.author))
start boolean in that if caused an error bcs I put start = True
inside that if
Entire code:
import discord
from discord.ext import commands
players_list =
wolves_list =
villagers_list =
start = False
class Werewolf:
def __init__(self, client):
self.client = client
@commands.command(pass_context = True)
async def playww(self, ctx):
channel = ctx.message.channel
if start == False:
start = True
players_list.append(ctx.message.author.id)
await self.client.send_message(channel, '**Session created by ** Wait another player to join..'.format(ctx.message.author))
else:
await self.client.send_message(channel, '**Session already created!**')
@commands.command(pass_context = True)
async def joinww(self, ctx):
channel = ctx.message.channel
id_player = ctx.message.author.id
if start == True:
if id_player not in players_list:
players_list.append(id_player)
await self.client.send_message(channel, '**** joined the game!'.format(ctx.message.author))
else:
await self.client.send_message(channel, '**** already inside player list!'.format(ctx.message.author))
else:
await self.client.send_message(channel, 'Create session first by `-playww` command!')
def setup(client):
client.add_cog(Werewolf(client))
Any ideas?
python discord discord.py
python discord discord.py
asked Nov 9 at 6:48
Shiina011
51
51
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Make start
(and all of the other "global" variables) an attribute of the Werewolf
cog.
class Werewolf:
def __init__(self, client):
self.client = client
self.players_list =
self.wolves_list =
self.villagers_list =
self.start = False
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Make start
(and all of the other "global" variables) an attribute of the Werewolf
cog.
class Werewolf:
def __init__(self, client):
self.client = client
self.players_list =
self.wolves_list =
self.villagers_list =
self.start = False
add a comment |
up vote
0
down vote
accepted
Make start
(and all of the other "global" variables) an attribute of the Werewolf
cog.
class Werewolf:
def __init__(self, client):
self.client = client
self.players_list =
self.wolves_list =
self.villagers_list =
self.start = False
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Make start
(and all of the other "global" variables) an attribute of the Werewolf
cog.
class Werewolf:
def __init__(self, client):
self.client = client
self.players_list =
self.wolves_list =
self.villagers_list =
self.start = False
Make start
(and all of the other "global" variables) an attribute of the Werewolf
cog.
class Werewolf:
def __init__(self, client):
self.client = client
self.players_list =
self.wolves_list =
self.villagers_list =
self.start = False
answered Nov 9 at 13:00
Patrick Haugh
26.3k82546
26.3k82546
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53221048%2fdiscord-py-if-not-working-to-check-boolean%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown