Facebook
From Scanty Parrot, 2 Years ago, written in Python.
This paste is a reply to Re: Discord Chat bot from Khaleel - view diff
Embed
Download Paste or View Raw
Hits: 222
  1. #mebin
  2.  
  3. Facebook
  4. Discord Chat bot safest cryptocurrency exchange
  5.  
  6. From Adrian Maximus, 1 Month ago, written in Python.
  7. URL https://pastebin.pl/view/671351e8
  8. Embed Show code
  9. Download Paste or View Raw
  10. Hits: 889
  11.      
  12.  
  13. #main.py
  14. import discord
  15. from keep_alive import keep_alive
  16. from discord.ext import commands
  17. import os
  18. import openai
  19.  
  20. #make sure you have import all the above
  21.  ebin
  22.  
  23. Facebook
  24. Discord Chat bot safest cryptocurrency exchange
  25.  
  26. From Adrian Maximus, 1 Month ago, written in Python.
  27. URL https://pastebin.pl/view/671351e8
  28. Embed Show code
  29. Download Paste or View Raw
  30. Hits: 889
  31.      
  32.  
  33. #main.py
  34. import discord
  35. from keep_alive import keep_alive
  36. from discord.ext import commands
  37. import os
  38. import openai
  39.  
  40. #make sure you have import all the above
  41.  
  42. bot = commands.Bot(
  43.   command_prefix='?', #any prefix you want
  44.   case_insensitive=False,
  45.   description=None,
  46.   intents=discord.Intents.all(), #enable intents in discord developer portal
  47.   help_command=None
  48. )
  49.  
  50. @bot.command()
  51. async def test(ctx,*,arg): # * is used to make sure your complete arguement is used rather than first word
  52.   query = ctx.message.content
  53.   response = openai.Completion.create(
  54.     api_key = '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', #put your own api key here, mine doesnt work i deleted mine ?
  55.     model="text-davinci-003",
  56.     prompt=query,
  57.     temperature=0.5,
  58.     max_tokens=60,
  59.     top_p=0.3,
  60.     frequency_penalty=0.5,
  61.     presence_penalty=0.0
  62.   )
  63.   await ctx.channel.send(content=response['choices'][0]['text'].replace(str(query), ""))
  64.  
  65. @bot.event
  66. async def on_ready():
  67.   await bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name=f"Hi"))
  68.   print(f"Logged in as {bot.user.name}")
  69.  
  70. keep_alive()
  71.  
  72.  
  73. bot.run(os.environ['BOT KEY']) #create a secret token named BOT KEY and paste ur token
  74.  
  75. #keep_alive.py -> new file
  76.  
  77. from flask import Flask
  78. from threading import Thread
  79.  
  80. app = Flask('')
  81.  
  82. @app.route('/')
  83. def home():
  84.     return "Hello. I am alive!"
  85.  
  86. def run():
  87.   app.run(host='0.0.0.0',port=8080)
  88.  
  89. def keep_alive():
  90.     t = Thread(target=run)
  91.     t.start()
  92. bot = commands.Bot(
  93.   command_prefix='?', #any prefix you want
  94.   case_insensitive=False,
  95.   description=None,
  96.   intents=discord.Intents.all(), #enable intents in discord developer portal
  97.   help_command=None
  98. )
  99.  
  100. @bot.command()
  101. async def test(ctx,*,arg): # * is used to make sure your complete arguement is used rather than first word
  102.   query = ctx.message.content
  103.   response = openai.Completion.create(
  104.     api_key = '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', #put your own api key here, mine doesnt work i deleted mine ?
  105.     model="text-davinci-003",
  106.     prompt=query,
  107.     temperature=0.5,
  108.     max_tokens=60,
  109.     top_p=0.3,
  110.     frequency_penalty=0.5,
  111.     presence_penalty=0.0
  112.   )
  113.   await ctx.channel.send(content=response['choices'][0]['text'].replace(str(query), ""))
  114.  
  115. @bot.event
  116. async def on_ready():
  117.   await bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name=f"Hi"))
  118.   print(f"Logged in as {bot.user.name}")
  119.  
  120. keep_alive()
  121.  
  122.  
  123. bot.run(os.environ['BOT KEY']) #create a secret token named BOT KEY and paste ur token
  124.  
  125. #keep_alive.py -> new file
  126.  
  127. from flask import Flask
  128. from threading import Thread
  129.  
  130. app = Flask('')
  131.  
  132. @app.route('/')
  133. def home():
  134.     return "Hello. I am alive!"
  135.  
  136. def run():
  137.   app.run(host='0.0.0.0',port=8080)
  138.  
  139. def keep_alive():
  140.     t = Thread(target=run)
  141.     t.start()ain.py
  142. import discord
  143. from keep_alive import keep_alive
  144. from discord.ext import commands
  145. import os
  146. import openai
  147.  
  148. #make sure you have import all the above
  149.  
  150. bot = commands.Bot(
  151.   command_prefix='?', #any prefix you want
  152.   case_insensitive=False,
  153.   description=None,
  154.   intents=discord.Intents.all(), #enable intents in discord developer portal
  155.   help_command=None
  156. )
  157.  
  158. @bot.command()
  159. async def test(ctx,*,arg): # * is used to make sure your complete arguement is used rather than first word
  160.   query = ctx.message.content
  161.   response = openai.Completion.create(
  162.     api_key = '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', #put your own api key here, mine doesnt work i deleted mine ?
  163.     model="text-davinci-003",
  164.     prompt=query,
  165.     temperature=0.5,
  166.     max_tokens=60,
  167.     top_p=0.3,
  168.     frequency_penalty=0.5,
  169.     presence_penalty=0.0
  170.   )
  171.   await ctx.channel.send(content=response['choices'][0]['text'].replace(str(query), ""))
  172.  
  173. @bot.event
  174. async def on_ready():
  175.   await bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name=f"Hi"))
  176.   print(f"Logged in as {bot.user.name}")
  177.  
  178. keep_alive()
  179.  
  180.  
  181. bot.run(os.environ['BOT KEY']) #create a secret token named BOT KEY and paste ur token
  182.  
  183. #keep_alive.py -> new file
  184.  
  185. from flask import Flask
  186. from threading import Thread
  187.  
  188. app = Flask('')
  189.  
  190. @app.route('/')
  191. def home():
  192.     return "Hello. I am alive!"
  193.  
  194. def run():
  195.   app.run(host='0.0.0.0',port=8080)
  196.  
  197. def keep_alive():
  198.     t = Thread(target=run)
  199.     t.start()