Sorry for the unclear question title. I don't know any other way to put it.
I made a command that says p!channel [channel_id]
which basically makes a channel where my bot will respond with "e". I want the command to store the channel_id
and guild_id
into a json file called channel.json
, and when a user sends a message, it will check if the message is in the channel_id
channel, and if it is in the channel, will send "e". However, it's not responding and no error codes are showing up. Can someone help? Code is below:
def get_channel(client,message):
with open("channel.json", "r") as f:
e = json.load(f)
return e[str(message.guild.id)]
@client.command()
@commands.has_permissions()
async def channel(ctx, *, channelid):
with open("channel.json", "r") as f:
e = json.load(f)
e[str(ctx.guild.id)] = channelid
with open("channel.json", "w") as f:
json.dump(e,f)
await ctx.send(f"Successfully setup <#{channelid}>")
@client.event
async def on_message(message):
if message.channel.id == get_channel:
await message.channel.send('e')