This repository was archived by the owner on Feb 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.html
128 lines (111 loc) · 5.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---
title: Home
layout: default
---
<div class="front-page-highlight" style="text-align: center">
<div class="container">
<img src="/img/javacord3_banner.png">
</div>
</div>
<div class="container front-page-highlights">
<section>
<h1 class="no-anchor">Why Javacord?</h1>
<div>
<hr>
<div class="row">
<div class="col-lg-2 col-md-3 col-sm-4">
<h1 class="text-center no-anchor faa-parent animated-hover"><i class="fas fa-rocket faa-passing" aria-hidden="true"></i></h1>
<h3 class="text-center no-anchor">It's fast</h3>
</div>
<div class="col-lg-10 col-md-9 col-sm-8">
Unlike most other libraries, Javacord is 100% multithreaded. Not only simple actions like sending messages are
executed asynchronously, but also logging in, event listening, ...
</div>
</div>
<hr>
<div class="row">
<div class="col-lg-2 col-md-3 col-sm-4">
<h1 class="text-center no-anchor"><i class="fa fa-thumbs-up" aria-hidden="true"></i></h1>
<h3 class="text-center no-anchor">It's simple</h3>
</div>
<div class="col-lg-10 col-md-9 col-sm-8">
Javacord is easy to use, both for beginners as well as experienced Java developers. We don't force you to learn
complex frameworks or introduce unnecessary abstraction or unintuitive concepts. Only familiar default
Java classes like <code class="highlighter-rouge">CompletableFuture</code>s or <code class="highlighter-rouge">Optional</code>s
are used.
</div>
</div>
<hr>
<div class="row">
<div class="col-lg-2 col-md-3 col-sm-4">
<h1 class="text-center no-anchor"><i class="fa fa-book" aria-hidden="true"></i></h1>
<h3 class="text-center no-anchor">Rich Documentation</h3>
</div>
<div class="col-lg-10 col-md-9 col-sm-8">
The best library is worth nothing, if you don't know how to use it. To help you getting started, there are plenty of
tutorials in our <a href="/wiki">wiki</a>.
</div>
</div>
<hr>
<div class="row">
<div class="col-lg-2 col-md-3 col-sm-4">
<h1 class="text-center no-anchor"><i class="fa fa-comments" aria-hidden="true"></i></h1>
<h3 class="text-center no-anchor">Awesome community</h3>
</div>
<div class="col-lg-10 col-md-9 col-sm-8">
There's a large community of other bot developers in our <a href="https://discordapp.com/invite/0qJ2jjyneLEgG7y3" target="_blank">Discord Server</a>.
You can ask questions there, chat with other developers and keep track about Javacord's development.
</div>
</div>
<hr>
</div>
</section>
</div>
<div class="font-page-code-examples">
<br>
<div class="container">
<section>
<h1 class="no-anchor">Here are some examples!</h1>
<h3 class="no-anchor">Logging in</h3>
<p>This an easy starter template. It logs the bot in and adds a listener, that answers <code class="highlighter-rouge">!ping</code>
commands with <code class="highlighter-rouge">Pong!</code>. It also prints the invite url for the bot.</p>
{% highlight java %}
public class MyFirstBot {
public static void main(String[] args) {
// Read the token from the first program parameter when invoking the bot
String token = args[0];
DiscordApi api = new DiscordApiBuilder().setToken(token).login().join();
// Add a listener which answers with "Pong!" if someone writes "!ping"
api.addMessageCreateListener(event -> {
if (event.getMessageContent().equalsIgnoreCase("!ping")) {
event.getChannel().sendMessage("Pong!");
}
});
// Print the invite url of your bot
System.out.println("You can invite the bot by using the following url: " + api.createBotInvite());
}
}
{% endhighlight %}
<h3 class="no-anchor">Creating a text channel</h3>
<p>The following example creates a new text channel in a server with some pre-set permissions for
the <code class="highlighter-rouge">@everyone</code> role.</p>
{% highlight java %}
Server server = ...;
new ServerTextChannelBuilder(server)
.setName("my-new-channel")
.setTopic("This channel was created by a bot!")
.addPermissionOverwrite(server.getEveryoneRole(), new PermissionsBuilder()
.setAllowed(PermissionType.READ_MESSAGES, PermissionType.SEND_MESSAGES, PermissionType.ADD_REACTIONS)
.setDenied(PermissionType.ATTACH_FILE, PermissionType.READ_MESSAGE_HISTORY)
.build())
.create();
{% endhighlight %}
<h3 class="no-anchor">Deleting the last 100 messages in a channel</h3>
<p>This code first fetches the last 100 messages in a given channel and then deletes them.</p>
{% highlight java %}
channel.getMessages(100).thenAcceptAsync(MessageSet::deleteAll);
{% endhighlight %}
</section>
</div>
</div>
<br>