Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. import asyncio
  4. import discord.utils
  5. import datetime
  6. import gspread
  7. import traceback
  8. import sys
  9. import time
  10. from gspread.exceptions import CellNotFound
  11. from oauth2client.service_account import ServiceAccountCredentials
  12.  
  13. scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
  14.  
  15. credentials = ServiceAccountCredentials.from_json_keyfile_name('Credites-d90e60bb9daf.json', scope)
  16.  
  17. gc = gspread.authorize(credentials)
  18.  
  19.  
  20. wks = gc.open_by_key('1hv3Xv5xssd0jmK1lsrdxTFVvARTMMiyUcX6TW2vHcdg') .sheet1
  21.  
  22. client = commands.Bot(command_prefix = '.')
  23.  
  24.  
  25. #Credits code.
  26. @client.command()
  27. @commands.cooldown(1, 15)
  28. @commands.has_any_role('test', 'Owner', 492212595072434186)
  29. async def credits(ctx):
  30. gc.login()
  31. time2 = datetime.datetime.now().strftime("%b %d, %Y at %I:%M %p (EST)")
  32. channel = client.get_channel(632969296535879705)
  33. await ctx.message.delete()
  34. cell = wks.find(str(ctx.message.author.id))
  35. ftocredits = wks.cell(cell.row,3).value
  36. await ctx.message.author.send("**__" + time2 + "__**")
  37. if str(ftocredits).lower() == '1':
  38. await ctx.message.author.send(f'**•** You have **{ftocredits}** credit')
  39. await channel.send("**__" + time2 + "__**\n**" + ctx.message.author.mention + "** Has successfully run the `credits` command!\n---------")
  40. elif str(ftocredits).lower() == '':
  41. await ctx.message.author.send("**•** **System Error; No Credits Available**")
  42. else:
  43. await ctx.message.author.send(f'**•** You have **{ftocredits}** credits')
  44. await channel.send("**__" + time2 + "__**\n**" + ctx.message.author.mention + "** Has successfully run the `credits` command!\n---------")
  45. requirements = wks.cell(cell.row,2).value
  46. if str(requirements).lower() == 'yes':
  47. await ctx.message.author.send('**•** You **have** met the requirements for this month!')
  48. elif str(requirements).lower() == 'fta':
  49. await ctx.message.author.send("**•** You are an FTA, don't worry about meeting requiremnts, rather focus on getting sit-ins done within your 60 days.")
  50. elif str(requirements).lower() == '\\':
  51. await ctx.message.author.send("**•** You are not required to meet requirements for this month!")
  52. elif str(requirements).lower() == '':
  53. await ctx.message.author.send("**•** Please contact an FTO-Lead for credits. The bot developer has been notified of this error.")
  54. await channel.send("**__" + time2 + "__**\n" + "<@359788891412103169> - **User: "+ ctx.message.author.mention + "** Has encountered an error while trying to use the `credits` command.\n---------")
  55. else:
  56. await ctx.message.author.send('**•** You **do not** meet the monthly requirements.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement