Python Discord Bot, Needing The Server Id
I am creating a discord bot in python, and to keep the data on my computer I am using a dictionary in a text file, but if I want multi-server support for something like config I ne
Solution 1:
You can get an instance of the Server
class from the command invocation contextctx
. That object will have a meaningful id
attribute.
@bot.command(pass_context=True)asyncdefinfo(ctx):
await bot.say("ID: {}".format(ctx.message.server.id))
For discord.py-rewrite, this would be
@bot.command()asyncdefinfo(ctx):
await ctx.send("ID: {}".format(ctx.guild.id))
Post a Comment for "Python Discord Bot, Needing The Server Id"