Making a Discord Bot in Python (Part 2: Events)

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ธ.ค. 2024

ความคิดเห็น • 131

  • @retroapple8906
    @retroapple8906 2 ปีที่แล้ว +40

    For the people that is having the problem in the "async def print_message(event):" and it says “none” Go to your Discord Developer Console and under the Bot section click "Message Content Intent".

    • @matroy
      @matroy 2 ปีที่แล้ว

      thanks

    • @matroy
      @matroy 2 ปีที่แล้ว +1

      How do you restart the bot? what button does he click? I always start a new terminal but i wanna do it like he does

    • @retroapple8906
      @retroapple8906 2 ปีที่แล้ว +2

      @@matroy If you are on Windows do “Ctlr+C” if your not on windows here are some other commands to try “Cltr+D”, “Ctlr+Z then Return”.

    • @matroy
      @matroy 2 ปีที่แล้ว

      @Kevin Gaming ok

    • @tacotalbert8729
      @tacotalbert8729 2 ปีที่แล้ว +6

      I know this a while ago, but I still am having the none message, even with Message Content Intent on, so idk.

  • @andeemengaming5000
    @andeemengaming5000 2 ปีที่แล้ว +5

    welcome back, king. you're the first dude i checked out when i began with python in sept 2020. ever so greatful to ya. keep up the good work

  • @thechristiantaco
    @thechristiantaco 2 ปีที่แล้ว +1

    This has been the most helpful series for a new programmer to learn discord bots, and its only part 2!!!
    thanks!!!!

  • @Lucas-tz3jp
    @Lucas-tz3jp  2 ปีที่แล้ว +51

    It is so hard to record takes where I don't cough. I hate being sick 😡

  • @triopical6884
    @triopical6884 2 ปีที่แล้ว +1

    Man, the way that you teach and everything is so wonderful.
    Keep it up!

  • @AniSeason
    @AniSeason 2 ปีที่แล้ว +2

    You are really good at teaching

  • @735c7
    @735c7 2 ปีที่แล้ว +15

    i found a fixed step 1. go to your developer portal > go where it says bot turn on MESSAGE CONTENT INTENT, SERVER MEMBERS INTENT, PRESENCE INTENT. than now try loading your bot. if that doesnt work heres a code: bot = hikari.GatewayBot(token=' ', intents=hikari.Intents.ALL) this code should fix the problem!! thank me later!

    • @m666rkin
      @m666rkin 2 ปีที่แล้ว

      thanks bro, that fixed my issue. :)

    • @maisonfifty4383
      @maisonfifty4383 2 ปีที่แล้ว

      OMG Thank you sooooo muchhhhh!!! i've been following many many tutorial for simple bot and just now can receive message

    • @JoeJoe-on3fu
      @JoeJoe-on3fu 2 ปีที่แล้ว

      thank you bro

    • @Kaibutsudareda
      @Kaibutsudareda ปีที่แล้ว

      thank u bro

    • @papajowapapaja2759
      @papajowapapaja2759 ปีที่แล้ว

      OMG THX

  • @Lusk7741
    @Lusk7741 2 ปีที่แล้ว +2

    Excellent tutorial(s)! I've actually got a couple video ideas for ya based on some ideas I've had that I haven't fully pursued yet. I know solutions already exist for 2 of the 3, but I'm a big fan of figuring out how things like this work. They might be a bit complicated or outside of the scope of these videos, but just throwing some ideas out there.
    I'm a big gamer, so the first idea I had would be a sort of "looking for group" bot. Say someone types an "!lfg" command, the bot will ask them a few questions privately (most likely through DM? maybe through a form in the same channel?) such as "what class/role are you? what minimum item level are you expecting from your party members, if any? what type of content will you be doing? etc" and make a post about it with all the details filled in. From there, the bot could react to its own comment with appropriate emojis consisting of the remaining roles required. As people react, it adds them to the queue, allowing the original poster to approve or deny, then it modifies the post to reflect what's left.
    Another idea (that I've already seen in action, but would be curious as to how it would be created) would be one that creates dynamic voice channels. Say a user clicks the top voice channel titled "Create channel". It would then create a new channel below that with the user's name and put the user into it. Once the channel is empty, it deletes the channel.
    The third concept I'd be curious about would be a sort of ticketing system. There's a main post with a reaction that says "click to create a ticket" or something to that effect. User clicks it, the bot essentially opens a form allowing the user to enter info. Based on that, the bot will create a new chat channel that only the mod group and the user can see, and that will contain the previously entered data. It'll mention the mod group, they'll work the ticket, and when they mark it complete (unsure how to handle this), the chat channel gets removed.
    Sorry for the wall of text! These are just a few ideas I've thought about and/or have seen in the past and have been truly curious how they would work. I've been messing around with creating an LFG bot for a few months now and have shifted directions a handful of times, so I'd be genuinely curious to see how someone with actual experience would go about tackling it.

  • @selo2410
    @selo2410 2 ปีที่แล้ว

    Thanks for coming back!!!

  • @thechristiantaco
    @thechristiantaco 2 ปีที่แล้ว +2

    Hey Lucas can you do a Hikari walk-through like how to use the modules and what the modules do? I am new to programming and I still don't quite understand all of the lingo when reading their documentation. Looking forward to the next discord bot tutorial!!

    • @justsomeguy6545
      @justsomeguy6545 2 ปีที่แล้ว

      You should learn basic programming before making discord bots it will make your life so much easier

  • @dsag253
    @dsag253 2 ปีที่แล้ว +2

    nice video as always

  • @xgreymory2667
    @xgreymory2667 2 ปีที่แล้ว

    bro good command to see someone talking without being known

  • @itzgen_z9634
    @itzgen_z9634 2 ปีที่แล้ว

    Ur Excellent Mate!!!! U deserve more subcribers.
    Btw this is a question from my side:- Why don't u like try recording the whole bot coding like commands and events like what u just did right now and the other stuff for hosting the bot online 24/7 like that in like 1 video So that if any error we can easily resolve it insted of opening a wrong file and stuff like that.... (I meant no offence in this so pls try to understand)

  • @kameblitz
    @kameblitz 2 ปีที่แล้ว +6

    Thanks can you upload videos at the same consistency in future as well if possible?

    • @Lucas-tz3jp
      @Lucas-tz3jp  2 ปีที่แล้ว +4

      Ill try but there's really no guarantee. My classes start up again soon and who knows what else might impede on my ability to make videos in the future

    • @kameblitz
      @kameblitz 2 ปีที่แล้ว +3

      @@Lucas-tz3jp It's ok at least you're trying so best of luck :)

  • @wolfram4728
    @wolfram4728 2 ปีที่แล้ว

    Great tutorial! Thanks a lot 👍

  • @unoriginalcontent1514
    @unoriginalcontent1514 2 ปีที่แล้ว +4

    how did you restart the bot? is it a keyboard combination or something else

    • @kriszenn1125
      @kriszenn1125 2 ปีที่แล้ว

      ctrl-c
      terminates the python program

  • @alexanderkalchev188
    @alexanderkalchev188 2 ปีที่แล้ว

    Amazing tutorial!

  • @keno7166
    @keno7166 2 ปีที่แล้ว +1

    I'm having problems with the bot printing out "None" and before you comment Retro Apple, I HAVE turned on Message Content Intent, reset the bot, executed new terminal and it still does not work :/

    • @maisonfifty4383
      @maisonfifty4383 2 ปีที่แล้ว

      my bot didn't print out anythingggg

    • @keno7166
      @keno7166 2 ปีที่แล้ว

      @@maisonfifty4383 this hella broken 😭

  • @richo__459
    @richo__459 2 ปีที่แล้ว +3

    Hey man, I'm a bit late to this video so you probably won't see this, but when I do the print(event.content) and I type in chat it returns "None". I've copied the code exactly so do you have any ideas?

    • @astarrobotics
      @astarrobotics 2 ปีที่แล้ว +2

      I have this same issue. Lmk if you fix it

    • @astarrobotics
      @astarrobotics 2 ปีที่แล้ว +8

      Go to your discord developer console. Go to the bot section. Turn on "message content intent". This fixed it for me

    • @Tomqnto
      @Tomqnto 2 ปีที่แล้ว

      Same

    • @Tomqnto
      @Tomqnto 2 ปีที่แล้ว

      @@astarrobotics tysm dude, u saved me.

    • @kiaryy1897
      @kiaryy1897 2 ปีที่แล้ว

      @@astarrobotics it doesn't work for me :c

  • @shauryapalaparthy6934
    @shauryapalaparthy6934 ปีที่แล้ว

    bro whenever i say a message in my server it just outputs none 4:02 i followed everything right what do i do

  • @coolkase_real
    @coolkase_real 2 ปีที่แล้ว +2

    just wanted to say i think Hikari got a update because now its only printing if i tag the bot

  • @mohaytham7832
    @mohaytham7832 2 ปีที่แล้ว

    Great video man!
    But can I send DMs to a user when he joins my server? ..like a welcoming message but DM not in a channel

  • @stombots479
    @stombots479 2 ปีที่แล้ว

    Great Video! Are you going to show us how to add slash commands?

  • @veiisk
    @veiisk 2 ปีที่แล้ว +1

    when i type in my discord the vs code terminal says "none" but everything else runs perfect. To be specific = if i type "hi" in discord, it says "none" in the the terminal. ideas?

    • @retroapple8906
      @retroapple8906 2 ปีที่แล้ว +2

      Enable “Message Content Intent” in the Discord Developer Console, under the Bot section

    • @jessdlyn21
      @jessdlyn21 2 ปีที่แล้ว

      @@retroapple8906 MVP

    • @antleg100
      @antleg100 ปีที่แล้ว

      I may be 10 months too late lol but the intents can also be changed within the code. For mine, I enabled all of them using
      intents = hikari.Intents(hikari.Intents.ALL)
      bot = hikari.GatewayBot(token='yourtokengoeshere', intents=intents)

  • @DarkblooM_IO
    @DarkblooM_IO ปีที่แล้ว

    If your bot is returning None when sending a message, try this line:
    -> bot = hikari.GatewayBot(intents=hikari.Intents.ALL, token=token)

  • @rpfl5059
    @rpfl5059 2 ปีที่แล้ว

    Thank-you

  • @just_andro
    @just_andro 2 ปีที่แล้ว +1

    What is easier to use nextcord or Hikari i really need your opinion

  • @maathewchen7231
    @maathewchen7231 2 ปีที่แล้ว

    i copied his exact code. when i ran it and typed something in the discord sever, it will say 'None' in the terminal instead of the letters i typed in the sever

  • @oz9985
    @oz9985 2 ปีที่แล้ว

    hey id love to get messaage vents from yeeti bot when new players join it gives info and id like to read that info but it doesnt

  • @PitersChannel
    @PitersChannel 2 ปีที่แล้ว

    Nice tutorial! Hope to see an episode on lightbulb commands!

    • @swarnimmarathe1613
      @swarnimmarathe1613 2 ปีที่แล้ว

      @Yvezzaint it is a command handler

    • @PitersChannel
      @PitersChannel 2 ปีที่แล้ว

      @Yvezzaint It's a command handler for hikari, because it doesn't have one by default

  • @squeed77
    @squeed77 2 ปีที่แล้ว

    how do i make it show the user and the channel that the message was sent in?

  • @maniccFN
    @maniccFN 2 ปีที่แล้ว

    What color theme do you use?

  • @anamoyeee
    @anamoyeee 2 ปีที่แล้ว +6

    Hi, i'm trying to set up my bot but it keeps returning None as the message content, i did everthing exactly as you showed in the tutorial but it doesn't work. Is there anything i can do to fix it?
    Edit: SOLUTION: it turns out you need to specify so called 'intents' after August 31st 2022, just after token="..." add ,intents=hikari.Intents.ALL so it looks like this:
    bot = hikari.GatewayBot(token="your token here", intents=hikari.Intents.ALL)

    • @LucasBubuOppenheimer
      @LucasBubuOppenheimer 2 ปีที่แล้ว

      i did that but then i got "hikari.errors.GatewayServerClosedConnectionError: Server closed connection with cod" in the terminal and i have been messing around with it but nothing so afar
      uupdate= i fixed my issue kind of , i change the intent to All_DMS and instead of hikari.GUILDMessageCreateEvent i idid hikari.DMMessageCreateEvent which makes it only work for dms with the bot

    • @diabolicaltricks8384
      @diabolicaltricks8384 2 ปีที่แล้ว

      @@LucasBubuOppenheimer If u want hikari.Intents.ALL to work u have to go to the discord developer console, the place we created the bot and got the token and enable all intents in the bot section

    • @superiormansex2011
      @superiormansex2011 2 ปีที่แล้ว

      Thank you so much for the comment and solution!

    • @anamoyeee
      @anamoyeee 2 ปีที่แล้ว

      @@superiormansex2011 Glad i helped!

    • @danielsoden5745
      @danielsoden5745 9 หลายเดือนก่อน

      you're a legend fr

  • @umaruta4
    @umaruta4 2 ปีที่แล้ว +1

    How do you change prefix in hikari? do I need lightbulb for that?

    • @thomm.o7782
      @thomm.o7782 2 ปีที่แล้ว

      You need a command handler for that. Lightbulb is an example of one of those

    • @umaruta4
      @umaruta4 2 ปีที่แล้ว

      @@thomm.o7782 I see, thank you for the response

  • @im_the_raymond
    @im_the_raymond 2 ปีที่แล้ว

    Why you are laughing in the end XD XD XD XD XD

  • @oofgaming4418
    @oofgaming4418 ปีที่แล้ว

    it is not working for me in vscode i have tryed recoding it 5 times and it still did not work using hikari 2.0.0.dev115

  • @petershepherd447
    @petershepherd447 2 ปีที่แล้ว

    When I enter a message into discord, event.content returns None. Can anyone help, please? Thanks

  • @ArtistUniverseUntouched
    @ArtistUniverseUntouched 2 ปีที่แล้ว

    So I want to parse RSS news to a channel but not sure how to go about it. How do I tell my bot to get the news and put it into my channel?

  • @CyberphobiaYT
    @CyberphobiaYT 2 ปีที่แล้ว

    will this include slash commands?

  • @mrXcrossM
    @mrXcrossM 2 ปีที่แล้ว

    To turn of the bot do Ctrl + C

  • @Nick-cm7jf
    @Nick-cm7jf 2 ปีที่แล้ว

    I still don't understand what events are, are they important? Or can I skip this part. Also, what is hikari?

  • @rpfl5059
    @rpfl5059 2 ปีที่แล้ว

    How to mute and unmute?

  • @skibidicumm
    @skibidicumm 2 ปีที่แล้ว

    Where is the code from the last vid

  • @icebear06
    @icebear06 2 ปีที่แล้ว +3

    Why does he record so late? We’ll never know, 8th wonder of the world 🌎

    • @Lucas-tz3jp
      @Lucas-tz3jp  2 ปีที่แล้ว +2

      Peace and quiet 👌

  • @Isaglish
    @Isaglish 2 ปีที่แล้ว

    Why don't you hide your token instead of refreshing it after every video?

  • @unpseudototalementnormal517
    @unpseudototalementnormal517 2 ปีที่แล้ว

    Hello would someone know how to make your bot welcome an user who is joining your server ? thanks in advance, i've been searching that for 5hours i'm going to be crazy lmao

  • @edujime23
    @edujime23 2 ปีที่แล้ว

    after of end with hikari use nextcord pls :)

  • @sanvi4236
    @sanvi4236 2 ปีที่แล้ว

    it might be easier for you to import your token from another file than to refresh it every time you post

  • @smong891
    @smong891 2 ปีที่แล้ว

    12 am nice

  • @SlimeyDev
    @SlimeyDev 2 ปีที่แล้ว +1

    y dont u use pycord?

    • @externref
      @externref 2 ปีที่แล้ว +1

      pycord bad.

    • @SlimeyDev
      @SlimeyDev 2 ปีที่แล้ว

      @@externref no its not

    • @externref
      @externref 2 ปีที่แล้ว +2

      @@SlimeyDev none of the forked libraries are trustworthy until you know how do they work , pycord changed the path of `discord.ext.commands.Bot` to `discord.Bot` which is a big fuss since the command handler and the discord API are not realated technically , if it's an extension it should stay as an extension. The slash command implementations are not too good either , dozens of dev working on slash commands fork such a long time , Disnake is a better fork Alternative imo . Also , hikari is a completely different library and is much more updated than pycord with additional features like full control over the cache so it's for sure better if you want to try something different than discord.py syntax.
      Even discord.py server recommends not to use any kind of forks.

    • @externref
      @externref 2 ปีที่แล้ว

      ^^^ personal opinions afterall

    • @SlimeyDev
      @SlimeyDev 2 ปีที่แล้ว

      @@externref um ok but i just prefer pycord i feel its better to understand but hey! everyone has there own opinions!

  • @pandaa3876
    @pandaa3876 2 ปีที่แล้ว

    with the first event you made, my bot printed None

  • @CarlosEduardo-yo2rz
    @CarlosEduardo-yo2rz 2 ปีที่แล้ว

    Great tutorial!