Skip to content

Commit

Permalink
fix dropdown counter
Browse files Browse the repository at this point in the history
  • Loading branch information
FO-nTTaX committed Aug 8, 2021
1 parent 968d8f3 commit 5adbbd6
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions ftsbot/cogs/rolecommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async def wikiroles(self, ctx):
@decoratorfunctions.is_bot_owner()
@slash_commands.command(description='Form setup (admin only)')
async def setup(self, ctx):

# Clean up channel
async for message in ctx.channel.history():
await message.delete()
Expand All @@ -54,18 +55,20 @@ async def setup(self, ctx):
entries_per_select = 25

# Add roles
c = 0
# Wikis
amount_select = math.ceil(len(data.botroleswikis) / entries_per_select)
components = []
for i in range(0, amount_select):
c += 1
options = []
for j in range(0, entries_per_select):
entry_id = j + i * entries_per_select
if entry_id < len(data.botroleswikis):
role = data.botroleswikis[entry_id]
options.append(SelectOption(role, role))
components.append(SelectMenu(
custom_id='addrole_select_' + str(i),
custom_id='addrole_select_' + str(c),
placeholder='Choose which wiki roles you want to add',
max_values=len(options),
options=options
Expand All @@ -78,14 +81,15 @@ async def setup(self, ctx):
amount_select = math.ceil(len(data.botroleslanguages) / entries_per_select)
components = []
for i in range(0, amount_select):
c += 1
options = []
for j in range(0, entries_per_select):
entry_id = j + i * entries_per_select
if entry_id < len(data.botroleslanguages):
role = data.botroleslanguages[entry_id]
options.append(SelectOption(role, role))
components.append(SelectMenu(
custom_id='addrole_select_' + str(i),
custom_id='addrole_select_' + str(c),
placeholder='Choose which language roles you want to add',
max_values=len(options),
options=options
Expand All @@ -98,14 +102,15 @@ async def setup(self, ctx):
amount_select = math.ceil(len(data.botrolesmisc) / entries_per_select)
components = []
for i in range(0, amount_select):
c += 1
options = []
for j in range(0, entries_per_select):
entry_id = j + i * entries_per_select
if entry_id < len(data.botrolesmisc):
role = data.botrolesmisc[entry_id]
options.append(SelectOption(role, role))
components.append(SelectMenu(
custom_id='addrole_select_' + str(i),
custom_id='addrole_select_' + str(c),
placeholder='Choose which misc roles you want to add',
max_values=len(options),
options=options
Expand All @@ -116,18 +121,20 @@ async def setup(self, ctx):
)

# Remove roles
c = 0
# Wikis
amount_select = math.ceil(len(data.botroleswikis) / entries_per_select)
components = []
for i in range(0, amount_select):
c += 1
options = []
for j in range(0, entries_per_select):
entry_id = j + i * entries_per_select
if entry_id < len(data.botroleswikis):
role = data.botroleswikis[entry_id]
options.append(SelectOption(role, role))
components.append(SelectMenu(
custom_id='removerole_select_' + str(i),
custom_id='removerole_select_' + str(c),
placeholder='Choose which wiki roles you want to remove',
max_values=len(options),
options=options
Expand All @@ -140,14 +147,15 @@ async def setup(self, ctx):
amount_select = math.ceil(len(data.botroleslanguages) / entries_per_select)
components = []
for i in range(0, amount_select):
c += 1
options = []
for j in range(0, entries_per_select):
entry_id = j + i * entries_per_select
if entry_id < len(data.botroleslanguages):
role = data.botroleslanguages[entry_id]
options.append(SelectOption(role, role))
components.append(SelectMenu(
custom_id='removerole_select_' + str(i),
custom_id='removerole_select_' + str(c),
placeholder='Choose which language roles you want to remove',
max_values=len(options),
options=options
Expand All @@ -160,14 +168,15 @@ async def setup(self, ctx):
amount_select = math.ceil(len(data.botrolesmisc) / entries_per_select)
components = []
for i in range(0, amount_select):
c += 1
options = []
for j in range(0, entries_per_select):
entry_id = j + i * entries_per_select
if entry_id < len(data.botrolesmisc):
role = data.botrolesmisc[entry_id]
options.append(SelectOption(role, role))
components.append(SelectMenu(
custom_id='removerole_select_' + str(i),
custom_id='removerole_select_' + str(c),
placeholder='Choose which misc roles you want to remove',
max_values=len(options),
options=options
Expand Down

0 comments on commit 5adbbd6

Please sign in to comment.