import discord
from discord.ext import commands
import asyncio
from itertools import cycle
import time
import random
import aiohttp
import json
TOKEN = 'tokeni buraya yazın'
client = commands.Bot(command_prefix='.') #Buraya hangi prefixi kullanıcağınızı girin
<14>@client.event
async def on_ready():
print("Bot hazır.")
await client.change_presence(game=discord.Game(name='.help')) #bot çalıştığında hangi oyunu oynuyor görünsün
<18>@client.event
async def on_message(message):
author = message.author
content = message.content
print('{}: {}'.format(author, content))
await client.process_commands(message)
"""
Burası çok önemli değil bir mesaj silindiğinde ne
<28>@client.event
async def on_message_delete(message):
kim = message.author
mesajicerik = message.content
kanal = message.channel
await client.send_message(kanal, '{} : {}'.format(kim, mesajicerik))
await client.process_commands(message)"""
<37>@client.event
#Girişte hangi perm verilsin
async def on_nember_join(kullanıcı):
perm = discord.utils.get(nember.server.roles, name='test')
await client.add.roles(kullanıcı, perm)
<44>@client.command()
#Basit kod bloğu
async def ping():
await client.say('Pong')
<49>@client.command()
# .echo yazarak bota istediğinizi yazdırın
async def echo(*args):
çıktı = ''
for yazı in args:
çıktı += yazı
çıktı += ' '
await client.say(çıktı)
<58>@client.command(pass_context=True)
#.clear ile çoklu mesaj silme
async def clear(ctx, amount=100):
channel = ctx.message.channel
messages = []
async for message in client.logs_from(channel, limit=int(amount)):
messages.append(message)
await client.delete_messages(messages)
await client.say("Mesajlar silindi.")
#8ball oyunu
<68>@client.command(name='8ball', description="Evet/Hayır soru cevaplar.", brief="Öteden cevaplar.", aliases=['eight_ball', 'eightball', '8-ball'], pass_context=True)
async def eight_ball(icerik):
possible_responses = ['Bu bir yankılanan hayır', 'Olası görünmüyor', 'Söylemek çok zor', 'Oldukça mümkündür', 'Kesinlikle',]
await client.say(random.choice(possible_responses) + ", " + icerik.message.author.mention)
#bitcoin anlık değer
<73>@client.command()
async def bitcoin():
api = 'https://api.coindesk.com/v1/bpi/currentprice/BTC.json'
async with aiohttp.ClientSession() as session:
raw_response = await session.get(api)
response = await raw_response.text()
response = json.loads(response)
await client.say("Bitcoin Şu an: $" + response['bpi']['USD']['rate'])
client.run(TOKEN)