【Proladon】Code a discord bot - EP1 - 基本Bot建置
HTML-код
- Опубликовано: 16 июл 2019
- #discord #bot #python #discord機器人
Python Debug launch 設定(全部覆蓋):
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit github.com/OmniSharp/omnishar...
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current Dir (external)",
"type": "python",
"request": "launch",
"cwd":"${fileDirname}",
"program": "${file}",
"console": "externalTerminal",
"env": {"PYTHONPATH": "${workspaceRoot}"},
},
{
"name": "Python: Current Dir (internal)",
"type": "python",
"request": "launch",
"cwd":"${fileDirname}",
"program": "${file}",
"console": "integratedTerminal",
"env": {"PYTHONPATH": "${workspaceRoot}"},
},
{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
}
]
} Хобби
很多人誤以為我給的launch.json的設定是整個覆蓋,但其實是把我給的加到你們原本的 configurations 裡。
所以我現在乾脆把完整的設定檔丟上來,大家就可以直接複製然後全部覆蓋。
然後debug時 啟動器 請選擇Name是 Current Dir 系列的
(一樣設定碼在影片下方資訊欄)
是Python: Current Dir (external)
還是Python: Current Dir (internal)
@yuuuuu 謝謝
会显示timed out waiting for launcher to connect, 这是怎么回事
想問Proladon用的VScord 跟 cmd 的 shell 是哪一款(好好看~~
感覺閃退的問題可以在最後一行加上
input()
這樣程式會停在等待輸入。按 enter 鍵後才會結束
請問您的CMD怎麼把樣式改成那樣的@@?
請問最後小黑窗要如何叫出來。我照著影片設定了,用Termianl偵錯,最後都跟我說Timed out waiting for launch to connect
Configured debug type 'python' is not supported
怎麽辦
大大您好,我執行後會跳出
No module named 'discord.ext'; 'discord' is not a package
During handling of the above exception, another exception occurred:
這要怎麼處理
不好意思,我想知道第二行導入的discord.ext是做什麼的。
第一行時不是已經導入discord了嗎?
請問那個終端機是wsl 的話在這邊能debug嗎
py第二句 From discord.ext import commands 就已經出錯了 是缺了什麼沒安裝嗎?
F5按了跳出Timed out waiting for launcher to connect,不知怎麼處理
打开debug的时候显示timeout waiting for debugger connection怎么解决
請問debug出現outfiles是發生什麼事?
不好意思老師,請問它顯示
發生例外狀況: TypeError
__init__() missing 1 required positional argument: 'command_prefix'
File "C:\Users\elvia\OneDrive\文件\GitHub\CHING\bot.py", line 5, in
bot = commands.Bot(commands_prefix='#', intents = Intents)
是發生什麼事情?還有它的主控台沒有顯示 >> Bot is online
報錯寫蠻清楚的
missing argument 'command_prefix'
遺失引數 command_prefix
你比對看看你自己打的
機器人的 command 失靈了怎辦??repl上的console跟channel都沒有響應
請問,為何老師在輸入關鍵字的時候會有快捷選項可以選擇呢?要怎麼做到這一部分?
本來就會有
你是否有安裝VSCode 的 Python擴充插件
請問大大,為甚麼我一開始在command_prefix那裏就會開始出錯
两年前的指令,还可以用吗?
請問有辦法可以不用prefix嗎?
可以請問一下要怎麼把visual studio code的字體改成像你那樣還有打字特效
Vscode的插件
搜尋 powermode
大大您好!謝謝你的教學
你知道Inkscape嗎? 我裝了他
結果它內建的python就跟我裝的python衝突在一起了LOL
害我用了好久XD
知道哦 我有雷雕所以也有在用inkspace
但是我並沒有發生衝突這種事
好哦
@@Proladon 為什麼我的bot程式是一職開在我電腦上 我電腦和程式都沒關 但是bot會自己下線?
發生例外狀況: ModuleNotFoundError
No module named 'discord'
File "C:\Users\XXX\OneDrive\文件\GitHub\XXX\bot.py", line 1, in
import discord
你還沒有安裝 discord.py 模組
請看上一集 EP0.5 - 前置作業
ruclips.net/video/ECOabx6Kl6c/видео.html
No value for argument 'command_prefix' in constructor callpylint(no-value-for-parameter) [4,7] 這是哪裡有出錯嗎?
你的程式碼貼上來
為什麼不能寫這條: import discord
按f5
cmd就跳出來
請按任意鍵繼續 . . .
請問
發生例外狀況: TypeError
__init__() missing 1 required positional argument: 'command_prefix'
File "D:\discord_bot\bot.py", line 4, in
bot = commands.Bot(command_preFix='[')
要怎麼辦
你打錯字
prefix 的f是小寫
抱歉是我字體的問題
@@Proladon那第二集的那個留言也拜託解答一下
執行debug時他不會疊加跑一下就跳掉
想詢問一下你的VScode字體名稱XD
我想問一下為甚麼運行後出現[按任意鍵繼續...]?
如果只出現這行字 代表你程式直接運行結束
你一定是程式碼沒寫對...
Import discord 不可用,怎么解决这个问题
請教 發生例外狀況: ModuleNotFoundError (note: full exception trace is shown but execution is paused at: )
No module named 'discord'
File "C:\Users\5168\Desktop\python\BOT_python.py", line 1, in (Current frame)
import discord
在list裡面確認過他在 也刪除重新載了 狀況依然沒有改善
meto
版本問題我搞好久才解決,現在pip安裝discord.py的話 因為都給你安裝新版本,新版本的discord.py通常需要python 3.8.0以上才可正常運行
@@Xia_yix原來如此 謝謝大大
Import "discord" could not be resolved Pylance(reportMissingImports) [1, 8]是什麼問題?
我也是這樣...
我在用偵錯的時候他跟我說
發生例外狀況: ModuleNotFoundError
No module named 'discord'
File "C:\Users\wt960\Documents\GitHub\discord.bot\bot.py", line 1, in
import discord
請問是甚麼意思啊 不知道該怎麼處理
你還沒有安裝discord插件
大大,我想請教問在mac上discord憑證過期要如何安裝?謝謝
在 Application/python xx 目錄下 執行 install cerfificates.command
__init__() missing 1 required positional argument: 'command_prefix
不知道少了什麼
Cannot close a running event loop
↑
不好意思 超級新手才剛操作
按下F5就出現這個問題了
請問該如何解決
沒遇過 看起來是tasks卡住
你可以試試:
1. 重開機
2. 重新生成一組token
我的powermode沒有用@.@
為何我在寫bot時
from discord.ext import commands
他無法辨識.ext 和 commands
我也是
發生例外狀況: TypeError
BotBase.__init__() missing 1 required keyword-only argument: 'intents'
File "C:\Users\USER\Documents\GitHub\bot\bot.py", line 4, in
bot = commands.Bot(command_prefix='!')
這樣是出了甚麼狀況,要怎麼解決
我在網路上查到的,bot = commands.Bot(command_prefix='!')這串可以拿掉換# after之後的那兩串
# before
client = discord.Client()
# after
intents = discord.Intents.default()
client = discord.Client(intents=intents)
為什麼我的launch會出現End of file expected. jsonc(0) [7,2]
你某一行少了一個大括號
請教一下, 出現這個問題:
invalid syntax (, line 2)
Line 2 :
import discord
From discord.ext import commands
discord.py安裝了
怎麽辦?
invalid syntax line2
第二行程式碼語法錯誤
from 的 f 是小寫
thx it solved!
我會run time error
怎麼辦
爲什麽會顯示 invalid syntax (, line 2)
你第二行有語法錯誤
您好 從9/1開始 discord bot的呼叫器似乎整合了起來... 那變成有些模組似乎不一樣 請問可以拍一段解說影片嗎?
正在計畫 但應該會轉 djs
@@Proladon 嗯...因為目前有學的只有py能力QQ
請問能解說一集bot.py 跟 main.py的改寫嗎? 目前只卡在整合那邊在 / 的指令中不知道該如何增加而已...
老師在bot.run(token)那行 出現Exception has occurred: RuntimeError
SSL is not supported.
File "C:\Users\william\ausbot\bot.py", line 10, in
bot.run('Njk4MzY0Nzg0MzY5ODYwNzA4.XpOE0A.nIL5qbnj8dRMsOi9f0hlcyWwuYo')
怎麼解決?
這是只有 MAC OS 才會有的問題
解答請參考:
github.com/Rapptz/discord.py/issues/1031
@@Proladon 我的是win10
我的VS Code顯示第二行的
from discord.ext import commands
是找不到discord這個有效的package?
github.com/SHELTER-ZONE/Discord_Bot_FAQ/blob/master/discord.py_FAQ.md#import-discordpy-時找不到-discordpy-模組
所以...我應該把discord.py的檔案放到我的工作區?
大大 請問一下 因為你的教學有點多了
想請問有沒有讓機器人定時打字到聊天頁面上
比如說 每1分鐘 在聊天頁面打 你好 這樣
寫一個loop 每1分鐘重複就好
Traceback (most recent call last):
File "C:\Users\GIGA01\Desktop\賭錢機器人\bot.py", line 4, in
bot = commands.bot(command_prefix='$')
TypeError: 'module' object is not callable
我確定有安裝discord模組 請問為什麼無法運行
commands.Bot
Bot 是大寫B
@@Proladon 謝謝
請問.....已經成功pip install discord.py了
但在終端機執行時卻頻頻顯示Unable to import 'discord'和Unable to import 'discord.ext'
請問這是為什麼呢.......
你電腦裡是不是有安裝2個以上版本的Python
@@Proladon 我也有同樣的問題 裝了python 3.7和3.8還是一樣
@@Proladon我也是無法import 我本身裝了python3.7跟winpython還有vs code
基本上這狀況就是你們電腦裡裝了兩個以上的python版本, pip install discord.py的時候是裝在其中一個python版本上, 但vscode裡又是執行另一個版本的python
@@Proladon 原來如此 感謝
BotBase.__init__() missing 1 required keyword-only argument: 'intents'
File "D:\XXX\XXX\XXX\Discord\bot.py", line 4, in
bot = commands.Bot(command_prefix='[')
請問為什麼無法運行
解法在這集
ruclips.net/video/clqFPOJkkrI/видео.html
發生例外狀況: ModuleNotFoundError
No module named 'discord'
File "E:\WK\bot.py", line 1, in
import discord
whyyyy
shelter-zone.github.io/Discord_Bot_FAQ/python/#import-discord-py-時找不到-discord-py-模組
這是什麼意思啊qwq 哪裡弄錯了
TypeError
BotBase.__init__() missing 1 required keyword-only argument: 'intents'
File "C:\Users\hudso\OneDrive\桌面\1\1.py", line 4, in
bot = commands.Bot(command_prefix='[')
intents = discord.Intents.default()
bot = commands.Bot(command_prefix='[' intents=intents)
把這個覆蓋掉bot = commands.Bot(command_prefix='[')
RuntimeError: Event loop is closed 能否解決
這問題的確是很奇怪 老實說我也沒遇過 都是留言有問
建議可以先試試看下列兩種方法:
1. 重開機
2. 重新生成 Token
順便可以跟我說哪個有效 還是都無效
@@Proladon 我其實有發現你當時的py與現在的py是不一樣的,我猜想這或許有關係,但應該影響不大,只是我怎麼設定,連解除安裝都試過了,還是一樣,不然我在試試,不行我在到粉絲專頁私訊老師,不然老師要到這裡收訊息有點麻煩(怕.jpg
@@Proladon 老師果然厲害!我更換Token就正常了,但在這裡我也發現到一個小問題,我從筆電更換到其他電腦就會發生,話說簡單點,就是路徑影響執行,我覺得Token不至於會影響,但既然都影響了,這或許可以給新手一個小提示!總之機器正常運行!感謝Proladon老師指導owo
用3.8之前的版本會報錯
大大我有裝discord.py可是出現這個
File "c:\Users\lilac\OneDrive\桌面\python bot\bot.py", line 2
From discord.ext import commands
^^^^^^^
SyntaxError: invalid syntax
請問怎辦????
from的f是小寫 不是大寫
@@user-mm5yw5is5xthx
抱歉打擾 以解決
請問要怎麼把Token更改為字串?
甚麼意思… 不是本來就是字串嗎…
@@Proladon 也可能是我聽錯,你在影片說要更改成另一個東西,才能正常運作
在token前後加''
我把prom改成from後還是一直有語法錯誤的問題 求解?
from 的語法錯誤, 如果能正常執行就不用裡他,那是設定問題,我自己也都會有那個錯誤
謝謝
發生例外狀況: TypeError
__init__() missing 1 required positional argument: 'command_prefix'
File "C:\Users\Administrator\Desktop\Trash\GitHub\OAO\bot.py", line 4, in
bot = commands.Bot(command_prefix_='[') 請問一下這個要怎麼解決?
你打錯字
"command_prefix"
不是 "command_prefix_"
@@Proladon OH! 現在好了 謝謝
沒有電腦怎麼辦
SyntaxError: invalid syntax这个怎么修复
代表你某行程式碼語法錯誤
你沒給完整報錯訊息與你的程式碼
我無法知道你是寫了什麼東西與哪行錯了
請問有上一集的連結嗎?(抱歉我找不到QQ......)
這系列的播放清單
其實你到我頻道就能找到了
ruclips.net/p/PLSCgthA1Anif1w6mKM3O6xlBGGypXtrtN
@@Proladon 謝謝您(๑´ㅂ`๑)
這甚麼問題...我用了好幾天都搞定不了
發生例外狀況: TypeError
BotBase.__init__() missing 1 required keyword-only argument: 'intents'
File "D:\Work spaces\Project_1\bot.py", line 4, in
bot = commands.Bot(command_prefix= '!')
這些是我安裝的東西:
aiohttp 3.8.1
aiosignal 1.2.0
async-timeout 4.0.2
attrs 22.1.0
charset-normalizer 2.1.1
discord.py 2.0.0
frozenlist 1.3.1
idna 3.3
multidict 6.0.2
pip 22.0.4
setuptools 58.1.0
yarl 1.8.1
ruclips.net/video/clqFPOJkkrI/видео.html
我剛剛也遇到類似的問題,點進這則留言底下大佬給的連結後才知道大概要怎麼做,這邊我就把方法簡化:
把原本的:
bot = commands.Bot(command_prefix='[')
改成:
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='[', intents=intents)
詳細原因可以點版主(?)給的連結
至少我是這樣就解決問題的:)
我想請教一下 有辦法用bat 一次啟動全部機器人嗎?
我自己用了五隻機器人
你可以試著把5個機器人的功能合在一個機器人上
寫程式若沒基礎概念說真的不是很好懂ww
對啊 所以其實這影片也是順便推廣大家一起來寫程式
請問字體要怎麼加
就是font
4:31 那要怎麼用?
選取後 按 單引號‘ 或是 雙引號“
@@Proladon 謝謝
發生例外狀況: ModuleNotFoundError
No module named 'discord'
File "C:\Users\XXXXX\OneDrive\桌面\檔案\Work Space\Discord Bot 1\bot.py", line 1, in
import discord
remember to install discord module in python
(pip install discord.py)
我可能需要你的幫忙
無法debug是甚麼問題
跳出紅框寫例外狀況 好像是無法連接discord
我不會通靈 抱歉
您好我打的有些指令沒顏色但你的卻有為甚麼,而且他沒有說有錯誤但機器人沒有上線
不好意思你這句文法好像怪怪的 看不太懂lol
關於沒報錯地的部分你可能是VSCode沒有安裝 Python的擴充還有Pylint
可以使用 pip install pylint 安裝
另外VSCode參考這支影片
ruclips.net/video/odIQEJW0m1M/видео.html
不知道你们谁出现过以下报错:
发生异常: ClientConnectorError
Cannot connect to host discordapp.com:443 ssl:default [Connect call failed ('xx.xx.xx.xxx', 443)]
File "D:\GitHub\Stripe-Bot\bot.py", line 11, in
bot.run('NzExMDYyODUyM87dfadfsadfdfd32er33kIW0VmX8H185ZHTw')
原以为是翻墙问题,后来翻墙后还是一样报错,谁能帮我一下吗?》
抱歉留言太多常常會被蓋掉,,你這問題我查了個遍真的沒什麼人遇過,所以也找不到確切的解決方案。
類似的問題你試試看以下的解決方案能不能行:
stackoverflow.com/questions/62102897/certifacte-verify-failed-certificate-has-expired-ssl-c1108
Proladon 后来我更换VPN翻墙就好了。原来是因为用socket5翻墙只是应用层可以通过网络代理而底层不能通过代理。其实就是要真正全局代理才可以解决。很感谢你回复我。你的教程很好👍我学完了,也写出一个小项目了。感谢🙏
No module named 'discord' 他會寫這樣..
電腦重開機看看
老師您好,我在按F5那一步後,他會跳出「您沒有用於偵錯純文字的延伸模組,我們是否要在Marketplace中尋找純文字延伸模組?」但是我安裝了兩個有關的模組,他還是會跳出這個訊息,請問該怎麼解決?圖片:imgur.com/a/iTyJZOX
如果是出現以下這種情況呢
Exception has occurred: TypeError
BotBase.__init__() missing 1 required keyword-only argument: 'intents'
File "C:\Users\user\Documents\GitHub\2024-AWECAN\2024-AWECAN\bot.py", line 4, in
bot = commands.Bot(command_prefix='[')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix=' !')
@bot.event
async def on_ready():
print(">>Bot is online
PS C:\Users\SUBI\Documents\GitHub> & C:/Users/SUBI/AppData/Local/Programs/Python/Python36/python.exe c:/Users/SUBI/Documents/GitHub/e_But/bot.py
File "c:/Users/SUBI/Documents/GitHub/e_But/bot.py", line 4
bot = commands.Bot{command_prefix='['}
^
SyntaxError: invalid syntax
為什麼無法運行?
語法錯誤
()不是 {}
import discord
from discord.ext import commands
bot = commands.Bot(command_prepix='.')
@bot.event
async def on_ready():
print("機器人已被啟動")
bot.run('TOKEN')
發生例外狀況: TypeError
BotBase.__init__() missing 1 required positional argument: 'command_prefix'
File "C:\Users\User\Documents\GitHub\1.bot\BOT.py", line 4, in
bot = commands.Bot(command_prepix='.')
請問這要怎麼處理