lancetabler
lancetabler

Reputation: 1

'NoneType object has no attribute ' send'

My code is returning this error NoneType object has no attribute 'send'

here is my code

import discord
import os
from discord.ext import commands

client = discord.Client()

class Logging(commands.Cog):
    """Sets up logging for you guild"""
    
    def __init__(self, client):
        self.bot = client

    async def __error(self, ctx, error):
        if isinstance(error, commands.BadArgument):
            await ctx.send(error)

    @commands.Cog.listener()
    async def on_message_delete(self, message,):

         deleted = embed = discord.Embed(
             description=f"Message deleted in {message.channel.mention}", color=0x4040EC
         ).set_author(name=message.author, url= discord.Embed.Empty, icon_url=message.author.avatar_url)

         
         
         
         channel = client.get_channel(888600482317213786)
         deleted.add_field(name="Message", value=message.content)
         deleted.timestamp = message.created_at
         await channel.send(embed=deleted)

def setup(client):
    client.add_cog(Logging(client))

I am doing this in my cogs and not in the main.py

Upvotes: 0

Views: 188

Answers (1)

Nevus
Nevus

Reputation: 1407

channel = client.get_channel(888600482317213786) should be channel = self.bot.get_channel(888600482317213786). Then check if channel is None.
I assume there is no indentation error in your actual code.

Upvotes: 2

Related Questions