Created
June 10, 2020 15:19
-
-
Save ErikBigDev/06c404e18ffdd8fc2dee4b6aa026eed0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
import atexit | |
from discord.ext import commands | |
from configparser import ConfigParser | |
def exit_handler(): | |
print('My application is ending!') | |
client = commands.Bot(command_prefix = '!') | |
counter = 0 | |
config = ConfigParser() | |
@client.event | |
async def on_ready(): | |
atexit.register(exit_handler) | |
global counter | |
global config | |
config.read('count.ini') | |
counter = config.getint('main', 'count') | |
print('ready') | |
@client.command() | |
async def count(ctx): | |
global counter | |
global config | |
await ctx.send(counter) | |
counter = counter + 1 | |
config.set('main', 'count', str(counter)) | |
with open('count.ini', 'w') as f: | |
config.write(f) | |
client.run('NzIwMjYxODQzMzE4MjEwNjAw.XuDcDQ.I_LGJvcdUomeZCKqEDlJgIq5-qo') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment