How can i keep track of how many times has a command been typed in discord

  discord, python

So I am making a bot and I wanted to have a game with some default values for the players when they join or the game is played for the first time on the server. So I can keep track of each player’s values.

Logic of the game:
the player has some values like coins,power,speed and brain
you can level them up by spending your coins on the power up’s
code:

# imports
import discord
import os
from discord import user
from discord import activity
from discord.ext import commands, tasks
from itertools import cycle
import random
# prefix
client = commands.Bot(command_prefix=",")
status = cycle(['spedrunning mincraft for the 100 time',
               'trololol', 'working on bugs', 'learning from dream'])
meme_list = ['https://i.pinimg.com/736x/62/bf/0d/62bf0d6b9ccd73f5e15aad8fa1d6163c.jpg',
'https://s3.india.com/wp-content/uploads/2019/02/valentines.jpg',
'https://img.delicious.com.au/WqbvXLhs/del/2016/06/more-the-merrier-31380-2.jpg',
'https://image.scoopwhoop.com/w960-h500-cfix/https://s4.scoopwhoop.com/anj/feat/941432013.jpg',
'https://perfectdaytoplay.com/wp-content/uploads/2020/05/Travel-funny-meme-covid19-pandemic-joke-humor-38.jpg',
'https://i.ytimg.com/vi/VrM-JkDnwiI/maxresdefault.jpg',
'https://i.ytimg.com/vi/zKxMTovmPN4/maxresdefault.jpg',
'https://i.imgur.com/k3pFRXd.jpg',
'https://starecat.com/content/wp-content/uploads/cats-and-dog-when-you-hold-your-hand-above-them-minecraft.jpg',
' https://i.pinimg.com/originals/1b/14/c3/1b14c30f94391830768d334f9234e412.jpg',
'https://i.pinimg.com/736x/a0/eb/34/a0eb3405be3afd0c622caf45b80fb4c7.jpg',
'https://static0.srcdn.com/wordpress/wp-content/uploads/2020/03/HarryPotterMemeHeader.jpg',
'https://i.pinimg.com/originals/6f/46/4f/6f464f022adadff6e831ecf54586a681.jpg',
'https://media.npr.org/assets/img/2015/03/03/overly_custom-39399d2cf8b6395770e3f10fd45b22ce39df70d4-s800-c85.jpg',
'https://cms.qz.com/wp-content/uploads/2018/07/meme-featured.jpg?qual75&stal41215',
'https://static.mommypoppins.com/styles/image620x420/s3/school_meme_3_0.jpg'
'https://s.yimg.com/ny/api/res/1.2/_twsNG4z4ENpWE7ZXoCJ2Q--/YXBwaWQ9aGlnaGxhbmRlcjt3PTk2MDtoPTk1OC4zNjE3NzQ3NDQwMjczO2NmPXdlYnA-/https://s.yimg.com/os/creatr-uploaded-images/2021-05/5d4f3960-acc5-11eb-bbff-5305b55ded14',
'https://i.imgflip.com/5c74jb.jpg',
'https://imgflip.com/i/5c74rc',
'https://imgflip.com/i/5c7539',
'https://imgflip.com/i/5c75bl',
'https://imgflip.com/i/5cx3vk',
'https://imgflip.com/i/5cx4ky',
'https://imgflip.com/i/5cx5io',

]

@client.event
async def on_ready():
    change_status.start()
    print("bot running ")


@tasks.loop(seconds=3600)
async def change_status():
    await client.change_presence(activity=discord.Game(next(status)))


@client.command()
async def info(ctx):
    await ctx.send('commands prefix is Blaeam  ,clear <amount> clears the amount that you puted ,kick,ban')
@client.command()
async def meme(ctx):
    await ctx.send(random.choice(meme_list))


@client.command()
async def clear(ctx, amount=5):
    await ctx.channel.purge(limit=amount)
    await ctx.send(f'Cleared {amount} message(s)')

def default_stats(coins,power,speed,brain):
 coins=100
 power=10
 speed=10
 brain=5



@client.command()
async def start (ctx):
  await ctx.send(' the game started ')
  await ctx.send('This game is called power apps.'+'In this game you have coins, power, speed, brain.'+'You can level up your skills by spending coins on the skils'+'To do that you can type -->play<amount of coins>_power, speed, brain '+'How to get coins.'+'You can get coins by battling other players by typing the command battle_<member name >')
  


@client.command()
async def play_power(ctx, member: discord.Member):
  await ctx.send('{member.name}put ten of his coins to power')
  #TODO:add game here 


@client.command()
async def kick(ctx, member: discord.Member, *, reason=None):
    await member.kick(reason=reason)
    await ctx.send(f'Kicked {member.name} from the server!')


@client.command()
async def ban(ctx, member: discord.Member, *, reason=None):
    await member.ban(reason=reason)
    await ctx.send(f'Banned {member.name} from the server!')


client.run(Token)```
If you have any ideas tell me.
You can also find this project on replit [https://replit.com/@YoLoGRAlex/Bleam#main.py][1]


  [1]: https://replit.com/@YoLoGRAlex/Bleam#main.py

Source: Python Questions

LEAVE A COMMENT