Facebook
From Khaleel, 1 Year ago, written in Python.
This paste is a reply to Discord Chat bot from Adrian Maximus - view diff
Embed
Download Paste or View Raw
Hits: 262
  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.  
  22. bot = commands.Bot(
  23.   command_prefix='?', #any prefix you want
  24.   case_insensitive=False,
  25.   description=None,
  26.   intents=discord.Intents.all(), #enable intents in discord developer portal
  27.   help_command=None
  28. )
  29.  
  30. @bot.command()
  31. async def test(ctx,*,arg): # * is used to make sure your complete arguement is used rather than first word
  32.   query = ctx.message.content
  33.   response = openai.Completion.create(
  34.     api_key = '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', #put your own api key here, mine doesnt work i deleted mine ?
  35.     model="text-davinci-003",
  36.     prompt=query,
  37.     temperature=0.5,
  38.     max_tokens=60,
  39.     top_p=0.3,
  40.     frequency_penalty=0.5,
  41.     presence_penalty=0.0
  42.   )
  43.   await ctx.channel.send(content=response['choices'][0]['text'].replace(str(query), ""))
  44.  
  45. @bot.event
  46. async def on_ready():
  47.   await bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name=f"Hi"))
  48.   print(f"Logged in as {bot.user.name}")
  49.  
  50. keep_alive()
  51.  
  52.  
  53. bot.run(os.environ['BOT KEY']) #create a secret token named BOT KEY and paste ur token
  54.  
  55. #keep_alive.py -> new file
  56.  
  57. from flask import Flask
  58. from threading import Thread
  59.  
  60. app = Flask('')
  61.  
  62. @app.route('/')
  63. def home():
  64.     return "Hello. I am alive!"
  65.  
  66. def run():
  67.   app.run(host='0.0.0.0',port=8080)
  68.  
  69. def keep_alive():
  70.     t = Thread(target=run)
  71.     t.start()ain.py
  72. import discord
  73. from keep_alive import keep_alive
  74. from discord.ext import commands
  75. import os
  76. import openai
  77.  
  78. #make sure you have import all the above
  79.  
  80. bot = commands.Bot(
  81.   command_prefix='?', #any prefix you want
  82.   case_insensitive=False,
  83.   description=None,
  84.   intents=discord.Intents.all(), #enable intents in discord developer portal
  85.   help_command=None
  86. )
  87.  
  88. @bot.command()
  89. async def test(ctx,*,arg): # * is used to make sure your complete arguement is used rather than first word
  90.   query = ctx.message.content
  91.   response = openai.Completion.create(
  92.     api_key = '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', #put your own api key here, mine doesnt work i deleted mine ?
  93.     model="text-davinci-003",
  94.     prompt=query,
  95.     temperature=0.5,
  96.     max_tokens=60,
  97.     top_p=0.3,
  98.     frequency_penalty=0.5,
  99.     presence_penalty=0.0
  100.   )
  101.   await ctx.channel.send(content=response['choices'][0]['text'].replace(str(query), ""))
  102.  
  103. @bot.event
  104. async def on_ready():
  105.   await bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name=f"Hi"))
  106.   print(f"Logged in as {bot.user.name}")
  107.  
  108. keep_alive()
  109.  
  110.  
  111. bot.run(os.environ['BOT KEY']) #create a secret token named BOT KEY and paste ur token
  112.  
  113. #keep_alive.py -> new file
  114.  
  115. from flask import Flask
  116. from threading import Thread
  117.  
  118. app = Flask('')
  119.  
  120. @app.route('/')
  121. def home():
  122.     return "Hello. I am alive!"
  123.  
  124. def run():
  125.   app.run(host='0.0.0.0',port=8080)
  126.  
  127. def keep_alive():
  128.     t = Thread(target=run)
  129.     t.start()

Replies to Re: Discord Chat bot rss

Title Name Language When
Re: Re: Discord Chat bot Emerald Capybara python 1 Year ago.
Re: Re: Discord Chat bot Scanty Parrot python 1 Year ago.