Advertisement
Jonpot

Untitled

Jul 8th, 2021 (edited)
1,446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.54 KB | None | 0 0
  1. from keep_alive import keep_alive
  2. import discord
  3. from discord.ext.commands import Bot
  4. from discord.ext import commands
  5. import os
  6.  
  7. client = discord.Client()
  8. bot = commands.Bot(".")
  9.  
  10. @client.event
  11. async def on_ready():
  12.     print('We have logged in as {0.user}'.format(client))
  13.  
  14. @client.event
  15. async def resolvedFun(message,askHereCat):
  16.     print('Running resolveFun')
  17.     await message.channel.edit(topic='Claim this channel by typing a question!',name='👋ask-here',category = askHereCat)
  18.     await message.channel.send("""Have questions or need help with a problem or specific topic? Ask here and be patient for a response. Remember to: \n • Ask your question straight away, rather than asking \'can anyone help\' \n • State the general concept/topic/chapter numbers (if applicable) \n • Tell us what you\'ve tried so far, or what your thought process is\n • The channel will be turned into your question when you type\n • Remember to free-up the channel with :resolved: when done""")
  19.  
  20. @client.event
  21. async def on_message(message):
  22.     print('Running on_message \n')
  23.  
  24.     if message.author == client.user:
  25.         print('This was the bot, returning. \n')
  26.         return
  27.  
  28.     guild = message.guild
  29.     askHereCat = discord.utils.get(guild.categories, name='ASK HERE')
  30.     activeQuestionsCat = discord.utils.get(guild.categories, name='ACTIVE QUESTIONS')
  31.     print('Not the bot, assigned guild, askHereCat, and activeQuestionsCat \n')
  32.  
  33.  
  34.     if message.channel.category_id == askHereCat.id:
  35.         print('Message in askHereCat, moving on. \n')
  36.         askerName = message.author.name
  37.         await message.channel.edit(topic=message.author.id,name='💬{}\'s-question.'.format(askerName),category = activeQuestionsCat)
  38.  
  39.  
  40.     if (message.content.startswith('resolved') and (message.channel.category_id == activeQuestionsCat.id) and ((message.author.id == int(message.channel.topic) or (message.author.guild_permissions.administrator == 1)))):
  41.       print('Message is resolved in activeQuestionsCat, running resolvedfun. \n')
  42.       await resolvedFun(message,askHereCat)
  43.  
  44.     if message.content.startswith('resolved') and message.channel.category_id == activeQuestionsCat.id and message.author.id != int(message.channel.topic):
  45.         print('Message is resolved and not the author. \n')
  46.         await message.channel.send('Only the question author or an admin can close an open question.')
  47.    
  48.     await bot.process_commands(message)
  49.     print('Processed commands. \n')
  50.  
  51. keep_alive()
  52. my_secret = os.environ['TOKEN']
  53. client.run(my_secret)
  54.  
  55.  
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement