2017-04-23 48 views
3

我正在做一個機器人與Discord.py和我有一些問題,如何使用功能create_custom_emojis(),因爲無論我做什麼,我不斷收到HTTP錯誤400Discord.py create_custom_emojis使用

這裏是我的代碼創建表情符號:

with open("data/emojis/image.png", "rb") as image: 
    image_byte = image.read() 
    emoji = await self.bot.create_custom_emoji(server, name="emo", image=image_byte) 

和錯誤,我得到:

Traceback (most recent call last): 
    File "C:\Program Files (x86)\Python35\lib\asyncio\tasks.py", line 239, in _step 
    result = coro.send(None) 
    File "C:\Users\armel\Downloads\Discord bot\Red-DiscordBot\cogs\moga.py", line 385, in read_feeds 
    message = await self._feed_check(server, chan_id, name, infos) 
    File "C:\Users\armel\Downloads\Discord bot\Red-DiscordBot\cogs\moga.py", line 198, in _feed_check 
    await self.create_custom_emojis(server) 
    File "C:\Users\armel\Downloads\Discord bot\Red-DiscordBot\cogs\moga.py", line 189, in create_custom_emojis 
    emoji = await self.bot.create_custom_emoji(server, name=name, image=image_byte) 
    File "lib\discord\client.py", line 2519, in create_custom_emoji 
    data = yield from self.http.create_custom_emoji(server.id, name, img) 
    File "lib\discord\http.py", line 202, in request 
    raise HTTPException(r, data) 
discord.errors.HTTPException: BAD REQUEST (status code: 400) 

回答

0
image_byte = image.read() 

不要學嘗試t從圖像讀取。它已經是一個像對象一樣的字節。只需將其作爲圖像發送。

emoji = await self.bot.create_custom_emoji(server, name="emo", image=image) 
相關問題