31b4
31b4

Reputation: 5

Discord.py send Embed with random colour: 'module' object is not callable

I want the bot to reply with embeds, here is the code: imports:

import discord
from discord import app_commands
async def reminder():
  channel = client.get_channel(1043655467089535067)
  embed = discord.Embed(title="This is my embed", description="Its very cool", colour=discord.colour.random())
  await channel.send(embed)

here is the error:

Traceback (most recent call last):
  File "/home/runner/inandoutbot/venv/lib/python3.10/site-packages/discord/client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 55, in on_ready
    await reminder()
  File "main.py", line 85, in reminder
    embed = discord.Embed(title="This is my embed", description="Its very cool", colour=discord.colour.random())
TypeError: 'module' object is not callable

I gave up trying, i think i missing someting

Upvotes: 0

Views: 75

Answers (1)

Daraan
Daraan

Reputation: 3790

The error lies within discord.colour.random, with the lowercase colour beeing the colour module and colour.random pointing to the random module - which raises the error.

You need the uppercase Colour class, where random then is a function.

discord.Colour.random

Upvotes: 1

Related Questions