Cov txheej txheem:
- Kauj ruam 1: Rub tawm Discord App
- Kauj Ruam 2: Teeb Koj Tus Kheej Channel
- Kauj Ruam 3: Nruab Node.js thiab Npm
- Kauj ruam 4: Tsim Bot
- Kauj Ruam 5: Tsim Cov Ntawv Teev Npe Hauv Zos
- Kauj Ruam 6: Kauj Ruam Kawg & Xeem Bot
Video: Yuav Ua Li Cas Ntxiv Kev Sib Tham Hauv Bot hauv Discord: 6 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:24
Hauv qhov kev qhia no kuv yuav qhia yuav ua li cas thiaj tsim tus kheej sib tham sib bot uas ua haujlwm nrog qee tus commandoes.
Discord yog Skype/Whats-app social media app zoo li uas coj cov neeg ua si ua ke. Lawv tuaj yeem muaj tus kheej channel, txheeb xyuas qhov game twg txhua tus tswv cuab ua si, hu ib leeg thiab sib tham nrog ib leeg. Ib qho ntawm qhov muaj peev xwm yog ntxiv bot rau server. Qhov no tuaj yeem yog lub tshuab bot, lossis bot uas ua suab paj nruag piv txwv.
Khoom siv:
- Internet ofcourse (doh!)
- Kev sib cav app
- Node.js, npm
- Kev paub yooj yim ntawm kev ua cov lus txib hauv Terminal
Kauj ruam 1: Rub tawm Discord App
Rub tawm Discord app. Cov app no yog ntau lub cuab yeej app uas tuaj yeem rub tawm los ntawm
Lub npe siv uas koj tsim muaj tus lej tshwj xeeb rau nws txuas nrog, pom zoo li daim duab saum toj no. Koj siv lub npe no + # ntxiv rau lwm tus tswv cuab tsis sib haum.
Kauj Ruam 2: Teeb Koj Tus Kheej Channel
Txhawm rau tsim tus bot, peb yuav tsum ua peb tus kheej lub server.
1. Thaum koj nkag mus rau Discord koj yuav tsum pom qee yam zoo li cov duab saum toj no:
2. Rau tus neeg rau zaub mov los tsim, peb yuav tsum nyem qhov '+' nyob rau hauv qab sab laug ces kaum uas hais lus liab.
Muab koj lub npe server thiab nkag mus rau cheeb tsam server. Optionally koj tuaj yeem ntxiv cov duab rau koj lub server. Thaum koj ua tiav cov theem no, koj yuav tsum pom cov npe neeg rau zaub mov hauv koj tabs nyob rau sab laug, nyob ntawm lub cuab yeej koj nyob.
Kauj Ruam 3: Nruab Node.js thiab Npm
Thaum koj tau ua tiav tsim koj tus kheej server, kev tsis sib haum nug caw cov phooj ywg tuaj rau koj lub server. Hla cov kauj ruam no (lossis caw cov phooj ywg rau koj qhov kev tsis pom zoo siv qhov txuas txuas) thiab voilá! Koj tus kheej server tau ua.
1. Txheeb rau node.js thiab npm
Ua ntej peb yuav tsum ua kom ntseeg tau tias peb yuav tsum ua qhov haujlwm hauv cheeb tsam rau API kom hu xov tooj. Peb tseem yuav tsum tau txais tus cim rau tus bot. Txhawm rau ua qhov no, peb yuav tsum ntxiv qee cov kab hauv lub davhlau ya nyob twg. Txhawm rau qhib lub davhlau ya nyob twg, nias CMD + spacebar thiab tshawb rau lub davhlau ya nyob twg. Yog tias koj ua qhov no raug, lub davhlau ya nyob twg yuav tsum tshwm li cov duab saum toj no.
Txhawm rau txheeb xyuas seb koj puas tau teeb tsa node.js thiab npm, ntaus cov cai hauv qab no:
Rau node.js:
node -v
Rau npm:
npm -v
Yog tias koj ob leeg muaj node.js teeb tsa thiab npm, koj yuav tsum pom cov version, yog tias tsis yog, nruab ob lub node.js thiab npm los ntawm kev nkag mus rau cov cai hauv qab no (node.js yuav raug teeb tsa nrog npm):
Rau npm:
npm nruab npm@latest -g
Kauj ruam 4: Tsim Bot
Peb yuav tsum ua daim ntawv thov thiab bot txhawm rau kom peb bot ua haujlwm. Peb kuj yuav tsum xa nws mus rau peb cov neeg rau zaub mov tsis sib xws.
1. Tsim daim ntawv thov & bot:
Ua ntej, mus rau discordapp.com/developers/applications/me. Nkag mus nrog koj tus account. Nyem Daim Ntawv Thov Tshiab kom pib, thiab muab koj daim ntawv thov lub npe tom qab nyem nyem tsim. Ntawm sab laug tab, xaiv Bot. Tsim tus bot. Yog tias bot tau tsim, koj yuav tau txais cov lus hauv daim duab saum toj no uas bot tau tsim.
2. Xa tus bot rau koj li Discord server
Hauv Cov Ntaub Ntawv Dav Dav, theej koj tus lej ID, luam tus ID thiab muab tso rau hauv qhov URL no, hloov tus lej:
discordapp.com/oauth2/authorize?&client_id…
Luam qhov URL nrog koj tus lej ID tus neeg siv khoom hauv nws rau hauv koj tus browser. Qhov ntawd yuav coj koj mus rau lub vev xaib uas koj tuaj yeem qhia Discord qhov twg yuav xa koj tus bot. Koj yuav paub tias nws ua haujlwm yog tias koj qhib Discord hauv app lossis hauv koj tus browser thiab mus rau koj lub server. Cov channel yuav hais tias bot tau koom nrog chav, thiab koj yuav pom nws ntawm sab xis cov ntawv qhia hauv qab cov npe ntawm cov tswv cuab online.
Kauj Ruam 5: Tsim Cov Ntawv Teev Npe Hauv Zos
Peb yuav tsum ua daim nplaub tshev ntawm koj lub pc uas yuav khaws tag nrho koj cov ntaub ntawv bot. Npe nws qee yam xws li discordBot lossis qee yam uas tuaj yeem lees paub yooj yim.
1. Tsim daim nplaub tshev thiab peb cov ntaub ntawv
Peb yuav tsum tsim peb hauv daim nplaub tshev ntawd.
Ua raws li cov cai hauv qab no hauv lub davhlau ya nyob twg:
mkdir discordBot
Txheeb xyuas txawm tias daim nplaub tshev los ntawm kev ntaus hauv cov cai hauv qab no:
cd discordBot
Tom qab ntawv ntaus kab hauv qab no:
npm init -y
Qhov no yuav tsim ib pob ntawv.json cov ntaub ntawv sab hauv qhov project.
Cia peb pib ua ntej los ntawm kev txhim kho lub tsev qiv ntawv Javascript uas paub zoo rau kev cuam tshuam nrog Discord API hu ua discord.js. Hom hauv:
npm nruab --save discord.js
Tsis quav ntsej cov lus ceeb toom tam sim no.
2. Tsim cov ntaub ntawv rau tus cim
Siv ib qho ntawv sau, tsim cov ntawv thiab npe nws "auth.json".
Muab tshuaj txhuam cov cai hauv qab no:
{
"Token": "Koj Tus lej Token"}
Tom qab ntawd, hloov "Koj Tus lej Token" nrog koj tus cim. Qhov no tuaj yeem pom ntawm:
Nkag mus, Nyem Client Secret thiab hloov pauv Bot Token.
Txuag cov ntawv thiab ua cov ntawv tshiab.
Cov ntaub ntawv tom ntej, npe lub npe ntawv no.json, muab cov cai hauv qab no:
{
"Lub npe": "discordBot", "version": "1.0.0", "kev piav qhia": "Kuv Thawj Qhov Tsis Txaus Ntseeg Bot", "lub ntsiab": "bot.js", "tus sau": "Koj Lub Npe", "kev vam khom ": {}}
Hloov tus sau lub npe nrog lub npe koj xav tau. Txuag cov ntawv no ua "pob.json" hauv koj li Discord bot nplaub tshev.
Thaum kawg, zaum kawg.json cov ntaub ntawv yuav raug hu ua bot.js thiab muab cov lej hauv qab no:
const Discord = xav tau ('discord.js');
const neeg = tshiab Discord. Client (); const auth = xav tau ('./ auth.json'); client.on ('ready', () => {console.log ('Nkag mus rau hauv $ {client.user.tag}!');}); client.on ('message', msg => {if (msg.content === 'ping') {msg.reply ('pong');}}); client.login (auth.token);
Txuag cov ntawv sau kawg no ua "bot.js" hauv koj daim Discord bot nplaub tshev. Kuv ntxiv cov lus txib yooj yim uas yog tias koj hais "ping", tus bot yuav teb nrog "Pong!"
Kauj Ruam 6: Kauj Ruam Kawg & Xeem Bot
1. Qhib davhlau ya nyob twg
Hauv Terminal, peb yuav tsum txheeb xyuas yog tias peb tau ua txhua yam kom raug. Nkag mus rau daim nplaub tshev los ntawm kev ntaus hauv cov lus txib hauv qab no:
cd discordBot
2. Khiav tus bot
Tom qab ntawv kawg, khiav cov lus txib raws li qhia hauv qab no:
node bot.js
Yog tias koj tau ua txhua yam, nws yuav tsum hais tias: Nkag mus rau hauv raws li discordBot#xxxx!
Yog lawm! bot tau ua rau koj cov neeg rau zaub mov tsis sib xws! Koj tuaj yeem xa xov "Ping" hauv cov channel kom tau txais lus teb "Pong!"
Qhov no tsuas yog lub hauv paus yooj yim rau koj cov channel tsis sib xws. Yog xav paub ntau cov tswv yim txheeb xyuas:
Pom zoo:
SASSIE: Cov Txheej Txheem rau Kev Txaus Siab Tsis Txaus Siab thiab Kev Sib Tham Sib Tham: 5 Cov Kauj Ruam
SASSIE: Cov Txheej Txheem rau Kev Txom Nyem Tsis Txaus Siab thiab Kev Sib Tham Sib Tham: SASSIE yog lo lus teb rau lo lus nug peb txhua tus tau nug peb tus kheej thaum muaj kev ntsiag to txawv ntawm ib qho hauv peb lub neej, "Kuv puas yuav tham tom ntej?" Zoo tam sim no koj tsis tas yuav txhawj xeeb vim tias SASSIE tau tsim tshwj xeeb los lees paub qhov txawv txav uas ntsiag to
THIAB LUB NEEJ !! (Sib tham sib tham rooj sib tham): 4 Kauj Ruam
THIAB LUB NEEJ !! (sib tham sib tham txog Thruth Table): Nyob zoo cov phooj ywg, Kuv vam tias koj txhua tus nyob hauv koj lub tsev zoo thiab xav tsis thoob dab tsi ntawm cov ntaub ntawv uas muaj ?? Nkag siab cov rooj vag logic yog qhov tseem ceeb heev rau ob leeg
Cov Neeg Siv Yooj Yim Sib Tham Sib Tham rau Kev Qhia thiab Kev Ntsuam Xyuas: 11 Kauj Ruam
Cov Neeg Siv Yooj Yim Sib Tham Sib Tham rau Kev Qhia thiab Kev Ntsuam Xyuas: Txoj haujlwm no tau tsim los ua ib feem ntawm chav kawm hauv tsev kawm qib siab, lub hom phiaj yog ua kom muaj kev sib tham sib tham los qhia thiab ntsuas qee yam ncauj lus. Rau nws peb tau siv Kev Ua Haujlwm ntawm PC rau lub interface thiab Arduino NANO rau lub khawm arcade thiab LEDs, yog li
Yuav Ua Li Cas Siv IRC (Internet Sib Tham Sib Tham): 5 Kauj Ruam
Yuav Ua Li Cas Siv IRC (Sib Tham Sib Tham Hauv Is Taws Nem): [Kho] Qhov no yog Cov Lus Qhia uas yog lub hauv paus rau cov uas tseem tsis tau nkag siab txog Kev Sib Tham Hauv Is Taws Nem, lossis IRC. Txoj haujlwm no tsis yog npaj los npog tag nrho cov peev txheej ntawm IRC thiab txhua tus neeg siv khoom lub peev xwm, tab sis yog lub hom phiaj kom yeej
Yuav Ua Li Cas Txuas Lub Rooj Sib Tham Sib Tham thiab Microphone Snake rau Lub Suab: 3 Kauj Ruam
Yuav Ua Li Cas Txuas Lub Rooj Sib Tham Sib Tham thiab Microphone Snake rau Lub Suab: Cov vis dis aus npog cov hauv paus ntawm kev txuas lub suab sib xyaw (sib xyaw board lossis console) rau lub suab siv siv lub microphone nab cable. Nws npog lub microphone thiab xa kev sib txuas. Yog xav paub ntxiv: http://proaudiotraining.com