Search code examples
pythonpython-3.xdiscorddiscord.pyhelper

AttributeError: 'Bot' object has no attribute 'pin_message'


Erro: AttributeError: 'Bot' object has no attribute 'pin_message' It's doing this erro, and I dont understand why. Can anyone help me with this Thankful

global stopcheck
stopcheck = 'test'
import asyncio
global time
time = 100
import os
ContinueAutoJoke = 'autojoke'
StopAutoJoke = 'o'
import discord
import time
import random
import discord
from discord.ext import commands



client = discord.Client()
client = commands.Bot(command_prefix = '$')

@client.command()
async def test(ctx):
  message = await ctx.send(f'All messages gonna be deleted in 100 seconds')
  await client.pin_message(message)
  for c in range(-100,0):
      await message.edit(content=f'All messages gonna be deleted in {c} seconds')

Solution

  • You need to use discord.Message.pin(), not client.pin_message(message):

    @client.command()
    async def test(ctx):
        message = await ctx.send(f'All messages gonna be deleted in 100 seconds')
        await message.pin()
        for c in range(-100,0):
            await message.edit(content=f'All messages gonna be deleted in {c} seconds')
            asyncio.sleep(1)
        await ctx.purge(limit=100)