-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickstart.html
193 lines (178 loc) · 12.5 KB
/
quickstart.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>빠른 시작</title>
<!-- end extra head -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="_static/style.css" type="text/css" />
<link rel="stylesheet" href="_static/codeblocks.css" type="text/css" />
<link rel="stylesheet" href="_static/icons.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<script src="_static/custom.js"></script>
<script src="_static/settings.js"></script>
<script src="_static/copy.js"></script>
<script src="_static/sidebar.js"></script>
<script src="_static/translations.js"></script>
<link rel="shortcut icon" href="_static/discord_py_logo.ico"/>
<link rel="index" title="색인" href="genindex.html" />
<link rel="search" title="검색" href="search.html" />
</head>
<body>
<div class="main-grid">
<header class="grid-item">
<nav>
<a href="index.html" class="main-heading">discord.py</a>
<a href="https://github.com/Rapptz/discord.py" title="GitHub"><span class="material-icons custom-icons">github</span></a>
<a href="https://discord.gg/YbfbxpX" title="Discord"><span class="material-icons custom-icons">discord</span></a>
<a href="faq.html" title="FAQ"><span class="material-icons">help_center</span></a>
<a onclick="mobileSearch.open();" title="검색" id="open-search" class="mobile-only"><span class="material-icons">search</span></a>
<a onclick="mobileSearch.close();" title="Close" id="close-search" class="mobile-only" hidden><span class="material-icons">close</span></a>
</nav>
<nav class="mobile-only">
<form role="search" class="search" action="search.html" method="get">
<div class="search-wrapper">
<input type="search" name="q" placeholder="Search documentation" />
<button type="submit">
<span class="material-icons">search</span>
</button>
</div>
</form>
</nav>
</header>
<div class="sub-header grid-item">
<label for="documentation_select">View Documentation For</label>
<select id="documentation_select" onchange="window.location = this.value;">
<option value="#" selected>discord</option>
<option value="ext/commands/index.html" >discord.ext.commands</option>
<option value="ext/tasks/index.html" >discord.ext.tasks</option>
</select>
<form role="search" class="search" action="search.html" method="get">
<div class="search-wrapper">
<input type="search" name="q" placeholder="Search documentation" />
<button type="submit">
<span class="material-icons">search</span>
</button>
</div>
</form>
<a accesskey="S" class="settings" onclick="settingsModal.open();"><span class="material-icons">settings</span></a>
</div>
<aside class="grid-item">
<span id="hamburger-toggle">
<span class="material-icons">menu</span>
</span>
<span id="settings-toggle" class="settings" onclick="settingsModal.open();">
<span class="material-icons">settings</span>
</span>
<div id="sidebar">
<h3><a href="index.html">목차</a></h3>
<ul>
<li><a class="reference internal" href="#">빠른 시작</a><ul>
<li><a class="reference internal" href="#a-minimal-bot">최소한의 봇</a></li>
</ul>
</li>
</ul>
</div>
</aside>
<main class="grid-item" role="main">
<section id="quickstart">
<span id="id1"></span><h1>빠른 시작<a class="headerlink" href="#quickstart" title="제목 주소">¶</a></h1>
<p>이 페이지는 라이브러리에 대한 간단한 소개를 합니다. 라이브러리가 설치되있다고 가정하므로, 만약에 그렇지 않다면 <a class="reference internal" href="intro.html#installing"><span class="std std-ref">설치</span></a> 항목을 확인해주세요.</p>
<section id="a-minimal-bot">
<h2>최소한의 봇<a class="headerlink" href="#a-minimal-bot" title="제목 주소">¶</a></h2>
<p>Let’s make a bot that responds to a specific message and walk you through it.</p>
<p>대충 이렇게 생겼습니다:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">discord</span>
<span class="n">client</span> <span class="o">=</span> <span class="n">discord</span><span class="o">.</span><span class="n">Client</span><span class="p">()</span>
<span class="nd">@client</span><span class="o">.</span><span class="n">event</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">on_ready</span><span class="p">():</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">'We have logged in as </span><span class="si">{0.user}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">client</span><span class="p">))</span>
<span class="nd">@client</span><span class="o">.</span><span class="n">event</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">on_message</span><span class="p">(</span><span class="n">message</span><span class="p">):</span>
<span class="k">if</span> <span class="n">message</span><span class="o">.</span><span class="n">author</span> <span class="o">==</span> <span class="n">client</span><span class="o">.</span><span class="n">user</span><span class="p">:</span>
<span class="k">return</span>
<span class="k">if</span> <span class="n">message</span><span class="o">.</span><span class="n">content</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">'$hello'</span><span class="p">):</span>
<span class="k">await</span> <span class="n">message</span><span class="o">.</span><span class="n">channel</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s1">'Hello!'</span><span class="p">)</span>
<span class="n">client</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="s1">'your token here'</span><span class="p">)</span>
</pre></div>
</div>
<p>이제 이 파일의 이름을 <code class="docutils literal notranslate"><span class="pre">example_bot.py</span></code>로 합시다. 이름을 <code class="docutils literal notranslate"><span class="pre">discord.py</span></code>로 하면 라이브러리와 충돌하므로 주의하세요.</p>
<p>많은 것들이 진행되므로, 차근차근 진행해봅시다.</p>
<ol class="arabic">
<li><p>첫번째 줄은 단순히 라이브러리를 불러오는데, 만약에 <cite>ModuleNotFoundError</cite>나 <cite>ImportError</cite>를 일으킨다면 <a class="reference internal" href="intro.html#installing"><span class="std std-ref">설치</span></a> 항목으로 가서 제대로 설치하세요.</p></li>
<li><p>다음으로, <a class="reference internal" href="api.html#discord.Client" title="discord.Client"><code class="xref py py-class docutils literal notranslate"><span class="pre">Client</span></code></a>의 인스턴스를 만듭니다. 이 클라이언트는 디스코드로의 연결입니다.</p></li>
<li><p>그러고 <a class="reference internal" href="api.html#discord.Client.event" title="discord.Client.event"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.event()</span></code></a> 데코레이터를 사용해서 이벤트를 등록합니다. 이 라이브러리에는 많은 이벤트들이 있습니다. 이 라이브러리는 비동기이기 때문에, 우리는 《callback》 스타일로 합니다.</p>
<p>콜백은 기본적으로는 무엇인가 일어났을때 호출되는 기능입니다. 현재 상황에서는, <a class="reference internal" href="api.html#discord.on_ready" title="discord.on_ready"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_ready()</span></code></a> 이벤트가 봇이 로깅을 끝내고 여러가지를 준비한 뒤 호출되고 <a class="reference internal" href="api.html#discord.on_message" title="discord.on_message"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_message()</span></code></a>는 봇이 메시지를 받았을 때 호출됩니다.</p>
</li>
<li><p><a class="reference internal" href="api.html#discord.on_message" title="discord.on_message"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_message()</span></code></a> 이벤트는 말 그대로 <em>모든</em> 메시지를 받았을 때 실행되므로, 봇이 보낸 메시지는 무시하도록 해야합니다. <a class="reference internal" href="api.html#discord.Message.author" title="discord.Message.author"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Message.author</span></code></a>가 <a class="reference internal" href="api.html#discord.Client.user" title="discord.Client.user"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Client.user</span></code></a>인지 확인하면 됩니다.</p></li>
<li><p>Afterwards, we check if the <a class="reference internal" href="api.html#discord.Message.content" title="discord.Message.content"><code class="xref py py-class docutils literal notranslate"><span class="pre">Message.content</span></code></a> starts with <code class="docutils literal notranslate"><span class="pre">'$hello'</span></code>. If it is,
then we send a message in the channel it was used in with <code class="docutils literal notranslate"><span class="pre">'Hello!'</span></code>.</p></li>
<li><p>마지막으로, 봇을 로그인 토큰으로 돌립니다. 만약 토큰을 얻거나 봇을 생성하는 것에 도움이 필요하다면, <a class="reference internal" href="discord.html#discord-intro"><span class="std std-ref">봇 계정 생성</span></a> 항목을 보세요.</p></li>
</ol>
<p>이제 우리가 봇을 만들었으므로, 우리는 봇을 <em>실행</em>해야합니다. 다행히, 이건 그저 파이썬 스크립트이기 때문에 바로 실행하면 되므로 간단합니다.</p>
<p>윈도우에서:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>$ py -3 example_bot.py
</pre></div>
</div>
<p>다른 시스템에서:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>$ python3 example_bot.py
</pre></div>
</div>
<p>이제 당신의 기본적인 봇으로 놀면 됩니다.</p>
</section>
</section>
</main>
<footer class="grid-item">
© Copyright 2015-2020, Rapptz.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</footer>
</div>
<div id="settings" class="modal" onclick="if (event.target == this){ settingsModal.close(); }" hidden>
<div class="modal-content">
<span class="close" onclick="settingsModal.close();" title="Close">
<span class="material-icons">close</span>
</span>
<h1>Settings</h1>
<h2>Font</h2>
<div class="setting">
<h3>Use a serif font:
<label class="toggle"
title="Use a serif font? Your system font will be used, falling back to serif.">
<input type="checkbox" name="useSerifFont" onclick="updateSetting(this);">
<span class="toggle-slider"></span>
</label>
</h3>
</div>
<h2>Theme</h2>
<div class="setting">
<h3>
<label class="toggle" title="Set your theme based on your system preferences">
<input type="radio" name="setTheme" onclick="updateSetting(this);" value="automatic" checked>
</label>
Automatic
</h3>
<h3>
<label class="toggle" title="Set your theme to light theme">
<input type="radio" name="setTheme" onclick="updateSetting(this);" value="light">
</label>
Light
</h3>
<h3>
<label class="toggle" title="Set your theme to dark theme">
<input type="radio" name="setTheme" onclick="updateSetting(this);" value="dark">
</label>
Dark
</h3>
</div>
</div>
</div>
<div id="to-top" onclick="scrollToTop()" hidden>
<span><span class="material-icons">arrow_upward</span> to top</span>
</div>
</body>
</html>