I am struggling on something I am working on with my custom discord bot for someone. I have made a series of events that go like the picture here: Link to Example
I want to be able to store this in a JSON file or database without sending it straight away so later I can do things like:
*event list
- lists all text events/announcements Like this;event preview 1
- Example here With the '1' I want it to link to an event name in the json file so I can do this command so whatever event name is linked to whatever number. this is to see the preview of the announcement you made. it sends a period, edits that period to whatever is the event/announcement selected. this is so that if the announcement has an everyone or here ping, it wont ping when you're previewing the announcement;event post 1 (or whatever number relates to the right event I want to post)
Example here - this command posts that particular event
I can not figure out how to store it in the Json file or database and be able to do those commands above. I have had little help from other devs but I still cant figure it out and need help on how to do it. Below is my code so far if someone can please help me:
@bot.command()
async def event(ctx):
def check(msg):
return msg.channel.id == ctx.channel.id and msg.author.id == ctx.author.id
await ctx.send("Please enter the event name:")
eventname = await bot.wait_for("message", check=check)
await ctx.send("Please send what you want to say in the announcement in a code block:")
codeblock = await bot.wait_for("message", check=check)
await ctx.send("What image should be posted? (Type 'no' for none)")
image = await bot.wait_for("message", check=check)
mainimage = None
if image.content.lower() != "no":
mainimage = image.attachments[0]
await ctx.send('What channel should the announcement be made in? (Please tag the channel)')
eventch = await bot.wait_for("message", check=check)
realchannel = await commands.TextChannelConverter().convert(ctx, eventch.content)
message = codeblock.content.replace("```", "").replace("`", "")
if mainimage:
return await realchannel.send(message, file=await mainimage.to_file())
await realchannel.send(message)
(Sorry if not indented properly, nor sure how to on here)
Help is appreciated.