Open hhstore opened 2 years ago
需求背景:
bot 应用:
项目源码:
长度 = 72
# 大概是这样的: 在创建应用的时候, 先复制出来. 不是 public key.
MTAxODU1ODQ1MjUxxxxxxxxxxxxxwmBA4.pXn8y_xxxxxxxxxxxxxxxxxxxCi5SNtM
本地调试时, bot 的代码参数, 要添加 http_proxy 参数. 因为被墙, 要走本地 proxy, 才能访问 discord 的服务.
如果报错, 提示权限问题. 注意在 bot 应用设置页面, 改一下权限设置, 如下截图.
踩坑:
示例代码:
import discord
from discord.ext import commands
intents = discord.Intents.all()
intents.members = True
# 注意 设置 proxy 参数:
bot = commands.Bot(command_prefix='$', intents=intents, proxy="http://127.0.0.1:7890")
➤ task discord:run
task: [discord:run] python3 run2.py \
--token=${DISCORD_TOKEN}
discord token: xxxxxx.xxxxx.xxxxx
2022-09-12 01:50:28 INFO discord.client logging in using static token
2022-09-12 01:50:33 INFO discord.gateway Shard ID None has connected to Gateway (Session ID: aaefcca2f142ab82e720c10cxxxxxx).
Logged in as
DisMate
101855845252xxxxx791
------
2022-09-12 02:05:41 INFO discord.gateway Shard ID None has successfully RESUMED session aaefcca2f142ab82e720c10cxxxxxx.
$greet
1
1
1
related: