Python 我的webhook脚本中的message\member有问题
我已经为聊天服务编写了一个python脚本 执行脚本时,收到以下错误: raise TypeError(类型为{o.class.name}的对象) TypeError:消息类型的对象不可JSON序列化 我无法解决此问题。以下是我正在使用的代码Python 我的webhook脚本中的message\member有问题,python,python-3.x,discord,webhooks,discord.py,Python,Python 3.x,Discord,Webhooks,Discord.py,我已经为聊天服务编写了一个python脚本 执行脚本时,收到以下错误: raise TypeError(类型为{o.class.name}的对象) TypeError:消息类型的对象不可JSON序列化 我无法解决此问题。以下是我正在使用的代码 import discord from discord.ext import commands import random from discord.ext.commands import Bot import asyncio import time im
import discord
from discord.ext import commands
import random
from discord.ext.commands import Bot
import asyncio
import time
import logging
import http.client
import aiml
import asyncio
from datetime import datetime, timedelta
import os
import pkg_resources
import logging
import logging.config
import sqlite3
import youtube_dl as ytdl
from discord_webhook import DiscordWebhook, DiscordEmbed
import time
import aiohttp
import importlib
import sys
import client
bot = commands.Bot(command_prefix='!', description=description)
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
await bot.change_presence(status=discord.Status.idle, activity=discord.Game('robie placki z Ufoludem (prefix?!)'))
webhook_urls = ['url1', 'url2']
@bot.event
async def on_message(message):
channels = [":arrow_lower_right:globalny:arrow_lower_left:"]
for word in channels:
await message.delete()
response = DiscordWebhook(url=webhook_urls, content=message).execute()
请让我知道我哪里出了问题。当前遇到此问题。有任何解决此问题的建议吗?
message
是一个message
对象,message。content
是您要查找的字符串
response = DiscordWebhook(url=webhook_urls, content=message.content).execute()