'Discord.py how to make buttons respond

ok so im a making a game in discord, where you walk on a 5 by 5 grid using buttons, everything almost works, i have the code that changes pozitions (the one below the async def for example) , the buttons appear. I just dont know how to make the code respond to button clicks. (here is an example of the code that should comment the game and move the player to the right when a button is pressed,(also the game is a list which contains the emotes making the game and pozition is the index of the player in the list)

@client.event
async def on_message(message):
if message.author == client.user:
return
if message.author.bot:
return

def check(m):
  return m.author == message.author and m.channel == message.channel
if "test" in message.content.lower():
view = discord.ui.View()
item = discord.ui.Button(label="<", style=discord.ButtonStyle.blurple)
item1 = discord.ui.Button(label=">", style=discord.ButtonStyle.blurple)
item2= discord.ui.Button(label="góra", style=discord.ButtonStyle.blurple)
item3 = discord.ui.Button(label="dół", style=discord.ButtonStyle.blurple)
view.add_item(item=item)  
view.add_item(item=item2)
view.add_item(item=item3)
view.add_item(item=item1)
pozition = 12
player = "<:B_:943183343254650920>" #its a emote id
game[pozition] = player
msg_ = await message.channel.send(''.join(game), view=view)
  async def button_callback(self, interaction):
    global pozition
    game[pozition] = "<:A_:943184054432452678>"
    pozition += 5
    game[pozition] = player
    await asyncio.sleep(1)
    await interaction.response.edit_message(content=''.join(game), view=view)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source