Skip to content

Instantly share code, notes, and snippets.

@ErikBigDev
Created June 10, 2020 15:19
Show Gist options
  • Save ErikBigDev/06c404e18ffdd8fc2dee4b6aa026eed0 to your computer and use it in GitHub Desktop.
Save ErikBigDev/06c404e18ffdd8fc2dee4b6aa026eed0 to your computer and use it in GitHub Desktop.
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