import discord
from discord.commands import SlashCommandGroup
from discord.ext import commands
import WiP.cogs.views as views
class Poll(commands.Cog):
def __init__(self, bot) -> None:
self.bot = bot
poll = SlashCommandGroup(name="poll", description="Create a poll")
@poll.command(name="single")
async def poll_single(self, interaction: discord.Interaction):
"""Create a single choice poll."""
await self._poll_callback(interaction, views.PollCreate(), max_values=1)
@poll.command(name="multiple")
async def poll_multiple(
self,
interaction: discord.Interaction,
):
"""Create a multiple choice poll."""
await self._poll_callback(
interaction, views.PollCreate()
)
@poll.command(name="yes-no")
async def poll_yes_no(self, interaction: discord.Interaction):
"""Create a "Yes or No" poll."""
await self._poll_callback(interaction, views.PollYesNoCreate(), max_values=1)
async def _poll_callback(
self,
interaction: discord.Interaction,
modal: discord.ui.Modal,
*,
max_values: int
):
"""Callback for poll creation and sending to the channel."""
await interaction.response.send_modal(modal)
await modal.wait()
options = modal.options.value.split("\n")
max_values = min(max_values, len(options))
view = views.PollInput(
author=interaction.user, modal=modal, max_values=max_values
)
embed, graph = await view.build_embed()
await interaction.followup.send(
embed=embed,
file=graph,
view=view,
)
def setup(bot):
bot.add_cog(Poll(bot))
#Poll cog
1 messages · Page 1 of 1 (latest)
- What isn't working? Are you getting any errors?
- That code on GitHub is for discord.py bots, not pycord bots
isn't pycord compatible with discord.py?
Pycord is it's own API Wrapper, just like discord.py. Pycord is a fork of discord.py so a lot of the stuff is implement the same way, but not all of them.
So discord.py and pycord cannot be used at the same time
i am sorry, i thought i closed this one because i wanted to try it for my own.
please delete
No tag close found.
.tag close
Done with your help thread?
Please close your own help thread by using </close:1009144375709814897> with @gentle storm.
Backup bot: </solved:1109625445990793246> (or
.solved) with @grave verge.