feat: add ability to exclusive command on channel
This commit is contained in:
@@ -115,8 +115,6 @@ class Fun(commands.Cog):
|
|||||||
# get poll from cache
|
# get poll from cache
|
||||||
poll = Poll.create_from(json.loads(polls[event.message_id]))
|
poll = Poll.create_from(json.loads(polls[event.message_id]))
|
||||||
|
|
||||||
print(event)
|
|
||||||
|
|
||||||
# check reaction emoji type
|
# check reaction emoji type
|
||||||
if event.event_type == "REACTION_ADD":
|
if event.event_type == "REACTION_ADD":
|
||||||
poll.add_vote(event.user_id, event.emoji.name)
|
poll.add_vote(event.user_id, event.emoji.name)
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ class Poll:
|
|||||||
# only add vote if user has not already voted
|
# only add vote if user has not already voted
|
||||||
if user_id not in self.votes[option]:
|
if user_id not in self.votes[option]:
|
||||||
self.votes[option].append(user_id)
|
self.votes[option].append(user_id)
|
||||||
|
|
||||||
print(self.votes) # TODO: remove
|
|
||||||
|
|
||||||
def remove_vote(self, user_id: str, emoji: str) -> None:
|
def remove_vote(self, user_id: str, emoji: str) -> None:
|
||||||
option = self._get_option(emoji)
|
option = self._get_option(emoji)
|
||||||
@@ -41,8 +39,6 @@ class Poll:
|
|||||||
# only remove if user has voted
|
# only remove if user has voted
|
||||||
if user_id in self.votes[option]:
|
if user_id in self.votes[option]:
|
||||||
self.votes[option].remove(user_id)
|
self.votes[option].remove(user_id)
|
||||||
|
|
||||||
print(self.votes) # TODO: remove
|
|
||||||
|
|
||||||
def get_emoji(self, option: str) -> str:
|
def get_emoji(self, option: str) -> str:
|
||||||
return Poll.OPTION_EMOJIS[self.options.index(option)]
|
return Poll.OPTION_EMOJIS[self.options.index(option)]
|
||||||
|
|||||||
5
pyvis.py
5
pyvis.py
@@ -55,7 +55,10 @@ async def on_message(message):
|
|||||||
if message.author == bot.user:
|
if message.author == bot.user:
|
||||||
return
|
return
|
||||||
|
|
||||||
# TODO: if channel is a proposal channel check for poll command
|
# if channel is proposals and message is not a poll command then delete
|
||||||
|
if message.channel.name == "📝proposals" and not message.content.startswith("!poll create") and not message.content.startswith("!poll results"):
|
||||||
|
await message.delete()
|
||||||
|
return
|
||||||
|
|
||||||
# repsond with command prefix
|
# repsond with command prefix
|
||||||
if bot.user.mentioned_in(message) and not message.mention_everyone:
|
if bot.user.mentioned_in(message) and not message.mention_everyone:
|
||||||
|
|||||||
Reference in New Issue
Block a user