Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from keep_alive import keep_alive
- import discord
- from discord.ext.commands import Bot
- from discord.ext import commands
- import os
- client = discord.Client()
- bot = commands.Bot(".")
- @client.event
- async def on_ready():
- print('We have logged in as {0.user}'.format(client))
- @client.event
- async def resolvedFun(message,askHereCat):
- print('Running resolveFun')
- await message.channel.edit(topic='Claim this channel by typing a question!',name='👋ask-here',category = askHereCat)
- 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""")
- @client.event
- async def on_message(message):
- print('Running on_message \n')
- if message.author == client.user:
- print('This was the bot, returning. \n')
- return
- guild = message.guild
- askHereCat = discord.utils.get(guild.categories, name='ASK HERE')
- activeQuestionsCat = discord.utils.get(guild.categories, name='ACTIVE QUESTIONS')
- print('Not the bot, assigned guild, askHereCat, and activeQuestionsCat \n')
- if message.channel.category_id == askHereCat.id:
- print('Message in askHereCat, moving on. \n')
- askerName = message.author.name
- await message.channel.edit(topic=message.author.id,name='💬{}\'s-question.'.format(askerName),category = activeQuestionsCat)
- 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)))):
- print('Message is resolved in activeQuestionsCat, running resolvedfun. \n')
- await resolvedFun(message,askHereCat)
- if message.content.startswith('resolved') and message.channel.category_id == activeQuestionsCat.id and message.author.id != int(message.channel.topic):
- print('Message is resolved and not the author. \n')
- await message.channel.send('Only the question author or an admin can close an open question.')
- await bot.process_commands(message)
- print('Processed commands. \n')
- keep_alive()
- my_secret = os.environ['TOKEN']
- client.run(my_secret)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement