def __init__(self, user_p: dict, user_c: dict):
super().__init__(label='Join the game.', style=discord.ButtonStyle.blurple)
self.message = None
self.user_p = user_p
self.user_c = user_c
async def join(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user.id in self.user_c.keys():
await interaction.response.send_message("You already joined the game!", ephemeral=True)
await interaction.response.send_message(f"<@{interaction.user.id}> you have successfully joined the game!", ephemeral=True)
self.user_p[interaction.user.id] = 0
self.user_c[interaction.user.id] = 0
class Quit(Button):
def __init__(self, user_p: dict, user_c: dict, host: int, game_going: dict):
super().__init__(label="Cancel", style=discord.ButtonStyle.danger)
self.message = None
self.user_p = user_p
self.user_c = user_c
self.host = host
self.game_going = game_going
async def callback(self, interaction: discord.Interaction):
if self.host == interaction.user.id:
can_emb = discord.Embed(title="Game cancelled!", description="The host thought to cancel the game. Successfully cancelled the game.", color=discord.Color.red())
can_emb.timestamp = datetime.now(timezone.utc)
await interaction.response.send_message(embed=can_emb)
self.host = 0
self.game_going["cancel"] = True
for item in self.view.children:
item.disabled = True
await self.message.edit(view=self)
``` This gives an error: 'Quit' object has no attribute 'to_components'. Did you mean: 'from_component'? Does anyone know how to fix it
#Error in disabling button
1 messages · Page 1 of 1 (latest)
You can use self.disable all item
.rtfm disable all item
16 results
discord.Member.communication_disabled_until
discord.ui.Select.disabled
discord.Guild.invites_disabled
discord.SelectMenu.disabled
discord.ui.View.disable_all_items
discord.ContentFilter.disabled
discord.StageInstance.discoverable_disabled
discord.ext.commands.DisabledCommand
discord.ext.commands.DisabledCommand.args
discord.ext.commands.DisabledCommand.with_traceback
discord.ext.pages.Paginator.disable
discord.ext.pages.Paginator.disable_all_items
discord.Button.disabled
discord.ext.pages.PaginatorMenu.disabled
discord.ui.Button.disabled
discord.ext.pages.PaginatorButton.disabled
Searched in pycord
it says no attribute
mb, ur thing is a subclass of Button and not View
so just self.disabled = True should be good
Alr
self.disabled = True works but after putting self.message.edit gives the error again mentioned in post
o
View is not a button
yes
Then how do I edit the message
await self.message.edit(view=self.view) i guess