discord bot code basic
import discord
from discord.ext import commands
import os, sqlite3
import random
from discord.ext import commands
import os, sqlite3
import random
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
coins = 0
coins1 = 1
coins12 = 12
coins1 = 1
coins12 = 12
'''connection = sqlite3.connect('Abot.db')
cursor = connection.cursor()'''
@bot.event
async def on_ready():
print('Bot is ready')
cursor = connection.cursor()'''
@bot.event
async def on_ready():
print('Bot is ready')
global base, cur
base = sqlite3.connect('Abot.db')
cur = base.cursor()
if base:
print('DataBase connected...OK')
base = sqlite3.connect('Abot.db')
cur = base.cursor()
if base:
print('DataBase connected...OK')
#фрази
@bot.command()
async def golos(ctx):
await ctx.send('го голос?')
@bot.command()
async def replay(ctx, *, arg):
await ctx.send(arg)
async def replay(ctx, *, arg):
await ctx.send(arg)
@bot.command()
async def no(ctx):
await ctx.send('ні')
async def no(ctx):
await ctx.send('ні')
@bot.command()
async def yes(ctx):
await ctx.send('Так')
async def yes(ctx):
await ctx.send('Так')
@bot.command()
async def author(ctx):
await ctx.send('Artem Karabinovych')
async def author(ctx):
await ctx.send('Artem Karabinovych')
@bot.command()
async def яс(ctx):
await ctx.send('Як спрaви?')
@bot.command()
async def яу(ctx):
await ctx.send('Як успіxи?')
async def яу(ctx):
await ctx.send('Як успіxи?')
@bot.command()
async def у(ctx):
await ctx.send('Удaчі!')
async def у(ctx):
await ctx.send('Удaчі!')
@bot.command()
async def добр(ctx):
await ctx.send('Добрий ранок!')
async def добр(ctx):
await ctx.send('Добрий ранок!')
@bot.command()
async def добд(ctx):
await ctx.send('Добрий день!')
async def добд(ctx):
await ctx.send('Добрий день!')
@bot.command()
async def добв(ctx):
await ctx.send('Добрий вечір!')
async def добв(ctx):
await ctx.send('Добрий вечір!')
@bot.command()
async def мб(ctx):
await ctx.send('Менш більш')
async def мб(ctx):
await ctx.send('Менш більш')
@bot.command()
async def к(ctx):
await ctx.send('Круто!')
async def к(ctx):
await ctx.send('Круто!')
@bot.command()
async def п(ctx):
await ctx.send('Прикольно!')
async def п(ctx):
await ctx.send('Прикольно!')
@bot.command()
async def ок(ctx):
await ctx.send('ОК')
async def ок(ctx):
await ctx.send('ОК')
@bot.command()
async def gg(ctx):
await ctx.send('GG')
async def gg(ctx):
await ctx.send('GG')
@bot.command()
async def н(ctx):
await ctx.send('Нормально')
async def н(ctx):
await ctx.send('Нормально')
@bot.command()
async def хз(ctx):
await ctx.send('Хз')
async def хз(ctx):
await ctx.send('Хз')
@bot.command()
async def пр(ctx):
await ctx.send('Привiт!')
async def пр(ctx):
await ctx.send('Привiт!')
@bot.command()
async def cube(ctx):
author = ctx.message.author
x = random.randint(1,6)
await ctx.send(f'{author.mention} {x}')
async def cube(ctx):
author = ctx.message.author
x = random.randint(1,6)
await ctx.send(f'{author.mention} {x}')
@bot.command()
async def dcube(ctx):
global coins
author = ctx.message.author
x = random.randint(1,6)
y = random.randint(1,6)
coinss = x+y
coinsss = x+y
jackpot = coinsss*9
if coinsss == x+y:
coins = coins+coinsss
if x+y == 12:
coins = coins + jackpot
await ctx.send(f'{author.mention} {x};{y} = {x+y} \n Server balance: {coins}')
async def dcube(ctx):
global coins
author = ctx.message.author
x = random.randint(1,6)
y = random.randint(1,6)
coinss = x+y
coinsss = x+y
jackpot = coinsss*9
if coinsss == x+y:
coins = coins+coinsss
if x+y == 12:
coins = coins + jackpot
await ctx.send(f'{author.mention} {x};{y} = {x+y} \n Server balance: {coins}')
@bot.command()
async def team(ctx):
author = ctx.message.author
await ctx.send('Artem Karabinovych - developer, Yan - alpha-tester, Kolya - alpha-tester')
async def team(ctx):
author = ctx.message.author
await ctx.send('Artem Karabinovych - developer, Yan - alpha-tester, Kolya - alpha-tester')
#info
@bot.command()
async def info(ctx, arg=None):
author = ctx.message.author
if arg == None:
await ctx.send(f'{author.mention} Введи \n !info all \n !info commands \n !info фрази')
elif arg == 'all':
await ctx.send(f'{author.mention} Правила: ...')
elif arg == 'commands':
await ctx.send(f'{author.mention} Команди: \n !replay - потвторює слова написані після команди в одному повідомленні \n !no - бот відповідає (ні)\
\n !yes - бот відповідає (так) \n !golos - бот відповідає (го голос?) \n !author - автор\
\n !team - розробники бота \n !cube - кубик рандомно висвітлює значення від 1 до 6 \n !dcube - кубики(2) рандомно висвітлюють значення від 1 до 6')
elif arg == 'фрази':
await ctx.send(f'{author.mention} Фрази: \n !яс - як спрaви? \n !яу - як успiхи? \n !у - удачi \n !добр - добрий ранок \n !добд - добрий день \n !добв - добрий вечір \n !мб - менш більш \n !к - круто \n !п - прикольно\
\n !ок - ОК \n !gg - GG \n !н - Нoрмально \n !хз - хз \n !пр - Привiт ')
else:
await ctx.send(f'{author.mention} Не намахуй мене, немає такої команди')
@bot.command()
async def info(ctx, arg=None):
author = ctx.message.author
if arg == None:
await ctx.send(f'{author.mention} Введи \n !info all \n !info commands \n !info фрази')
elif arg == 'all':
await ctx.send(f'{author.mention} Правила: ...')
elif arg == 'commands':
await ctx.send(f'{author.mention} Команди: \n !replay - потвторює слова написані після команди в одному повідомленні \n !no - бот відповідає (ні)\
\n !yes - бот відповідає (так) \n !golos - бот відповідає (го голос?) \n !author - автор\
\n !team - розробники бота \n !cube - кубик рандомно висвітлює значення від 1 до 6 \n !dcube - кубики(2) рандомно висвітлюють значення від 1 до 6')
elif arg == 'фрази':
await ctx.send(f'{author.mention} Фрази: \n !яс - як спрaви? \n !яу - як успiхи? \n !у - удачi \n !добр - добрий ранок \n !добд - добрий день \n !добв - добрий вечір \n !мб - менш більш \n !к - круто \n !п - прикольно\
\n !ок - ОК \n !gg - GG \n !н - Нoрмально \n !хз - хз \n !пр - Привiт ')
else:
await ctx.send(f'{author.mention} Не намахуй мене, немає такої команди')
#вчу бота говорити
@bot.event
async def on_message(message):
if 'дела' in message.content.lower():
await message.channel.send('норм')
if 'справи' in message.content.lower():
await message.channel.send('норм')
if 'життя' in message.content.lower():
await message.channel.send('Яке прекрасне жииииииииииття')
if 'удачі' in message.content.lower():
await message.channel.send('тобі також')
if 'привіт' in message.content.lower():
await message.channel.send('Хаай')
if 'привет' in message.content.lower():
await message.channel.send('Хаай')
if 'хай' in message.content.lower():
await message.channel.send('Хаай')
if 'hi' in message.content.lower():
await message.channel.send('Хаай')
if 'hello' in message.content.lower():
await message.channel.send('Хаай')
if 'бай' in message.content.lower():
await message.channel.send('Чаао')
if 'bye' in message.content.lower():
await message.channel.send('Чаао')
if 'чао' in message.content.lower():
await message.channel.send('Чаао')
if 'хах' in message.content.lower():
await message.channel.send(')')
await bot.process_commands(message)
bot.run(os.getenv('TOKEN'))
async def on_message(message):
if 'дела' in message.content.lower():
await message.channel.send('норм')
if 'справи' in message.content.lower():
await message.channel.send('норм')
if 'життя' in message.content.lower():
await message.channel.send('Яке прекрасне жииииииииииття')
if 'удачі' in message.content.lower():
await message.channel.send('тобі також')
if 'привіт' in message.content.lower():
await message.channel.send('Хаай')
if 'привет' in message.content.lower():
await message.channel.send('Хаай')
if 'хай' in message.content.lower():
await message.channel.send('Хаай')
if 'hi' in message.content.lower():
await message.channel.send('Хаай')
if 'hello' in message.content.lower():
await message.channel.send('Хаай')
if 'бай' in message.content.lower():
await message.channel.send('Чаао')
if 'bye' in message.content.lower():
await message.channel.send('Чаао')
if 'чао' in message.content.lower():
await message.channel.send('Чаао')
if 'хах' in message.content.lower():
await message.channel.send(')')
await bot.process_commands(message)
bot.run(os.getenv('TOKEN'))