def on_ready():
print("discord.py version: {}".format(discord.__version__))
print('Running script as: {}#{}({})'.format(bot.user.name, bot.user.discriminator, bot.user.id))
print('------------------------------------------------------------------')
if not hasattr(bot, 'game_name'):
bot.game_name = None
if not hasattr(bot, 'status'):
bot.status = discord.Status.online
await bot.change_presence(status=bot.status)
# reset these to empty list
bot.log_servers = []
bot.log_private_channels_list = []
if bot.log_all_messages_on_start:
print("Beginning to dump previous messages to log...")
log.info("====================== Dumping Previous Messages ======================")
# first log all servers and channels in servers
for server in bot.servers:
for channel in server.channels:
permissions = channel.permissions_for(server.get_member(bot.user.id))
if all(getattr(permissions, perm, None) == True for perm in ["read_messages", "read_message_history"]):
async for message in bot.logs_from(channel, limit=bot.message_channel_max):
log_message(message)
# now the same for PrivateChannels
for channel in bot.private_channels:
async for message in bot.logs_from(channel, limit=bot.message_channel_max):
log_message(message)
log.info("====================== End Previous Message Dump ======================")
print("Finished dumping previous messages!")
评论列表
文章目录