This commit is contained in:
2023-05-05 17:44:48 +02:00
parent 1a40ffb4a6
commit b60a78e75a
8 changed files with 564 additions and 15 deletions
+35
View File
@@ -0,0 +1,35 @@
import discord
from discord.ext import commands
class Changelog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("Changlog.py is ready")
@commands.command()
async def changelog(self, ctx):
botmessage = str(
"Welcome to V1.1 of Sonar, we have lots to discuss because alot has changed or got added.\n\n"+
"-change 1, !stats and !compare arent 2 different functions anymore but became 1 function,\n"+
"so now you can do !stats <playername>, <playername>, <weapon>, or for those who like to write !compare this still works aswell.\n\n"+
"-change 2, !stats, !lb (!leaderboard) got <server> filters so now its possible to see your standing in a server.\n\n"
"-change 3, All currently existing commands did get an overhaul to make them less restrictive to people, so you no longer need to write wingman_elite,\n"+
"you can now do wingman elite or elite to get the wingman elite as filter, servers do have the same principle\n\n"+
"-change 4, clearer error message\n\n"+
"-change 5, All currently existing commands did get a slash command counterpart\n\n"+
"Thanks for reading and goodluck increasing those stats"
)
await ctx.send(f"```{botmessage}```")
async def setup(client):
await client.add_cog(Changelog(client))
+24 -15
View File
@@ -13,30 +13,39 @@ class Help(commands.Cog):
async def help(self, ctx, message="all"):
botmessage = ""
if(message == "all"):
botmessage = str("To get further information about a command do: \n!help <command> \n" +
botmessage = str("To get further information about a command do: \n!help <command> \n------------------- \n" +
"The commands you can get information on are: \n" +
"roll \n" +
"ping \n" +
"compare \n" +
"stats \n" +
"leaderboard \n"+
"changelog : Gives all the information about the changes and updates.\n"
"roll : Rolls a number between 1 and 100. \n" +
"ping : Shows latency. \n" +
"stats : Shows stats collected by ToneAPI. \n" +
"leaderboard : Shows a leaderboard of stats. \n"+
"slashcommands: This explains what slash commands are, if you used slash commands before this isnt usefull\n"
"------------------- \n"
"if this help command doesnt help you or you have suggestions for future commands, ping or dm me @lars#1029")
elif(message == "changelog"):
botmessage = str("!changelogs is a command that gives you all the recent changes and updates")
elif(message == "roll"):
botmessage = str("!roll is a command that rolls a number between 1 and 100, with a rating")
elif(message == "ping"):
botmessage = str("!ping gives the latency between you and the bot")
elif(message == "compare"):
botmessage = str("!compare takes multiple playernames and 1 weapon to compare these players \n"+
"Example: \n!compare iilars, legonzaur, okvdai, kraber \n!compare <playername>, <playername>, <playername>, <weaponname> \nA weapon doesnt need to be specified")
elif(message == "stats"):
botmessage = str("!stats takes 1 playername and 1 weapon name to show this players stats\n"+
"Example: \n!stats iilars, kraber \n!stats <playername>, <weaponname> \nA weapon doesnt need to be specified\n"+
"For those wondering why the kd with a weapon doesnt match the webclient, de webclient takes kills with a weapon and deaths to that weapon and this bot takes kills with weapon and deaths while weapon is held")
botmessage = str("!stats takes playername(s), Optional: weaponname, servername\n"+
"Example: \n!stats iilars, kraber, fvnkhead's 3v3 \n!stats <playername>, <weaponname>, <servername> \nA weapon or server doesnt need to be specified, because if they arent there it will take overall\n"+
"-------------------------------------------------\n"+
"For those wondering why the kd with a weapon doesnt match the webclient,\nthe webclient takes kills with a weapon and deaths to that weapon and this bot takes kills with weapon and deaths while weapon is held")
elif(message == "leaderboard"):
botmessage = str("!leaderboard is a leaderboard that can be filtered, also for the lazy between us leaderboard can be subsituted by lb, rank, ranking \n"
+"currently the leaderboard can only be filtered by kills, deaths, max_distance, total_distance with a specified weapon \n" +
"Example: \n!lb kills, kraber \n!lb <filter>, <weaponname> \nA weapon doesnt need to be specified")
botmessage = str("!leaderboard is a leaderboard that can be filtered, also for the lazy between us leaderboard can be subsituted by lb, rank, ranking, board \n"
+"currently the leaderboard can only be filtered by kills, deaths, maxd, totald, kd and avgd with a specified weapon \n" +
"Example: \n!lb kills, kraber, fvnkhead's 3v3 \n!lb <filter>, <weaponname>, <servername> \nA weapon or server doesnt need to be specified\n"+
"------------------------\n"+
"maxd = max distance, avgd = average distance, kd = kill/death ratio and totald = total distance"
)
elif(message == "slashcommands"):
botmessage = str("To do a slash command, hit the / key and navigate to the sonar icon after doing this you will see all the commands.\nThese commands take the same input as the normal !commands")
else:
botmessage = "Cant help you with this"
+36
View File
@@ -0,0 +1,36 @@
import discord
from discord.ext import commands
from discord import app_commands
class SlashChangelog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("SlashChanglog.py is ready")
@app_commands.command(name="changelog", description="Gives all the changes and updates to new or old commands")
async def changelog(self, interaction: discord.Interaction):
botmessage = str(
"Welcome to V1.1 of Sonar, we have lots to discuss because alot has changed or got added.\n\n"+
"-change 1, !stats and !compare arent 2 different functions anymore but became 1 function,\n"+
"so now you can do !stats <playername>, <playername>, <weapon>, or for those who like to write !compare this still works aswell.\n\n"+
"-change 2, !stats, !lb (!leaderboard) got <server> filters so now its possible to see your standing in a server.\n\n"
"-change 3, All currently existing commands did get an overhaul to make them less restrictive to people, so you no longer need to write wingman_elite,\n"+
"you can now do wingman elite or elite to get the wingman elite as filter, servers do have the same principle\n\n"+
"-change 4, clearer error message\n\n"+
"-change 5, All currently existing commands did get a slash command counterpart\n\n"+
"Thanks for reading and goodluck increasing those stats"
)
await interaction.response.send_message(f"```{botmessage}```")
async def setup(client):
await client.add_cog(SlashChangelog(client))
+57
View File
@@ -0,0 +1,57 @@
import discord
from discord.ext import commands
from discord import app_commands
class SlashHelp(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("SlashHelp.py is ready")
@app_commands.command(name="help", description= "Gives information about the commands in this bot")
async def help(self, interaction: discord.Interaction, message:str ="all"):
botmessage = ""
if(message == "all"):
botmessage = str("To get further information about a command do: \n!help <command> \n------------------- \n" +
"The commands you can get information on are: \n" +
"changelog : Gives all the information about the changes and updates.\n"
"roll : Rolls a number between 1 and 100. \n" +
"ping : Shows latency. \n" +
"stats : Shows stats collected by ToneAPI. \n" +
"leaderboard : Shows a leaderboard of stats. \n"+
"slashcommands: This explains what slash commands are, if you used slash commands before this isnt usefull\n"
"------------------- \n"
"if this help command doesnt help you or you have suggestions for future commands, ping or dm me @lars#1029")
elif(message == "changelog"):
botmessage = str("!changelogs is a command that gives you all the recent changes and updates")
elif(message == "roll"):
botmessage = str("!roll is a command that rolls a number between 1 and 100, with a rating")
elif(message == "ping"):
botmessage = str("!ping gives the latency between you and the bot")
elif(message == "stats"):
botmessage = str("!stats takes playername(s), Optional: weaponname, servername\n"+
"Example: \n!stats iilars, kraber, fvnkhead's 3v3 \n!stats <playername>, <weaponname>, <servername> \nA weapon or server doesnt need to be specified, because if they arent there it will take overall\n"+
"-------------------------------------------------\n"+
"For those wondering why the kd with a weapon doesnt match the webclient,\nthe webclient takes kills with a weapon and deaths to that weapon and this bot takes kills with weapon and deaths while weapon is held")
elif(message == "leaderboard"):
botmessage = str("!leaderboard is a leaderboard that can be filtered, also for the lazy between us leaderboard can be subsituted by lb, rank, ranking, board \n"
+"currently the leaderboard can only be filtered by kills, deaths, maxd, totald, kd and avgd with a specified weapon \n" +
"Example: \n!lb kills, kraber, fvnkhead's 3v3 \n!lb <filter>, <weaponname>, <servername> \nA weapon or server doesnt need to be specified\n"+
"------------------------\n"+
"maxd = max distance, avgd = average distance, kd = kill/death ratio and totald = total distance"
)
elif(message == "slashcommands"):
botmessage = str("To do a slash command, hit the / key and navigate to the sonar icon after doing this you will see all the commands.\nThese commands take the same input as the normal !commands")
else:
botmessage = "Cant help you with this"
await interaction.response.send_message(f"```{botmessage}```")
async def setup(client):
await client.add_cog(SlashHelp(client))
+19
View File
@@ -0,0 +1,19 @@
import discord
from discord.ext import commands
from discord import app_commands
class SlashInvite(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("SlashInvite.py is ready")
@app_commands.command(name="invite", description="Tells you in how many servers sonar is active and gives an invite link with it")
async def invite(self, interaction: discord.Interaction):
link = "https://discord.com/api/oauth2/authorize?client_id=1100115547515011182&permissions=414464862272&scope=bot"
await interaction.response.send_message("I'm already in " + str(len(self.client.guilds)) + " servers!\n" + "Invite me now using:\n " + link)
async def setup(client):
await client.add_cog(SlashInvite(client))
+201
View File
@@ -0,0 +1,201 @@
import discord
from discord.ext import commands
from discord import app_commands
import requests
class SlashLeaderboard(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("SlashLeaderboard.py is ready")
@app_commands.command(name="leaderboard", description="Gives the leaderboard of selected filter, possible to be narrowed down on weapon and server")
@app_commands.describe(board = "The filter that decides the stat the leaderboard gets ordered at",weapon = "Ingame Weaponname", servername = "A Tone supported server")
@app_commands.rename(board = "filter", servername = "server")
async def leaderboard(self, interaction: discord.Interaction, board: str, weapon : str = "", servername : str = ""):
boards = ["kd", "avgd", "maxd", "totald","deaths", "kills"]
server = ""
weaponid= ""
weaponname= ""
if(weapon != ""):
weaponid, weaponname = self.getweaponid(weapon)
if(servername != ""):
server = self.getserver(servername)
if(board in boards):
botmessage = self.getleaderboard(weaponid=weaponid, weaponname=weaponname, server=server, board=board)
else:
botmessage = "You gave a none existing filter"
await interaction.response.send_message(f'```{botmessage}```')
def getweaponid(self, weaponname):
weapons ={
"execution": "human_execution",
"car": "mp_weapon_car",
"charge rifle": "mp_weapon_defender",
"double take": "mp_weapon_doubletake",
"epg": "mp_weapon_epg",
"volt": "mp_weapon_hemlok_smg",
"lstar": "mp_weapon_lstar",
"r97": "mp_weapon_r97",
"r-201": "mp_weapon_rspn101",
"smart pistol": "mp_weapon_smart_pistol",
"kraber": "mp_weapon_sniper",
"flatline": "mp_weapon_vinson",
"re-45 auto": "mp_weapon_autopistol",
"alternator": "mp_weapon_alternator_smg",
"frag grenade": "mp_weapon_frag_grenade",
"g2": "mp_weapon_g2",
"spitfire": "mp_weapon_lmg",
"smr": "mp_weapon_smr",
"softball": "mp_weapon_softball",
"firestar": "mp_weapon_thermite_grenade",
"melee": "melee_pilot_emptyhanded",
"masstiff": "mp_weapon_mastiff",
"mgl": "mp_weapon_mgl",
"r-101": "mp_weapon_rspn101_og",
"wingman": "mp_weapon_wingman",
"invalid": "invalid",
"thunderbolt": "mp_weapon_arc_launcher",
"dmr": "mp_weapon_dmr",
"electric smoke": "mp_weapon_grenade_electric_smoke",
"cold war": "mp_weapon_pulse_lmg",
"satchel": "mp_weapon_satchel",
"eva-8 auto": "mp_weapon_shotgun",
"mozambique": "mp_weapon_shotgun_pistol",
"wingman elite": "mp_weapon_wingman_n",
"gravity star": "mp_weapon_grenade_gravity",
"pulse blade": "mp_weapon_grenade_sonar",
"archer": "mp_weapon_rocket_launcher",
"outOfBounds": "outOfBounds",
"mind crime": "mind_crime",
"devotion": "mp_weapon_esaw",
"fall": "fall",
"p2016": "mp_weapon_semipistol",
"arc grenade": "mp_weapon_grenade_emp",
"hemlok": "mp_weapon_hemlok",
"phase shift": "phase_shift"
}
weaponid = ""
for weapon in weapons:
if(weaponname.lower() in weapon.lower()):
weaponid = weapons[weapon]
weaponname = weapon
break
return weaponid, weaponname
def getserver(self, snippet):
server = ""
response = requests.get('https://tone.sleepycat.date/v2/client/servers').json()
servers = response.keys()
for i in servers:
if(snippet.lower() in i.lower()):
server = i
break
return server
def getleaderboard(self, board, weaponid="", weaponname="", server=""):
easyfilter = False
hardfilter = False
payload = {"weapon": weaponid, "server": server}
response = requests.get('https://tone.sleepycat.date/v2/client/players', params=payload).json()
players = response.keys()
if(board.lower() in ["kills", "deaths", "maxd", "totald"]):
if(board.lower() == "totald"):
board = "total_distance"
if(board.lower() == "maxd"):
board = "max_distance"
easyfilter = True
else:
hardfilter = True
top10 = {}
while(len(top10)<10):
current = 0
name = ""
for p in players:
stats = response[p]
if(easyfilter):
checked = stats[str(board)]
if(hardfilter):
if(board.lower() == "kd"):
if (stats['deaths'] == 0):
deaths = 1
else:
deaths = stats['deaths']
checked = round(stats["kills"] / deaths, 2)
if(board.lower() == "avgd"):
if(stats["kills"] == 0):
kills = 1
else:
kills = stats["kills"]
checked = round(stats["total_distance"] / kills, 2)
#print(checked, ", ", current )
if(checked >= current and stats["username"] not in top10.keys()):
#print(checked, ", ", current)
current = checked
name = stats['username']
top10[name] = current
if(board.lower() == "deaths"):
inbetween = "to"
else:
inbetween = "with"
if(server == ""):
server = "all servers"
if(weaponname == ""):
weaponname = "any weapon"
botmessage = str(f"Leaderboard of {board} {inbetween} {weaponname} for {server}\n-------------------------------\n")
counter = 1
for i, j in top10.items():
if(hardfilter):
stat = str("{:0.2f}".format(j))
if(easyfilter):
stat = str(j)
botmessage = botmessage + str(f"{str(counter):<2}"+ " - " + f"{i :<15}" + " : "+ f"{stat:<8}" + "\n")
counter= counter+1
return botmessage
@leaderboard.autocomplete("weapon")
async def autocomplete_weapon(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
data = []
weaponlist = ['execution', 'car', 'charge rifle', 'double take', 'epg', 'volt', 'lstar', 'r97', 'r-201', 'smart pistol', 'kraber', 'flatline', 're-45 auto', 'alternator', 'frag grenade', 'g2', 'spitfire', 'smr', 'softball', 'firestar', 'melee', 'masstiff', 'mgl', 'r-101', 'wingman', 'invalid', 'thunderbolt', 'dmr', 'electric smoke', 'cold war', 'satchel', 'eva-8 auto', 'mozambique', 'wingman elite', 'gravity star', 'pulse blade', 'archer', 'outOfBounds', 'mind crime', 'devotion', 'fall', 'p2016', 'arc grenade', 'hemlok', 'phase shift']
for weapon_choice in weaponlist:
if(current.lower() in weapon_choice.lower()):
data.append(app_commands.Choice(name=weapon_choice, value=weapon_choice))
return data
@leaderboard.autocomplete("servername")
async def autocomplete_server(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
data = []
servers = requests.get("https://tone.sleepycat.date/v2/client/servers").json()
for server_choice in servers.keys():
if(current.lower() in server_choice.lower()):
data.append(app_commands.Choice(name=server_choice, value=server_choice))
return data
@leaderboard.autocomplete("board")
async def autocomplete_server(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
data = []
boards = ["kd", "avgd", "maxd", "totald","deaths", "kills"]
for board_choice in boards:
if(current.lower() in board_choice.lower()):
data.append(app_commands.Choice(name=board_choice, value=board_choice))
return data
async def setup(client):
await client.add_cog(SlashLeaderboard(client))
+8
View File
@@ -12,6 +12,7 @@ class SlashRoll(commands.Cog):
print("SlashRoll.py is ready")
@app_commands.command(name="roll", description="Rolls a number between 1 and 100 with a rating")
@app_commands.checks.cooldown(1, 600)
async def slashroll(self, interaction: discord.Interaction):
rolled = random.randint(1,100)
rating = ""
@@ -39,6 +40,13 @@ class SlashRoll(commands.Cog):
await interaction.response.send_message(message)
@slashroll.error
async def on_command_error(self, interaction: discord.Interaction, error : app_commands.AppCommandError):
if isinstance(error, app_commands.CommandOnCooldown):
time = round(error.retry_after/60)
message = f"This command is on cooldown, the cooldown ends in {time} minutes"
await interaction.response.send_message(message)
async def setup(client):
await client.add_cog(SlashRoll(client))
+184
View File
@@ -0,0 +1,184 @@
import discord
from discord.ext import commands
from discord import app_commands
import requests
class SlashStats(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("SlashStats.py is ready")
@app_commands.command(name="stats", description="Gives the stats of the selected player/players filtered by weapon and server, if given")
@app_commands.describe(playernames = "Ingame name of the player or players", weapon = "Ingame Weaponname", servername = "A Tone supported server")
@app_commands.rename(playernames = "player", servername = "server")
async def stats(self, interaction: discord.Interaction, playernames : str, weapon : str = "", servername : str = ""):
error = False
playernames = playernames.replace(",", "")
playernames = playernames.split(" ")
players = []
server = ""
weaponid= ""
weaponname= ""
print(playernames)
for i in playernames:
playerid = self.getplayerid(i)
if(playerid != ""):
players.append(playerid)
if(weapon != ""):
weaponid, weaponname = self.getweaponid(weapon)
if(servername != ""):
server = self.getserver(servername)
if(len(players) == 0 and error == False):
error = True
await interaction.response.send_message("```No existing player found, check if the name is correct or has changed```")
list_of_stats = []
for i in players:
stats = self.getstats(playerid=i,weaponid=weaponid, weaponname=weaponname, server=server)
list_of_stats.append(stats)
if ("".join(list_of_stats) != ""):
if(server != ""):
botmessage = str("Stats for " + server + "\n" + "---------------------" + "\n")
else:
botmessage = str("Stats for all servers\n" + "---------------------" + "\n")
divider = str("\n --------------------- \n")
botmessage = botmessage + divider.join(list_of_stats)
await interaction.response.send_message(f'```{botmessage}```')
def getplayerid(self, playername):
playerid = ""
payload = str("username=") + playername
response = requests.get('https://northstar.tf/accounts/lookup_uid', params=payload).json()
if (response['matches'] != None):
playerid = response['matches'][0]
return str(playerid)
def getweaponid(self, weaponname):
weapons ={
"execution": "human_execution",
"car": "mp_weapon_car",
"charge rifle": "mp_weapon_defender",
"double take": "mp_weapon_doubletake",
"epg": "mp_weapon_epg",
"volt": "mp_weapon_hemlok_smg",
"lstar": "mp_weapon_lstar",
"r97": "mp_weapon_r97",
"r-201": "mp_weapon_rspn101",
"smart pistol": "mp_weapon_smart_pistol",
"kraber": "mp_weapon_sniper",
"flatline": "mp_weapon_vinson",
"re-45 auto": "mp_weapon_autopistol",
"alternator": "mp_weapon_alternator_smg",
"frag grenade": "mp_weapon_frag_grenade",
"g2": "mp_weapon_g2",
"spitfire": "mp_weapon_lmg",
"smr": "mp_weapon_smr",
"softball": "mp_weapon_softball",
"firestar": "mp_weapon_thermite_grenade",
"melee": "melee_pilot_emptyhanded",
"masstiff": "mp_weapon_mastiff",
"mgl": "mp_weapon_mgl",
"r-101": "mp_weapon_rspn101_og",
"wingman": "mp_weapon_wingman",
"invalid": "invalid",
"thunderbolt": "mp_weapon_arc_launcher",
"dmr": "mp_weapon_dmr",
"electric smoke": "mp_weapon_grenade_electric_smoke",
"cold war": "mp_weapon_pulse_lmg",
"satchel": "mp_weapon_satchel",
"eva-8 auto": "mp_weapon_shotgun",
"mozambique": "mp_weapon_shotgun_pistol",
"wingman elite": "mp_weapon_wingman_n",
"gravity star": "mp_weapon_grenade_gravity",
"pulse blade": "mp_weapon_grenade_sonar",
"archer": "mp_weapon_rocket_launcher",
"outOfBounds": "outOfBounds",
"mind crime": "mind_crime",
"devotion": "mp_weapon_esaw",
"fall": "fall",
"p2016": "mp_weapon_semipistol",
"arc grenade": "mp_weapon_grenade_emp",
"hemlok": "mp_weapon_hemlok",
"phase shift": "phase_shift"
}
weaponid = ""
for weapon in weapons:
if(weaponname.lower() in weapon.lower()):
weaponid = weapons[weapon]
weaponname = weapon
break
if(weaponid == ""):
weaponname = ""
return weaponid, weaponname
def getserver(self, snippet):
server = ""
response = requests.get('https://tone.sleepycat.date/v2/client/servers').json()
servers = response.keys()
for i in servers:
if(snippet.lower() in i.lower()):
server = i
break
return server
def getstats(self, playerid, weaponid = "", weaponname = "", server = ""):
payload = {'player': playerid, 'weapon': weaponid, 'server': server}
response = requests.get('https://tone.sleepycat.date/v2/client/players', params=payload).json()
if(response == {}):
errorresponse = requests.get("https://northstar.tf/accounts/get_username", params={"uid": playerid}).json()
if(errorresponse['matches'] != None):
playername = errorresponse['matches'][0]
return str("No stats found for player: " + playername)
killstats = response[str(playerid)]
botmessage = str("Playername: " + killstats['username'] + '\n' + "Kills : " + str(killstats['kills']) + '\n' )
if(weaponid != ""):
deaths=killstats['deaths_while_equipped']
if(deaths == 0):
deaths = 1;
botmessage += str("Deaths : " + str(killstats['deaths_while_equipped'])) + '\n' + str("Weapon : " + weaponname) + '\n' + str(str("weapon KD : " + str("{:0.2f}".format(killstats['kills']/deaths))))
else:
deaths=killstats['deaths']
if(deaths == 0):
deaths = 1;
botmessage = botmessage + str("Deaths : " + str(killstats['deaths'])) + '\n' + str("KD : " + str("{:0.2f}".format(killstats['kills']/deaths)))
return botmessage
@stats.autocomplete("weapon")
async def autocomplete_weapon(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
data = []
weaponlist = ['execution', 'car', 'charge rifle', 'double take', 'epg', 'volt', 'lstar', 'r97', 'r-201', 'smart pistol', 'kraber', 'flatline', 're-45 auto', 'alternator', 'frag grenade', 'g2', 'spitfire', 'smr', 'softball', 'firestar', 'melee', 'masstiff', 'mgl', 'r-101', 'wingman', 'invalid', 'thunderbolt', 'dmr', 'electric smoke', 'cold war', 'satchel', 'eva-8 auto', 'mozambique', 'wingman elite', 'gravity star', 'pulse blade', 'archer', 'outOfBounds', 'mind crime', 'devotion', 'fall', 'p2016', 'arc grenade', 'hemlok', 'phase shift']
for weapon_choice in weaponlist:
if(current.lower() in weapon_choice.lower()):
data.append(app_commands.Choice(name=weapon_choice, value=weapon_choice))
return data
@stats.autocomplete("servername")
async def autocomplete_server(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
data = []
servers = requests.get("https://tone.sleepycat.date/v2/client/servers").json()
for server_choice in servers.keys():
if(current.lower() in server_choice.lower()):
data.append(app_commands.Choice(name=server_choice, value=server_choice))
return data
async def setup(client):
await client.add_cog(SlashStats(client))