【发布时间】:2022-01-17 22:06:10
【问题描述】:
每当我尝试运行我的程序时,我都会收到此错误,我尝试为其授予除管理员之外的所有可能的权限,但它仍然无法运行,它仅在我授予它管理员权限时运行,
错误发生在 on_ready 事件上
这是我的代码
@client.event
async def on_ready():
print('------')
print('Online! Details:')
print(f"Bot Username: {client.user.name}")
print(f"BotID: {client.user.id}")
print('------')
data = pd.DataFrame(columns=['channel','author'])
text_channel_list = []
for i in guild:
g = client.get_guild(i)
for channel in g.channels:
if str(channel.type) == 'text':
text_channel_list.append(channel)
for j in text_channel_list:
channel = client.get_channel(j.id)
async for msg in channel.history(limit=100000):
if msg.author != client.user:
data = data.append({'channel':msg.channel.name,
'author': msg.author}, ignore_index=True)
if len(data) == 100000:
break
file_location = "data.csv"
data.to_csv(file_location)
await asyncio.sleep(60)
client.loop.create_task(on_ready())
这是错误
------
Online! Details:
Bot Username: Giveaway Bot Dev
BotID: 920320119878602752
------
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\hires\AppData\Roaming\Python\Python39\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "d:\Freelance Giveaway Bot\main.py", line 95, in on_ready
async for msg in channel.history(limit=100000):
File "C:\Users\hires\AppData\Roaming\Python\Python39\site-packages\discord\iterators.py", line 91, in __anext__
msg = await self.next()
File "C:\Users\hires\AppData\Roaming\Python\Python39\site-packages\discord\iterators.py", line 285, in next
await self.fill_messages()
File "C:\Users\hires\AppData\Roaming\Python\Python39\site-packages\discord\iterators.py", line 328, in fill_messages
data = await self._retrieve_messages(self.retrieve)
File "C:\Users\hires\AppData\Roaming\Python\Python39\site-packages\discord\iterators.py", line 348, in _retrieve_messages_before_strategy
data = await self.logs_from(self.channel.id, retrieve, before=before)
File "C:\Users\hires\AppData\Roaming\Python\Python39\site-packages\discord\http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
【问题讨论】:
标签: python discord discord.py