-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
52 lines (39 loc) · 1.41 KB
/
test.py
File metadata and controls
52 lines (39 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import discord
import os
from discord import app_commands
from dotenv import load_dotenv
from utils.summon import Summon
load_dotenv()
intents = discord.Intents.all()
# TOKEN = os.getenv(sys.argv[1])
TOKEN = os.getenv("DISCORD_TOKEN_TEST_BOT")
guild = discord.Object(id=690215022957559942)
class aclient(discord.Client):
def __init__(self):
super().__init__(intents=intents)
self.synced = False
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await tree.sync(guild=guild)
self.synced = True
print(f"{self.user} is nu online")
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="You"))
client = aclient()
tree = app_commands.CommandTree(client)
async def users_autocomplete(
interaction: discord.Interaction,
current: str,
) -> list[app_commands.Choice[str]]:
guild = interaction.guild
users = guild.members
return [
app_commands.Choice(name=user.name, value=str(user.id))
for user in users
if current.lower() in user.name.lower() and not user.bot and user.id != client.user.id
]
@tree.command(name="summon", description="Summon iemand", guild=guild)
@app_commands.autocomplete(user=users_autocomplete)
async def self(interaction: discord.Interaction, user: str):
await Summon().start(interaction, int(user))
client.run(TOKEN)