Coleman Ethington
Coleman Ethington

Reputation: 162

Trying to show the current log channel for a server discord.py

Im trying to add something to my help command where it can show the current log channel that is setup for the server. I tried to do it myself from scratch but log_channel is not getting defined. How can I define this? THx

My def log_channel code:

def get_logchannel(bot, message):
        with open('logchannel.json', 'r') as fp:
          log_channel = json.load(fp)
          return log_channel[str(message.guild.id)]

my help command code:

embed.add_field(name="**Current Log Channel:**", value=f"{log_channel(self.bot, ctx.message)}", inline=False)

the log_channel in {log_channel(self.bot, ctx.message)}") is not getting defined.

Upvotes: 0

Views: 40

Answers (1)

itzFlubby
itzFlubby

Reputation: 2289

You used whats supposedly meant a variable log_channel for a function call, which isn't defined anywhere, because your function is called get_logchannel.


Just replace log_channel with the actual function name in your help command and you should be good to go

embed.add_field(name="**Current Log Channel:**", value=f"{get_logchannel(self.bot, ctx.message)}", inline=False)

Upvotes: 2

Related Questions