Answer the question
In order to leave comments, you need to log in
What are the minimum characteristics that a simple bot based on discord.py should have to work properly?
I need to run a bot based on discord.py 24/7
for this I want to use a VPS
and I need to understand if the characteristics of my tariff are suitable for the bot to work.
My plan features:
CPU:2x3.0 GHz
RAM:2gb
Disk(HDD):80 GB
1 IPv4 IP address and 1 IPv6 IP address
Channel: 1 Gbps
Traffic: unlimited
my code :
import datetime
import random
import sqlite3
import discord
from discord.ext import commands
from datetime import datetime
import time
from datetime import date
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='D.', intents=intents)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_member_join(member):
con = sqlite3.connect('mydatabase.db')
cursorObj = con.cursor()
cursorObj.execute('create table if not exists now(id INTEGER, rawexp INTEGER, date DATE, level INTEGER)')
userdate = datetime.now()
userid = member.author.id
userrawexp = 0
userlevel = 1
cursorObj.execute("INSERT INTO now VALUES(?, ?, ?, ?);", (userid, userrawexp, userdate, userlevel))
con.commit()
@client.event
async def on_message(message):
if message.author == client.user:
return
if len(message.content) > 19:
now_re = len(message.content)
now_re = now_re // 20
userid = message.author.id
con = sqlite3.connect('mydatabase.db')
cursorObj = con.cursor()
cursorObj.execute('create table if not exists now(id INTEGER, rawexp INTEGER, date DATE, level INTEGER)')
cursorObj.execute(f"SELECT rawexp FROM now where id = ? ",(int(userid),))
old_re = cursorObj.fetchone()
old_re = old_re[0]
now_re = now_re + int(old_re)
cursorObj.execute('UPDATE now SET rawexp = ? where id = ?',(now_re,userid))
cursorObj.execute(f"SELECT date FROM now where id = ? ",(int(userid),))
userdate = cursorObj.fetchone()
userdate = userdate[0]
userdate = datetime.strptime(userdate, '%Y-%m-%d %H:%M:%S.%f')
userdate = userdate.date()
tn = datetime.now()
tn = date(2022,12,12)
delta = tn - userdate
dos = (delta.days)
dos = abs(dos)
cursorObj.execute(f"SELECT level FROM now where id = ? ",(int(userid),))
level = cursorObj.fetchone()
level = level[0]
level = int(level)
wc = level
befnl = 50
btfnl = 1
el = level
print("wc:",wc,"level:",level,"dos:",dos,"tn:",tn,"befnl:",befnl,"btfnl:",btfnl,"now_re:",now_re)
while wc != 0:
print("wc:",wc,"level:",level,"dos:",dos,"tn:",tn,"befnl:",befnl,"btfnl:",btfnl,"now_re:",now_re)
befnl = befnl * 2
btfnl = btfnl * 1.5
if dos >= btfnl:
if now_re >= befnl:
el = el + 1
wc = wc - 1
cursorObj.execute('UPDATE now SET level = ? where id = ?',(el,userid))
con.commit()
await client.process_commands(message)
@client.command()
async def тестдатабазы(ctx):
con = sqlite3.connect('mydatabase.db')
cursorObj = con.cursor()
a = ctx.author.id
print(a)
cursorObj.execute(f"SELECT * FROM now")
d = cursorObj.fetchall()
await ctx.send(f'{d}')
@client.command()
async def НУЧ(ctx):
con = sqlite3.connect('mydatabase.db')
cursorObj = con.cursor()
cursorObj.execute('create table if not exists now(id INТЕGER, rawexp INTEGER, date DATE, level INTEGER)')
a = ctx.author.id
cursorObj.execute(f"SELECT * FROM now where id = ? ",(int(a),))#проверка, существует ли участник в БД
if cursorObj.fetchone() != None:
cursorObj.execute('DELETE from now where id = ? ',(int(a),))
userdate = datetime.now()
userid = ctx.author.id
userrawexp = 0
userlevel = 1
cursorObj.execute("INSERT INTO now VALUES(?, ?, ?, ?);", (userid, userrawexp, userdate, userlevel))
else:
userdate = datetime.now()
userid = ctx.author.id
userrawexp = 0
userexp = 0
userlevel = 1
cursorObj.execute("INSERT INTO now VALUES(?, ?, ?, ?);", (userid, userrawexp, userdate, userlevel))
con.commit()
@client.command()
async def время(ctx):
now = datetime.now()
s = now.time()
await ctx.send(f'{s}')
@client.command()
async def DaElBP1(ctx):
a = datetime.now()
b = datetime.now()
first_date = a.date()
second_date = b.date()
delta = second_date - first_date
print(delta)
@client.command()
async def примитивныйкалькулятор(ctx,arg1,arg2,arg3):
a = arg1
b = arg2
c = arg3
if (b) == "*" :
a = int(a) * int(c)
else:
if (b) == "+":
a = int(a) + int(c)
else:
if (b) == "-":
a = int(a) + int(c)
else:
if (b) == "/":
a = int(a) / int(c)
await ctx.send(f'{int(a)}')
client.run('MyToken')
Answer the question
In order to leave comments, you need to log in
For a simple bot will be enough:
CPU 1 x 3.3 GHz
RAM 1 GB
NVME 10 GB
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question