Reputation: 11
channel = client.get_channel
if message.content.lower().startswith('experiment'):
moji = await client.get_channel.send("https://c.tenor.com/R_itimARcLAAAAAd/talking-ben-yes.gif")
emoji = [":blue_circle:"]
for experiment in emoji:
await client.add_reaction(emoji)
What I want the bot to do is when the user types 'experiment' the bot will send the link to the photo and it will attach the emoji to it. It gives me this error.
Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\13129\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) File "c:\Users\13129\Desktop\Python Bot\Ben.py", line 50, in on_message moji = await client.get_channel.send("https://c.tenor.com/R_itimARcLAAAAAd/talking-ben-yes.gif") AttributeError: 'function' object has no attribute 'send'
I tried changing a few things on line 20 but nothing seems to be working!
Upvotes: 0
Views: 1156
Reputation: 116
Bot.get_channel
is a method which takes a channel_id
as a positional argument and gets you a Union[StageChannel, VoiceChannel, CategoryChannel, TextChannel, Thread (if you are on master)]
if the ID you pass to it matches one it has in its internal cache (this requeires members
intent)
you can't do
get_channel.send()
, get_channel
is a method
, or in other words, a bound function to Bot
class.
here is an example usage:
channel = bot.get_channel(CHANNEL_ID)
await channel.send("hello there!")
also,
client.add_reaction(emoji)
is not a thing
Message.add_reaction
is. await channel.send()
returns a Message
object which you can store in a variable and then add your emoji
message = await channel.send("hello there!")
for emo in emoji:
await message.add_reaction(emo)
and I am pretty sure that you need the unicode
of that emoji and the string would raise UnknownEmoji
error, but if it doesn't then it's fine. If it does though, just use "\N{Large Blue Circle}"
instead :blue_circle:
and that should fix it.
Upvotes: 1
Reputation: 511
You should be doing client.get_channel() with something in the brackets like a channel ID, not client.get_channel
If not how will they know what channel to send it to.
For Prefixed Commands
@client.command()
async def command_name(ctx)
await ctx.send()
# Sends to what ever channel the command was sent in
Upvotes: 0