cog file
from discord.ext import commands
import requests
import discord
def fetch_user_id(username: str):
response = requests.post(
"https://users.roblox.com/v1/usernames/users",
json = {
"usernames": [username],
"excludeBannedUsers": True
}
)
return response.json()["data"][0]["id"]
def fetch_avatar(user_id: int):
response = requests.get(
"https://thumbnails.roblox.com/v1/users/avatar",
params = {
"userIds": [user_id],
"size": "420x420",
"format": "Png",
"isCircular": "false"
}
)
return response.json()["data"][0]["imageUrl"]
class Kos(commands.Cog, name="Kos"):
print("received")
def __init__(self, bot: commands.Bot):
self.bot = bot
@discord.app_commands.command(name = "kos", description = "Publishes a KOS notice on the specified user")
async def kos(self, interaction: discord.Interaction, username: str, reason: str):
targetchannel = self.bot.get_channel(1343882206053142580)
user_id = fetch_user_id(username)
avatar_url = fetch_avatar(user_id)
embed = discord.Embed(
color = 0xff0000,
title = f"USERNAME: {username}", url=f"https://www.roblox.com/users/{user_id}/profile",
description = f"**Reason:** {reason}\n**Issued By:** <@{interaction.user.id}>"
)
embed.set_author(name = "KILL ON SIGHT NOTICE")
embed.set_image(url = avatar_url)
embed.set_footer(text = "If user is seen you are authorised to shoot, regardless of your rank witin the nowhere ville comedy club")
await targetchannel.send("<@&1343881957771186257>", embed = embed)
await interaction.response.send_message(f"KOS Notice sucessfully posted on {username}!")
async def setup(client):
await client.add_cog(Kos(client), guilds=[discord.Object(id="1341723521906114643")])