updated suggestion bot in terms of suggestions
This commit is contained in:
parent
7719b90747
commit
8bed22fcdc
@ -1,5 +1,6 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.ext.tasks import loop
|
||||
from settings import token
|
||||
import datetime
|
||||
|
||||
@ -37,10 +38,38 @@ async def on_message(message):
|
||||
message_content = message.content
|
||||
suggestion_type, message_content = get_suggestion_type(message_content)
|
||||
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
send_msg = f"""```DISCORD USER ID: {message.author.id}\nUSERNAME: {message.author}\nTYPE: {suggestion_type}\nTIME: {now}\nSUGGESTION: {message_content}```"""
|
||||
send_msg = f"""```DISCORD USER ID: {message.author.id}\nUSERNAME: {message.author}\nTYPE: {suggestion_type}\nTIME: {now}\nSTATUS: No admin interested yet (mark with an emote to prevent suggestion deletion within 48 hours)\nSUGGESTION: {message_content}```"""
|
||||
send_channel_msg = f"""{message.author} your suggestion was sent to admins as type: {suggestion_type}. Specify Suggestion types by appending your message with one of the following commands: !ze !zr !mg !forum !discord !meta"""
|
||||
await message.channel.purge(limit=1)
|
||||
await message.channel.send(send_channel_msg)
|
||||
await channel.send(send_msg)
|
||||
|
||||
client.run(token)
|
||||
@loop(seconds = 10)
|
||||
async def check_suggestions_to_delete():
|
||||
for channel in client.get_all_channels():
|
||||
if channel.name == 'suggestion-admin':
|
||||
msgs_history = channel.history()
|
||||
j1 = await msgs_history.flatten()
|
||||
status_msg = "STATUS: No admin interested yet (mark with an emote to prevent suggestion deletion within 48 hours)"
|
||||
for msg in j1:
|
||||
if len(msg.reactions) == 0:
|
||||
created_at = msg.created_at
|
||||
if created_at < datetime.datetime.now()-datetime.timedelta(days=2):
|
||||
print('deleting message: ', msg.content)
|
||||
await msg.delete()
|
||||
elif status_msg in msg.content:
|
||||
first_part = msg.content.split(status_msg)[0]
|
||||
last_part = msg.content.split(status_msg)[1]
|
||||
user_reactions = []
|
||||
for react in msg.reactions:
|
||||
users = react.users()
|
||||
j2 = await users.flatten()
|
||||
for user in j2:
|
||||
if user.name not in user_reactions:
|
||||
user_reactions.append(user.name)
|
||||
final_msg = f'{first_part}STATUS: Admins interested in topic:{user_reactions} {last_part}'
|
||||
await msg.edit(content=final_msg)
|
||||
|
||||
#the entire syntax that is visisble from python3 terminal is not very well displayed in the docs of discord.py and nobody has the current syntax in any suggestions anywhere on the internet. almost every single thing is out of date reee
|
||||
if __name__ == '__main__':
|
||||
check_suggestions_to_delete.start()
|
||||
client.run(token)
|
||||
|
Loading…
Reference in New Issue
Block a user