Advertisement
misiekii123

CoinsDiscordBot

Jan 15th, 2022 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. from discord import utils
  4. from discord import Embed
  5. from discord import activity
  6.  
  7. TOKEN = 'ODM2NTIxOTAwMTA4ODA4MjEz.YIfNug.oWr0wycw0c_MlCzkXImufhrAbhU'
  8.  
  9. bot = commands.Bot(command_prefix='!')
  10. client = discord.Client()
  11. bot.remove_command('help')
  12.  
  13.  
  14. @bot.event
  15. async def on_ready():
  16.     await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="!coins"))
  17.     print('Connected to bot: {}'.format(bot.user.name))
  18.     print('Bot ID: {}'.format(bot.user.id))
  19.     print('Ready\n')
  20.  
  21.  
  22. @bot.command()
  23. async def coins(ctx):
  24.     user = ctx.author.id
  25.     with open(str(user) + ".txt", "a+") as FileWithCoinsValue:
  26.         print(FileWithCoinsValue.readline(0))
  27.         CoinsValue = FileWithCoinsValue.readline(0)
  28.         IntCoinsValue = 0
  29.  
  30.         if FileWithCoinsValue.readline(0) is None:
  31.             FileWithCoinsValue.write("0")
  32.         else:
  33.             IntCoinsValue = int(CoinsValue)
  34.             IntCoinsValue += 1000
  35.             FileWithCoinsValue.readline(0).replace(FileWithCoinsValue.readline(0), str(IntCoinsValue))
  36.  
  37.         embed = Embed(title="Coins")
  38.         embed.add_field(name="You are using `!coins` command", value='Your coins: ' + str(IntCoinsValue))
  39.  
  40.         await ctx.send(embed=embed)
  41.  
  42. bot.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement