Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @bot.event
- async def on_message(message):
- if message.author == bot.user: return
- author = message.author
- content = message.content
- channel = message.channel
- if "!add" in content:
- content = str(content)
- url = content.strip("!add")
- url = url.replace(" ", "")
- botmessage = "Added URL: " + url
- with open("products.txt", "a") as txtfile:
- txtfile.write(url+"\n")
- print(botmessage)
- await message.channel.send(botmessage)
- elif "!remove" in content:
- content = str(content)
- print(content)
- urls = content.split(" ")
- url = urls[1]
- print(url)
- txtfile = open("products.txt", "r")
- url_links = txtfile.readlines()
- txtfile.close()
- with open("products.txt", "w") as txt:
- for link in url_links:
- if url != link:
- txt.write(link)
- else:
- print("found it")
- botmessage = "Removed URL: " + url
- print("remove")
- await message.channel.send(botmessage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement