Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import discord ##for discord
from discord.ext import commands ## for discord
import json # for json files
import requests ## for API
import random
import secrets ## for API keys
import botfunctions as bf ## for botfunctions.py functions
## setting intents for discord bot#
intents = discord.Intents.default()
intents.message_content = True
## setting bot prefix#
bot = commands.Bot(command_prefix='!',intents=intents, case_insensitive=True, help_command=None)
@bot.event
async def on_ready():
## logging bot is ready to use in console
print('Bot is now online!')
## setting bot status message
await bot.change_presence(activity=discord.Game(name=f'Hi! I am {bot.user.name}. Please use ! to interact with me!'))
@bot.event
async def on_message(message):
## wait to see if its a command first
await bot.process_commands(message)
## on message event - setting so the bot doesnt reply to its own message
if message.author == bot.user:
return
## chatbot logic needs to be somwehre else later
## users sends a message
## run a check if message had 'most played' in it
## sends a question back about summoner
## waits for reply and uses that so bring most played data
if 'most played' in message.content:
channel = message.channel
await channel.send('Whats your summoner name?')
def check(m):
return message.content
msg = await bot.wait_for('message', check=check)
## embed results
champions = bf.get_top5(msg.content)
top5 = discord.Embed(title=f'{msg.content}\'s 5 most played champions:')
pfp = f'http://ddragon.leagueoflegends.com/cdn/12.20.1/img/champion/{champions[0]}.png'
top5.set_thumbnail(url=f'{pfp}')
for champion in champions:
emoji = f'\:{champion}_0:'
top5.add_field(name=f'**{champion}**',value=f'emoji and winrate later',inline=False)
await channel.send(embed = top5)
## users sends a message
## run a check if message had 'most played' in it
## sends a question back about summoner
## waits for reply and uses that so bring most played data
if 'stats' in message.content:
channel = message.channel
await channel.send('Whats your summoner name?')
def check(m):
return message.content
msg = await bot.wait_for('message', check=check)
## embed results
ranked_stats = bf.get_summoner_stats(msg.content)
stats = discord.Embed(title=f'{msg.content}\'s ranked stats')
sender = message.author
name = sender.display_name
pfp = sender.display_avatar
stats.set_thumbnail(url='https://i.postimg.cc/SsX4nyp3/GOLD.png')
stats.add_field(name=f'**Rank**',value=f'{ranked_stats[0]}')
stats.add_field(name=f'**Divison**',value=f'{ranked_stats[1]}')
stats.add_field(name=f'**LP**',value=f'{ranked_stats[2]}')
stats.add_field(name=f'**Winrate**',value=f'{ranked_stats[3]}')
await channel.send(embed = stats)
bot.run(secrets.discord_bot_key)