You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取Discord用户的Boost date?命令开发技术问询

获取Discord用户的Boost日期方法

要获取用户的服务器Boost日期,你需要区分Nitro订阅开始时间和服务器Boost开始时间:前者是用户对象的premium_since字段,后者是服务器成员(Guild Member)对象的premium_since字段——这才是你需要的目标字段,它记录了用户开始Boost当前服务器的时间。

以下是不同开发场景下的实现方式:

1. 使用Discord.py(Python)

@bot.command()
async def boostdate(ctx):
    member = ctx.author
    if member.premium_since:
        boost_date = member.premium_since.strftime("%Y-%m-%d %H:%M:%S")
        await ctx.send(f"你开始Boost本服务器的时间是:{boost_date}")
    else:
        await ctx.send("你当前没有Boost本服务器")
  • member.premium_since仅在用户Boost当前服务器时返回时间对象,否则为None。

2. 使用Discord.js(JavaScript)

client.commands.set('boostdate', {
    run: async (message) => {
        const member = message.member;
        if (member.premiumSince) {
            const boostDate = member.premiumSince.toLocaleString();
            message.reply(`你开始Boost本服务器的时间是:${boostDate}`);
        } else {
            message.reply("你当前没有Boost本服务器");
        }
    }
});
  • member.premiumSince返回Date对象,可直接用原生方法格式化显示。

3. 直接调用Discord API

发送GET请求到/guilds/{guild_id}/members/{user_id}接口,返回的JSON数据中premium_since字段即为ISO 8601格式的Boost日期字符串。请求需要携带拥有guilds.members.read权限的令牌。

内容的提问来源于stack exchange,提问作者azonix

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 13:40:09