Code a Discord Bot in Java with Discord JDA! (Episode 3: Events & Roles)

preview_player
Показать описание
Hello. In this episode, we'll go over how to use events as well as apply roles to a user when the join a server!

» Links

Disclaimer: Any/all songs used in this video are/may be protected by copyright. I by no means take credit for them; please read the "Music Used" section of the description for more information.

» Music Used
‣  engelwood - barbecue music
‣  linanthem - gone
‣  jef2 - one for Jun
‣  slr - break
‣  Pryces - Sango Flip
‣  jef - lovely day
‣  Jack Elphick - Keep On Going (Instrumental)

Рекомендации по теме
Комментарии
Автор

getController was removed in JDA 4 so here I've found a solution for those, who are still watching this video:


Old: event.getGuild().getController().addRolesToMember(event.getMember(), event.getGuild().getRolesByName("Member", true)).complete();


New: event.getGuild().modifyMemberRoles(event.getMember(), event.getGuild().getRolesByName("Member", true)).complete();

RobertLoewen
Автор

Heres a bigger list (All of them)
String[] messages = {
"[member] joined. You must construct addition pylons!",
"Never gonna give [member] up! Never gonna let [member] down!",
"Hey! Listen! [member] has joined!",
"Ha! [member] has joined! You activated my trap card!",
"We've been expecting you, [member].",
"It's dangerous to go alone, take [member]!",
"Swoooosh. [member] just landed.",
"Brace yourselves. [member] just joined the server.",
"A wild [member] appeared.",
"[member] just slid into the server!",
"Ermagherd. [member] is here.",
"[member] joined your party.",
"[member] just joined the server. - glhf",
"[member] just joined. Everyone, look busy!",
"[member] just joined. Can I get a heal?",
"Welcome, [member]. Stay awhile and listen",
"Welcome, [member]. Leave your weapons by the door.",
"Welcome, [member]. We hope you brought pizza.",
"Brace yourselves. [member] just joined the server.",
"[member] just joined. Hide your bananas.",
"[member] just arrived. Seems OP - please nerf.",
"A [member] has spawned in the server.",
"Big [member] showed up!",
"Where’s [member]? In the server!",
"[member] hopped into the server. Kangaroo!!",
"[member] just showed up. Hold my beer.",
"Challenger approaching - [member] has appeared!",
"It's a bird! It's a plane! Nevermind, it's just [member].",
"It's [member]! Praise the sun! [T]/",
"Roses are red, violets are blue, [member] joined this server with you",
"Hello. Is it [member] you're looking for?",
"[member] is here to kick butt and chew bubblegum. And [member] is all out of gum.",
"[member] has arrived. Party's over.",
"Ready player [member]"
};

ChillNationHDRemixes
Автор

These videos are quite something, very entertaining and engaging hahah. Haven’t coded something in a while so this is a good way to get back into it.

HuggingPretzel
Автор

This is sooo much better than reading the damn docs. Great video!

morsflattbrdoffisiell
Автор

Dude it helped out so much. Thanks for doing these videos.

fiQmeister
Автор

Anyone here when it's still 360p? :D

sys.overflow
Автор

I have a problem with the bot.

everytime I run the code, the embeds repeat itself for numbers of time I ran code, with .clear() that don't happen but instead .clear don't allow me to update anything of the embeds

Hopefully someone will understand and will know what to do

Sorry for my bad english

khalidnecron
Автор

sad how on every tutorial series ever the views decrease every episode from people giving up

Sqwify
Автор

I did as you, but, when it comes to add a role, I have this issue: Can't modify a role with higher or equal highest role than yourself!

I don't understand why this hierarchical problem. I gave to the bot the permission to work as an admin and I gave to also the Member role. Could someone help me?

cezarlupu
Автор

how do I make it go to a certain channel instead of the default one

swurvinq
Автор

thank you :)
I am looking for some kind of desktop notification for online and offline status, something like a toastr notif, do you know what do i need?
Great vids.

marvi
Автор

Use the following to add the role to the user:

event.getGuild().addRoleToMember(event.getMember(), event.getGuild().getRolesByName("ROLE_NAME", true).get(0)).complete();

This returns and adds the first role with that name, which is the role you want to add.

radishmouse
Автор

Hey, thanks for all your help! Is there a option to make these Embeds disappear after a few seconds if so could you do a video about that? Thank you

valentinlorenz
Автор

Thx for the tutorial!
I got a little request/question...
How do you get the Channelname the bot is in and how do you post images? I was messing around a bit and i managed to put a image in the embed but it only worked once, for some reason. Or it just takes really long to load... But if you could make a tutorial on that, that'd be great ^^
Or you could just give me a brief answer as a comment. I'd really appreaciate it :)

flockenlp
Автор

This fun to watch somehow, and your video is enjoyable, even though I already know what're you talking about.
Can you make more advanced tutorial? Like making cooldowns.
I already tried jumbling with making Command Core, and extends them to a bunch of commands. But the core itself can't set the cooldown properly.
Hey, thanks in advance. Good video, keep going! Try kotlin next time.

ハロクレアチブスタジオ
Автор

upload something to your gaming Great vid btw

zerohacks
Автор

can you install a permission
that not everyone can execute the commands?

fallenbreak
Автор

Hey, i want to add a command for !setchannel for the member remove event. Do you know how i can make that?

rzzer
Автор

This is not working anymore (or at least for me) anyone can help me?

BroIamBro
Автор

oh crap this is big
String[] messages = {
"[member] joined. You must construct addition pylons!",
"Never gonna give [member] up! Never gonna let [member] down!",
"Hey! Listen! [member] has joined!",
"Ha! [member] has joined! You activated my trap card!",
"We've been expecting you, [member].",
"It's dangerous to go alone, take [member]!",
"Swoooosh. [member] just landed.",
"Brace yourselves. [member] just joined the server.",
"A wild [member] appeared.",
"[member] just slid into the server!",
"Ermagherd. [member] is here.",
"[member] joined your party.",
"[member] just joined the server. - glhf",
"[member] just joined. Everyone, look busy!",
"[member] just joined. Can I get a heal?",
"Welcome, [member]. Stay awhile and listen",
"Welcome, [member]. Leave your weapons by the door.",
"Welcome, [member]. We hope you brought pizza.",
"Brace yourselves. [member] just joined the server.",
"[member] just joined. Hide your bananas.",
"[member] just arrived. Seems OP - please nerf.",
"A [member] has spawned in the server.",
"Big [member] showed up!",
"Where’s [member]? In the server!",
"[member] hopped into the server. Kangaroo!!",
"[member] just showed up. Hold my beer.",
"Challenger approaching - [member] has appeared!",
"It's a bird! It's a plane! Nevermind, it's just [member].",
"It's [member]! Praise the sun! [T]/",
"Roses are red, violets are blue, [member] joined this server with you",
"Hello. Is it [member] you're looking for?",
"[member] is here to kick butt and chew bubblegum. And [member] is all out of gum.",
"[member] has arrived. Party's over.",
"Ready player [member]",
"Look! [member] has OP items! Oh no RUN!",
"Look! It's my mom! oh wait its my dad! oh nvm its just [member] chillin",
"[member] have fun ok bye bye",
"Hey! We have a new pogger in town his name is called [member]",
"[member] is finally here lets get this party started!",
"[member] is here! Play minecraft NOW!"
};

hdfsyu