You are on page 1of 3

import discord

import json
import random as rand
import requests
import asyncio
from discord.ext import commands
import os

bot = commands.Bot(command_prefix = "!", intents = discord.Intents.all())


bot.remove_command( 'help' )
os.chdir("C:\\Users\\User\\Desktop\\test botik")

@bot.event
async def on_ready():
print("запустился!")

@bot.command(aliases = ['пена'])
async def ping(ctx):
await ctx.send("ненада")

@bot.event
async def on_message_edit(before, after):
if before.content == after.content:
return
await before.channel.send(f"Сообщение было изменено!\n{before.content} ->
{after.content}")

@bot.command()
async def мем(ctx):
response = requests.get('https://some-random-api.ml/meme')
json_data = json.loads(response.text)
embed = discord.Embed(color = 0x006400, title = '🤣')
embed.set_image(url = json_data ['image'])
await ctx.send(embed = embed)

@bot.command()
async def собака(ctx):
response = requests.get('https://some-random-api.ml/img/dog')
json_data = json.loads(response.text)
embed = discord.Embed(color = 0x8B4513, title = '❤')
embed.set_image(url = json_data ['link'])
await ctx.send(embed = embed)

@bot.command()
async def кот(ctx):
response = requests.get('https://some-random-api.ml/img/cat')
json_data = response.json()
embed = discord.Embed(color = 0xF0E68C, title = '❤')
embed.set_image(url = json_data ['link'])
await ctx.send(embed = embed)

@bot.command()
async def рандом(ctx, num1 = None, num2 = None):
author= ctx.message.author
avatar = author.avatar_url
if num1 != None:
if num2 != None:
x = int(num1)
y = int(num2)
if x < y:
value = rand.randint(x,y)
embed=discord.Embed(title='Случайное число',
description=f'{author.mention}, вот ваше число: \n**{value}**')
embed.set_author(name=f"{author}", icon_url=f"{avatar}")
await ctx.send(embed=embed)
else:
await ctx.send("Первое число больше второго")
else:
await ctx.send('Вы не ввели наибольшее число!')
else:
await ctx.send('Вы не ввели наименьшее число')

@bot.command()
async def инфо(ctx):
embed = discord.Embed(title="Grapper", description="БОТЯРА для сервера.",
color=0xeee657)
embed.add_field(name="Автор", value="<Zernovoy#0004>")
embed.add_field(name="Сервера", value=f"{len(bot.guilds)}")
embed.add_field(name="Приглашение:",
value="[приглашение](<https://discord.gg/ac9cfyTfM2>)")
await ctx.send(embed=embed)

@bot.command()
async def баланс(self,ctx):
await self.open_account(ctx_author)
user = ctx.author
users = await get_bank_data()

wallet_amt = users[str(user.id)]["wallet"]
bank_amt = users[str(user.id)]["bank"]

em = discord.Embed(title = f"{ctx.author.name}'s balance",color =


discord.color.red())
em.add_field(name = "Wallet balance",value = wallet_amt)
em.add_field(name = "Bank balance",value = bank_amt)
await ctx.send(embed = em)

@bot.command()
async def beg(self,ctx):
await self.open_account(ctx.author)

users = await get_bank_data()

user = ctx.author

earnings = random.randrange(101)

await ctx.send(f"Кто-то дал тебе {earnings} монет!")


users[str(user.id)]["wallet"] +=earnings

with open("mainbank.json","w") as f:
json.dump(users,f)

async def open_account(user):

users = await get_bank_data()

if str(user.id) in users:
return False
else:
users[str(user.id)]["wallet"] = 0
users[str(user.id)]["bank"] = 0

with open("mainbank.json","w") as f:
json.dump(users,f)
return True

async def get_bank_data():


with open("mainbank.json","r") as f:
users = json.load(f)

bot.run("ODYzMTcwOTk1MDg3MDgxNDcz.YOjAog.8QnHz5QTPmAKmpBlsZxe8zn3uu4")

You might also like