Пример #1
0
            else:

                activity_name = "No Activity"
                activity_type = "No Activity"

            l[str(a)] = {
                "username": str(a),
                "name": str(a.name),
                "id": a.id,
                "avatar_url": str(a.avatar_url),
                "activity": {
                    "name": str(activity_name),
                    "type": str(activity_type)
                },
                "status": str(a.status)
            }

    with open("data/bots.json", "w") as f:

        json.dump(l, f, indent=4)

    with open("data/logs.txt", "a") as f:

        f.write(
            f"\n[{datetime.datetime.now().strftime('%d %B %Y [%I:%M:%S %p]')}] - Updated bots.json"
        )


keep_alive()
client.run(os.environ.get("token"))
Пример #2
0
        )
        msg = await bot.wait_for('message', check=check)
        if msg.content not in ['y', 'n']:
            raise ValueError('Type y or n only')
        if msg.content == 'y':
            index = all_gatherings.index(selected_gathering)
            del db['gatherings'][index]
            await ctx.send('Circled Deleted')
            time.sleep(2)
            await ctx.invoke(bot.get_command('clear'))
    except (ValueError, IndexError) as e:
        await ctx.send(f'Error: {str(e)}\nEXITING COMMAND')


# Delete all messages that don't start with '!'
@bot.event
async def on_message(message):
    if message.author.bot:
        return
    scheduling_channel = discord.utils.get(
        bot.get_all_channels(), name='schedule-a-coin-session'
    )
    if (message.channel == scheduling_channel) and not (
        message.content.startswith('!')
    ):
        await message.delete()
    await bot.process_commands(message)

server.keep_alive()
bot.run(TOKEN)