Based on this, this, this & this, I expected client.get_all_emojis()
to work in my Discord chat bot:
import discord
from dotenv import load_dotenv
import asyncio
import os
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
client = discord.Client()
@client.event
async def on_message(message):
if message.content == 'send emoji':
await message.channel.send(client.get_all_emojis()[0])
client.run(TOKEN)
I expected client.get_all_emojis()
to be a list, & wanted the bot to send the first element of that list. I get however:
Traceback (most recent call last):
File "/home/ps738/.local/lib/python3.8/site-packages/discord/client.py", line 312, in _run_eventawait coro(*args, **kwargs) > File "bot5.py", line 15, in on_message
await message.channel.send(client.get_all_emojis()[0]) > AttributeError: 'Client' object has no attribute 'get_all_emojis'
Main point: 'Client' object has no attribute 'get_all_emojis'.
How can I fix this?
ADD
Based on Patrick's comment to this answer & this source of PrimeEpoch's answer to my question, I tried replacing client.get_all_emojis()[0]
with client.emojis[0]
. Now it says: IndexError: list index out of range
, so probably an empty list was returned, which is not ideal.