Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cbdiscord
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Geovanny E. Vera Pazmino
cbdiscord
Commits
3ec0f548
Commit
3ec0f548
authored
Jun 02, 2020
by
Geovanny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed participation url and new display for participation
parent
52c6cc60
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
20 deletions
+45
-20
manager.py
discord/house/war/manager.py
+45
-20
No files found.
discord/house/war/manager.py
View file @
3ec0f548
...
...
@@ -32,51 +32,76 @@ class WarManager(commands.Cog):
except
ApiError
as
error
:
await
ctx
.
send
(
error
.
message
)
@
commands
.
command
(
aliases
=
[
"si"
])
@
commands
.
command
(
aliases
=
[
"si"
,
"SI"
,
"yes"
])
async
def
warYes
(
self
,
ctx
):
"""Yes confirmation to current war"""
await
self
.
warParticipation
(
ctx
,
"Yes"
)
@
commands
.
command
(
aliases
=
[
"no"
])
@
commands
.
command
(
aliases
=
[
"no"
,
"NO"
])
async
def
warNo
(
self
,
ctx
):
"""No confirmation to current war"""
await
self
.
warParticipation
(
ctx
,
"No"
)
@
commands
.
command
(
aliases
=
[
"idk"
])
@
commands
.
command
(
aliases
=
[
"idk"
,
"IDK"
])
async
def
warIdk
(
self
,
ctx
):
"""Maybe confirmation to current war"""
await
self
.
warParticipation
(
ctx
,
"Maybe"
)
@
commands
.
command
()
@
commands
.
command
(
aliases
=
[
"guerra"
]
)
async
def
houseParticipation
(
self
,
ctx
):
try
:
session
=
await
self
.
bot
.
getUserSession
(
ctx
.
message
.
author
)
data
=
await
Api
.
getSession
(
'/house/participation'
,
session
)
data
=
await
Api
.
getSession
(
'/house/
war/
participation'
,
session
)
date
=
parser
.
parse
(
data
[
'war'
]
.
get
(
'day'
))
await
ctx
.
send
(
'Participation for War: {0}/{1}/{2}'
.
format
(
date
.
year
,
date
.
month
,
date
.
day
))
await
EmbedStyle
.
createPages
(
self
.
bot
,
ctx
,
data
.
get
(
'participation'
),
10
,
self
.
craftParticipationPage
)
members
=
data
.
get
(
'participation'
)
yes_list
=
list
(
filter
(
lambda
x
:
x
.
get
(
'decision'
)
==
'Yes'
,
members
))
no_list
=
list
(
filter
(
lambda
x
:
x
.
get
(
'decision'
)
==
'No'
,
members
))
idk_list
=
list
(
filter
(
lambda
x
:
x
.
get
(
'decision'
)
==
'Maybe'
,
members
))
yes_embed
=
self
.
craftColumns
(
yes_list
,
3
,
'Yes'
)
no_embed
=
self
.
craftColumns
(
no_list
,
3
,
'No'
)
idk_embed
=
self
.
craftColumns
(
idk_list
,
3
,
'Maybe'
)
await
ctx
.
send
(
embed
=
yes_embed
)
await
ctx
.
send
(
embed
=
no_embed
)
await
ctx
.
send
(
embed
=
idk_embed
)
except
ApiError
as
error
:
await
ctx
.
send
(
error
.
message
)
def
craftParticipationPage
(
self
,
data
,
minI
,
maxI
):
embed
=
discord
.
Embed
(
color
=
0x19212d
)
embed
.
set_author
(
name
=
'Conquy'
)
def
craftColumns
(
self
,
data
,
numOfColumns
,
title
):
embed
=
discord
.
Embed
()
embed
.
set_author
(
name
=
title
)
if
(
len
(
data
)
==
0
):
embed
.
add_field
(
name
=
'Members'
,
value
=
'None'
)
return
embed
lens
=
len
(
data
)
//
numOfColumns
rem
=
len
(
data
)
%
numOfColumns
if
rem
!=
0
:
lens
+=
1
table
=
[]
for
i
in
range
(
minI
,
maxI
):
if
i
<
len
(
data
):
part
=
data
[
i
]
item
=
part
.
values
()
table
.
append
(
item
)
headers
=
[
"Name"
,
"Decision"
]
for
i
in
range
(
lens
):
temp
=
[]
for
j
in
range
(
numOfColumns
):
index
=
(
numOfColumns
*
i
)
+
j
if
index
<
len
(
data
):
temp
.
append
(
data
[
index
]
.
get
(
'username'
))
else
:
# Add empty cell for zipping purposes
temp
.
append
(
' '
)
table
.
append
(
temp
)
headers
=
[
'a'
,
'b'
,
'c'
]
max_lens
=
[
len
(
str
(
max
(
i
,
key
=
lambda
x
:
len
(
str
(
x
)))))
for
i
in
zip
(
headers
,
*
table
)]
participation_str
=
'```'
;
for
row
in
(
headers
,
*
table
)
:
participation
_str
+=
(
' | '
.
join
(
'{0:{width}}'
.
format
(
x
,
width
=
y
)
for
x
,
y
in
zip
(
row
,
max_lens
)))
+
'
\n
'
participation_str
+=
'```'
embed
.
add_field
(
name
=
'Participation'
,
value
=
participation
_str
)
out_str
=
'```'
for
row
in
table
:
out
_str
+=
(
' | '
.
join
(
'{0:{width}}'
.
format
(
x
,
width
=
y
)
for
x
,
y
in
zip
(
row
,
max_lens
)))
+
'
\n
'
out_str
+=
'```'
embed
.
add_field
(
name
=
"Members"
,
value
=
out
_str
)
return
embed
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment