0
votes

Please don't say "Already answered", cause I tried EVERYTHING, including all related posts here and obviously, reading the api doc.

Complete error is:

Ignoring exception in on_ready Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 312, in _run_event await coro(*args, **kwargs) File "embbed_shop.py", line 26, in on_ready await channel.send_message(embed=embed) AttributeError: 'NoneType' object has no attribute 'send_message'

Here is my complete code (except token):

import discord
from discord.ext import commands
import datetime
import asyncio
import time

from urllib import parse, request
import re

bot = discord.Client()

@bot.event
async def on_ready():
    embed = discord.Embed(title="Le SHOP de POIDSPLUME", colour=discord.Colour(0xff9e26), url="https://discordapp.com", description="```yaml\n \t\t\t\t CASSIMON vs ENDER```", timestamp=datetime.datetime.utcfromtimestamp(1593927421))

    embed.set_image(url="https://vignette.wikia.nocookie.net/bokunoheroacademia/images/d/d8/Class_1-A_vs._Mirio_Togata_Anime.png/revision/latest?cb=20181001113201")
    embed.set_thumbnail(url="https://i.pinimg.com/564x/d5/76/60/d576605d7afc2387757862d9916ea911.jpg")
    embed.set_author(name="Poidsplume SHOP", icon_url="https://cdn.discordapp.com/embed/avatars/0.png")
    embed.set_footer(text="Powered by @Poidsplume (La Banque)", icon_url="https://i.pinimg.com/564x/d5/76/60/d576605d7afc2387757862d9916ea911.jpg")

    embed.add_field(name=" __Achats Cassimon__ ", value="- 1000 pokédollars :dollar: =  200 <:perfectprism:726002243677192283> __ou__ 80 <:Antimater:726002322127454227> \n-1 Pokémon SH qui méga ou giga  = 2k <:Antimater:726002322127454227> ou équivalent ", inline=True)
    embed.add_field(name="__Ventes Cassimon__ ", value="Les pokémons en vente sont tous à __1500__ pokédollars :dollar: : \n\n x1 Mouscoto <:mouscoto:729241671899938826> \n x1 Ho-oh <:ho_oh_1:729240842518134795> \n x1 Régirock <:regirock:729241757803348000> \n x1 Necrozma Crinière du couchant <:necrozma_criniere:729241703273463830> \n\n\nx1 Hélionceau SH <:helionceau:729242441206726738>", inline=True)
    embed.add_field(name=".", value="```yaml\n \t\t\t\tENDER vs ENDER```")
    embed.add_field(name=".", value="A VENIR[]")
    channel = bot.get_channel(712559462262767617)
    await channel.send_message(embed=embed)

bot.run("TOKEN") ```

Regards,
2
Please create a minimal reproducible example. When asking about an expection, provide the exact error message including the stack trace, from which it is clear which line in your code produces the error.zvone
I think it's all ^^Ju Facultatif Lhz
@zvone This is a special case as it does not have an error. It just does not work. That's discord.py for you hahasam.iee

2 Answers

0
votes
  1. Remove the quotes from:

channel = bot.get_channel('712559462262767617')

to

channel = bot.get_channel(712559462262767617)


  1. Change send_message to send

await channel.send(embed=embed)


Tell me if this works please. It seems as if you are using the older version of discord.py


I got this answer from: Trying to send a message to a specific channel using Discord.py rewrite and it isn't working

0
votes

This API Reference will probably be more useful: https://discordpy.readthedocs.io/en/latest/api.html#textchannel

You have to use send instead of send_message as defined in the documentation that I linked above

embed = discord.Embed(title="Hi!")

channel = bot.get_channel(712559462262767617)
await channel.send(embed=embed)

There a couple of changes you have to understand in the new version of discord.py
For instance,

  • Snowflakes are no longer strings, they are integers now
  • send_message became send
  • Server is now Guild

Don't hesitate to check this link for a complete list of changes: https://discordpy.readthedocs.io/en/latest/migrating.html