Browse Source

Change persistent view example to use new setup_hook

pull/7686/head
Rapptz 3 years ago
parent
commit
bc70ec5cfd
  1. 6
      examples/views/persistent.py

6
examples/views/persistent.py

@ -35,18 +35,16 @@ class PersistentViewBot(commands.Bot):
intents.message_content = True
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
self.persistent_views_added = False
async def on_ready(self):
if not self.persistent_views_added:
async def setup_hook(self) -> None:
# Register the persistent view for listening here.
# Note that this does not send the view to any message.
# In order to do this you need to first send a message with the View, which is shown below.
# If you have the message_id you can also pass it as a keyword argument, but for this example
# we don't have one.
self.add_view(PersistentView())
self.persistent_views_added = True
async def on_ready(self):
print(f'Logged in as {self.user} (ID: {self.user.id})')
print('------')

Loading…
Cancel
Save