Download bots/servers.py from jam134/adad: direct link, hf CLI and curl.
- Browser
- Download file 810 Bytes
-
https://huggingface.co/spaces/jam134/adad/resolve/main/bots/servers.py
- Command line
-
hf download hf://spaces/jam134/adad/bots/servers.py
-
curl -L -o servers.py https://huggingface.co/spaces/jam134/adad/resolve/main/bots/servers.py
810 Bytes
| import discord | |
| from discord.ext import commands | |
| import asyncio | |
| import random | |
| from datetime import datetime | |
| intents = discord.Intents.default() | |
| intents.guilds = True # 讓機器人能夠查看伺服器列表 | |
| intents.members = True # 讓機器人能夠讀取伺服器的成員資訊 | |
| intents.message_content = True # 讓機器人能夠讀取訊息內容(這對於某些指令是必要的) | |
| bot = commands.Bot(command_prefix='!', intents=intents) | |
| def sid(): | |
| for index, guild in enumerate(bot.guilds): | |
| print(f"{index}: 伺服器名稱: {guild.name}, 伺服器 ID: {guild.id}") | |
| for index, channel in enumerate(guild.channels): | |
| print(f"{index}: 頻道名稱: {channel.name}, 頻道 ID: {channel.id}") | |
| def generate_random_number(): | |
| return random.randint(1, 100) |