def color_string(self): if self.color == CardColor.GREY: return get_emoji('white_square') if self.color == CardColor.RED: return get_emoji('red_square') if self.color == CardColor.BLUE: return get_emoji('blue_square')
async def handle(self, params, message, client): # 'params' is a list that contains the parameters that the command # expects to receive, t is guaranteed to have AT LEAST as many # parameters as specified in __init__ # 'message' is the discord.py Message object for the command to handle # 'client' is the bot Client object try: lower_bound = int(params[0]) upper_bound = int(params[1]) except ValueError: await client.send_message(message.channel, "Please, provide valid numbers") return if lower_bound > upper_bound: await client.send_message( message.channel, "The lower bound can't be higher than the upper bound") return rolled = randint(lower_bound, upper_bound) msg = get_emoji(":game_die:") + f" You rolled {rolled}!" await BaseCommand.send_response(msg, message.channel)
async def delete_message_on_reaction(self, payload: RawReactionActionEvent): if payload.emoji.name == get_emoji(':wastebasket:'): message = await (await self.client.fetch_channel( payload.channel_id)).fetch_message(payload.message_id) if message.author.id == self.client.user.id: await message.delete()
async def handle(self, params, message, client): # 'params' is a list that contains the parameters that the command # expects to receive, t is guaranteed to have AT LEAST as many # parameters as specified in __init__ # 'message' is the discord.py Message object for the command to handle # 'client' is the bot Client object try: club_tag = str(params[0]) print(f"Club Tag {club_tag}") except Exception as e: print(e) await client.send_message(message.channel, "Please, provide valid club tag") return brawl_database = database.SQL_Server() if "ClubTag" in brawl_database.return_allUsers(): await client.send_message( message.channel, "The Club has already been linked to the server") return brawl_database.insert_user("ClubTag", club_tag) brawl_database.save_database() msg = get_emoji( ":ok_hand:" ) + f" The Club {club_tag} has been linked to the server" await client.send_message(message.channel, msg)
async def handle(self, params, message, client): # 'params' is a list that contains the parameters that the command # expects to receive, t is guaranteed to have AT LEAST as many # parameters as specified in __init__ # 'message' is the discord.py Message object for the command to handle # 'client' is the bot Client object msg = get_emoji(":middle_finger:") + f" Nejsem nějakej otrok vole, prostě si něco vymsli..." await message.channel.send(msg)
async def handle(self, params, message, client): try: lower_bound = int(params[0]) upper_bound = int(params[9]) except ValueError: await client.send_message(message.channel, "Please, provide valid numbers") return if lower_bound > upper_bound: await client.send_message(message.channel, "The lower bound can't be higher than the upper bound") return rolled = randint(lower_bound, upper_bound) msg = get_emoji(":phuggers:") + f" You rolled {rolled}!" await client.send_message(message.channel, msg)
async def handle(self, params, message, client): try: lower_bound = int(params[0]) upper_bound = int(params[1]) except ValueError: await message.channel.send( "Please, provide valid numbers") return if lower_bound > upper_bound: await message.channel.send( "The lower bound can't be higher than the upper bound") return rolled = randint(lower_bound, upper_bound) msg = get_emoji(":game_die:")+f" **You rolled** {rolled}" await message.channel.send(msg)
async def handle(self, params, message, client): # 'params' is a list that contains the parameters that the command # expects to receive, t is guaranteed to have AT LEAST as many # parameters as specified in __init__ # 'message' is the discord.py Message object for the command to handle # 'client' is the bot Client object brawl_client = brawlstats.Client(self.brawl_api) try: player_tag = str(params[0]) print(player_tag) if player_tag[:1] != "#": raise Exception("Incorrect Player Tag. Be sure to add #") specific_user = brawl_client.get_profile(player_tag) except Exception: await client.send_message(message.channel, "Please, provide valid player tag") return brawl_database = database.SQL_Server() user_name = str(message.author) if user_name in brawl_database.return_allUsers( ) and brawl_database.information_present(user_name): await client.send_message( message.channel, "The User has already been linked to an account") return if player_tag in brawl_database.return_allPlayers(): await client.send_message( message.channel, "The Tag has already been linked to other user") return brawl_database.insert_user(user_name, player_tag) brawl_database.save_database() msg = get_emoji( ":ok_hand:" ) + f" The User {player_tag} has been linked to {user_name} in the database!" await client.send_message(message.channel, msg)
async def handle(self, *params): message = params[1] client = params[2] from message_handler import COMMAND_HANDLERS try: name = "" i = 0 # print(params) while(params[0][i] not in rarities): name += params[0][i] + " " i += 1 rarity = params[0][i] except ValueError: await message.channel.send("Missing name or rarity!") return except IndexError: await message.channel.send(f"{message.author.mention} Missing rarity!") return msg = get_emoji(":crown:") + f"You spawned a {rarity} {name}!" await message.channel.send(msg)
def get_default_emoji(self, emoji: str): return utils.get_emoji(self.bot.get_guild(config.guild_id), emoji)
import asyncio from typing import Collection from discord import Message, Reaction, User, Client from discord.ext.commands import Bot from utils import try_to_clear_reactions, get_emoji DEFAULT_TIMEOUT = 60 TOGGLE_EXPAND_EMOJI = get_emoji(':question_mark:') TOGGLE_COLLAPSE_EMOJI = get_emoji(':x:') TOGGLE_EMOJIS = (TOGGLE_EXPAND_EMOJI, TOGGLE_COLLAPSE_EMOJI) PAGE_NEXT_EMOJI = get_emoji(':arrow_right:') PAGE_PREV_EMOJI = get_emoji(':arrow_left:') PAGE_EMOJIS = (PAGE_NEXT_EMOJI, PAGE_PREV_EMOJI) class InterfaceState: def __init__(self, callback, *args, **kwargs): self.callback = callback self.args = args self.kwargs = kwargs # class EmojiInterfaceState(InterfaceState): # def __init__(self, emoji: str, callback, *args, **kwargs): # super().__init__(callback, *args, **kwargs) # self.emoji = emoji
APPLICATION_REMARKS = 18 # S APPLICATION_PERIOD = 19 # T MEMBER_LIST_NUMBER = 0 MEMBER_LIST_NICKNAME = 1 MEMBER_LIST_STATE = 2 MEMBER_LIST_ID = 3 MEMBER_LIST_JOINED_AT = 4 APPLICATION_RECEIVED = '접수됨' APPLICATION_APPROVED = '승인됨' SECOND_PER_HOUR = 3600 NSFW_TIMEOUT = 60 NSFW_EMOJI = get_emoji(':underage:') CONFIRM_EMOJI = get_emoji(':white_check_mark:') deck_cooldown = shared_cooldown(1, 60, BucketType.category) def get_application_sheet(): sheet = get_constant('application') rows = sheet_read(sheet['sheet_id'], sheet['read_range']) keys = rows.pop(0) for reply in rows: while len(reply) < len(keys): reply.append('') return keys, rows
async def handle(self, params, message, client): try: nick = str(params[0]) except ValueError: await message.channel.send("Please, provide valid numbers") return url = 'https://eune.op.gg/summoner/userName='******'html.parser') l = soup.find("div", {"class": "TierRankInfo"}) SoloDuoRank = [] LpSoloDuo = [] SoloDuoWR = "" for i in l.findAll("div"): SoloDuoRank.append(i.text) for j in l.findAll("span"): LpSoloDuo.append(j.text) if len(LpSoloDuo) == 0: LpSoloDuo.append("Unranked") SoloDuoWR = "-" else: SoloDuoWR = LpSoloDuo[4] else: print("Error") #FLEX if resp.status_code == 200: soup = BeautifulSoup(resp.text, 'html.parser') l = soup.find("div", {"class": "sub-tier"}) FlexRank = [] FlexLp = "" FlexWR = "" for i in l.findAll("div"): FlexRank.append(i.text) if len(FlexRank) > 3: FlexWR = FlexRank[4].lstrip().rstrip() if FlexRank[3][2:3] == "P": FlexLp = FlexRank[3][0:3].strip() elif FlexRank[3][3:4] == "P": FlexLp = FlexRank[3][0:4].strip() elif FlexRank[3][4:5] == "P": FlexLp = FlexRank[3][0:5].strip() else: FlexLp = "Unranked" FlexWR = "-" #NICKNAME if resp.status_code == 200: soup = BeautifulSoup(resp.text, 'html.parser') l = soup.find("div", {"class": "Information"}) Name = "" for i in l.findAll("span", {"class": "Name"}): Name = i.text else: print("Error") # #ROLE / # if resp.status_code==200: # l=soup.find("td",{"class":"PositionStats"}) # RoleArray=[] # for i in l.findAll("div",{"class":"PositionStatContent"}): # RoleArray.append(i.text) # else: # print("Error") # print(RoleArray[0]) # print(RoleArray[1]) await message.channel.send( get_emoji(":trophy:") + f"** Nickname: **" + Name + "\n" + get_emoji(":small_orange_diamond:") + f"** Solo/Duo Rank: **" + SoloDuoRank[1].strip() + "\t" + get_emoji(":small_orange_diamond:") + f"** Points: **" + LpSoloDuo[0].strip() + "\t" + get_emoji(":small_orange_diamond:") + f"** Win Rate: **" + SoloDuoWR[len(SoloDuoWR) - 4:len(SoloDuoWR)] + "\n" + get_emoji(":small_orange_diamond:") + f"** Flex Rank: **" + FlexRank[2].strip() + "\t" + get_emoji("::small_orange_diamond:") + f"** Points: **" + FlexLp + "\t" + get_emoji("::small_orange_diamond:") + f"** Win Rate: **" + FlexWR[len(FlexWR) - 4:len(FlexWR)] + "\n" # +get_emoji(":small_orange_diamond:")+f"** Main Role: **" +RoleArray[0]+"\n"+ # get_emoji(":small_orange_diamond:")+f"** Sub Role: **" +RoleArray[1]+"\n" )
import asyncio from random import randrange from typing import Dict, List, Optional from discord import Message, User, Reaction from discord.ext.commands import Bot, Context from modules import ChainedEmbed from modules.games.game import Game from utils import literals, get_emoji ONES = ('Ones', get_emoji(':one:')) TWOS = ('Twos', get_emoji(':two:')) THREES = ('Threes', get_emoji(':three:')) FOURS = ('Fours', get_emoji(':four:')) FIVES = ('Fives', get_emoji(':five:')) SIXES = ('Sixes', get_emoji(':six:')) FULL_HOUSE = ('Full house', get_emoji(':eject:')) FOUR_OF_A_KIND = ('4 of a kind', get_emoji(':capital_abcd:')) LITTLE_STRAIGHT = ('Little straight', get_emoji(':track_previous:')) BIG_STRAIGHT = ('Big straight', get_emoji(':track_next:')) CHOICE = ('Choice', get_emoji(':asterisk:')) YACHT = ('Yacht', get_emoji(':cruise_ship:')) CATEGORIES = [ ONES, TWOS, THREES, FOURS, FIVES, SIXES, FULL_HOUSE, FOUR_OF_A_KIND, LITTLE_STRAIGHT, BIG_STRAIGHT, CHOICE, YACHT ] DICE_ID = [ get_emoji(':regional_indicator_a:'),
import asyncio from typing import Coroutine, Union import discord from discord import Member, Reaction, User, Role, Message, VoiceChannel, TextChannel, PermissionOverwrite from discord.abc import GuildChannel from discord.ext.commands import Bot, Context, BadArgument, check, BucketType, MemberConverter import modules from modules import CustomCog, ChainedEmbed, shared_cooldown, DeckHandler, Deck, DeckConverter, guild_only from utils import get_cog, literals, get_emoji, wrap_codeblock, get_constant, check_length, attach_toggle_interface, \ InterfaceState FAILED_EMOJI = get_emoji(':negative_squared_cross_mark:') CONFIRM_EMOJI = get_emoji(':white_check_mark:') NSFW_EMOJI = get_emoji(':underage:') NSFW_TIMEOUT = 60 DECK_START_TIMEOUT = 60 DECK_END_TIMEOUT = 30 CHANNEL_DELETE_DELAY = 120 def wait_until_deck_handler_ready(): async def predicate(ctx: Context) -> bool: deck_handler = DeckHandler(ctx.bot) if not deck_handler.ready: message = await ctx.send( literals('wait_until_deck_handler_ready.predicate')['start']) await deck_handler.wait_until_ready()
async def handle(self, params, message, client): try: nick = str(params[0]) nick.replace('_', '+') except ValueError: await message.channel.send("Please, provide valid numbers") return url = 'https://eune.op.gg/summoner/spectator/userName='******'&' resp = requests.get(url) #Friendly if resp.status_code == 200: print("Successfully opened the web page") soup = BeautifulSoup(resp.text, 'html.parser') l = soup.find( "div", { "class": "tabItem Content SummonerLayoutContent summonerLayout-spectator" }) Error = [] for i in l.findAll("div"): Error.append(i.text) if (len(Error) > 5): l = soup.find("table", {"class": "Table Team-100"}) FriendNames = [] TierF = [] Wrf = [] for i in l.findAll("a", {"class": "SummonerName"}): FriendNames.append(i.text) for i in l.findAll("div", {"class": "TierRank"}): TierF.append(i.text) for i in l.findAll("td", {"class": "RankedWinRatio Cell"}): Wrf.append(i.text) l = soup.find("table", {"class": "Table Team-200"}) EnemyNames = [] TierE = [] Wre = [] for i in l.findAll("a", {"class": "SummonerName"}): EnemyNames.append(i.text) for i in l.findAll("div", {"class": "TierRank"}): TierE.append(i.text) for i in l.findAll("td", {"class": "RankedWinRatio Cell"}): Wre.append(i.text) l = soup.find("div", {"class": "Box"}) GameMode = [] MapName = "" Current = "" for i in l.findAll("div", {"class": "Title"}): GameMode.append(i.text) for i in l.findAll("small", {"class": "MapName"}): MapName = i.text for i in l.findAll("small", {"class": "Time"}): Current = i.text print(Current) Time = Current[len(Current) - 8:len(Current) - 3] print(Time) if (Time[0:1] == "0"): Time = Time[1:len(Time)] TMP1 = Time.replace(":", ".") TMP2 = float(TMP1) TMP2 += 16 TMP3 = str(TMP2) if (len(TMP3) == 2): TMP3 += "00" elif (len(TMP3) == 3 and TMP3[2:3] == "."): TMP3 += "00" elif (len(TMP3) == 3 and TMP3[1:2] == "."): TMP3 += "0" elif (len(TMP3) == 4 and TMP3[2:3] == "."): TMP3 += "0" TimeEUNE = TMP3.replace(".", ":") await message.channel.send( get_emoji(":game_die:") + "** Gamemode: **" + GameMode[0][0:15] + "\t" + get_emoji(":camping:") + "** Map: **" + MapName + "\t" + get_emoji(":hourglass:") + "** Time of start: **" + TimeEUNE + "\n\n" + get_emoji(":small_blue_diamond:") + f"** " + FriendNames[0] + "**\t" + get_emoji(":small_blue_diamond:") + f"** Rank: **" + TierF[0].lstrip().rstrip() + "\t" + get_emoji(":small_blue_diamond:") + f" **WinRate: **" + Wrf[0][0:8].lstrip().rstrip() + "\t" + get_emoji(":small_blue_diamond:") + "** Played Matches: **" + Wrf[0][9:15].strip() + "\n" + get_emoji(":small_blue_diamond:") + f"** " + FriendNames[1] + "**\t" + get_emoji(":small_blue_diamond:") + f"** Rank: **" + TierF[1].lstrip().rstrip() + "\t" + get_emoji(":small_blue_diamond:") + f" **WinRate: **" + Wrf[1][0:8].lstrip().rstrip() + "\t" + get_emoji(":small_blue_diamond:") + f"** Played Matches: **" + Wrf[1][9:15].strip() + "\n" + get_emoji(":small_blue_diamond:") + f"** " + FriendNames[2] + "**\t" + get_emoji(":small_blue_diamond:") + f"** Rank: **" + TierF[2].lstrip().rstrip() + "\t" + get_emoji(":small_blue_diamond:") + f" **WinRate: **" + Wrf[2][0:8].lstrip().rstrip() + "\t" + get_emoji(":small_blue_diamond:") + f"** Played Matches: **" + Wrf[2][9:15].strip() + "\n" + get_emoji(":small_blue_diamond:") + f"** " + FriendNames[3] + "**\t" + get_emoji(":small_blue_diamond:") + f"** Rank: **" + TierF[3].lstrip().rstrip() + "\t" + get_emoji(":small_blue_diamond:") + f" **WinRate: **" + Wrf[3][0:8].lstrip().rstrip() + "\t" + get_emoji(":small_blue_diamond:") + f"** Played Matches: **" + Wrf[3][9:15].strip() + "\n" + get_emoji(":small_blue_diamond:") + f"** " + FriendNames[4] + "**\t" + get_emoji(":small_blue_diamond:") + f"** Rank: **" + TierF[4].lstrip().rstrip() + "\t" + get_emoji(":small_blue_diamond:") + f" **WinRate: **" + Wrf[4][0:8].lstrip().rstrip() + "\t" + get_emoji(":small_blue_diamond:") + f"** Played Matches: **" + Wrf[4][9:15].strip() + "\n" + "\n" + get_emoji(":small_orange_diamond:") + f" **" + EnemyNames[0] + "**\t" + get_emoji(":small_orange_diamond:") + f" **Rank: **" + TierE[0].lstrip().rstrip() + "\t" + get_emoji(":small_orange_diamond:") + f" **WinRate: **" + Wre[0][0:8].lstrip().rstrip() + "\t" + get_emoji(":small_orange_diamond:") + f"** Played Matches: **" + Wre[0][9:15].strip() + "\n" + get_emoji(":small_orange_diamond:") + f" **" + EnemyNames[1] + "**\t" + get_emoji(":small_orange_diamond:") + f" **Rank: **" + TierE[1].lstrip().rstrip() + "\t" + get_emoji(":small_orange_diamond:") + f" **WinRate: **" + Wre[1][0:8].lstrip().rstrip() + "\t" + get_emoji(":small_orange_diamond:") + f"** Played Matches: **" + Wre[1][9:15].strip() + "\n" + get_emoji(":small_orange_diamond:") + f" **" + EnemyNames[2] + "**\t" + get_emoji(":small_orange_diamond:") + f" **Rank: **" + TierE[2].lstrip().rstrip() + "\t" + get_emoji(":small_orange_diamond:") + f" **WinRate: **" + Wre[2][0:8].lstrip().rstrip() + "\t" + get_emoji(":small_orange_diamond:") + f"** Played Matches: **" + Wre[2][9:15].strip() + "\n" + get_emoji(":small_orange_diamond:") + f" **" + EnemyNames[3] + "**\t" + get_emoji(":small_orange_diamond:") + f" **Rank: **" + TierE[3].lstrip().rstrip() + "\t" + get_emoji(":small_orange_diamond:") + f" **WinRate: **" + Wre[3][0:8].lstrip().rstrip() + "\t" + get_emoji(":small_orange_diamond:") + f"** Played Matches: **" + Wre[3][9:15].strip() + "\n" + get_emoji(":small_orange_diamond:") + f" **" + EnemyNames[4] + "**\t" + get_emoji(":small_orange_diamond:") + f" **Rank: **" + TierE[4].lstrip().rstrip() + "\t" + get_emoji(":small_orange_diamond:") + f" **WinRate: **" + Wre[4][0:8].lstrip().rstrip() + "\t" + get_emoji(":small_orange_diamond:") + f"** Played Matches: **" + Wre[4][9:15].strip() + "\n") else: await message.channel.send( "Player is not in game at the moment.") else: print("Error")