mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-11 20:35:26 +00:00
Change persistent view example to use new setup_hook
This commit is contained in:
parent
c95c163266
commit
bc70ec5cfd
@ -35,18 +35,16 @@ class PersistentViewBot(commands.Bot):
|
|||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
|
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
|
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
|
||||||
self.persistent_views_added = False
|
|
||||||
|
|
||||||
async def on_ready(self):
|
async def setup_hook(self) -> None:
|
||||||
if not self.persistent_views_added:
|
|
||||||
# Register the persistent view for listening here.
|
# Register the persistent view for listening here.
|
||||||
# Note that this does not send the view to any message.
|
# 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.
|
# 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
|
# If you have the message_id you can also pass it as a keyword argument, but for this example
|
||||||
# we don't have one.
|
# we don't have one.
|
||||||
self.add_view(PersistentView())
|
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(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
print('------')
|
print('------')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user