style: auto-format

This commit is contained in:
Jean-Philippe Sirois
2021-02-25 04:24:10 -05:00
parent f782589856
commit 46e8651b31
@@ -84,22 +84,22 @@ read property" error might arise.
```html ```html
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<body> <body>
<p id=paragraph-1>Welcome to <i>The programmer's hangout</i>.</p> <p id="paragraph-1">Welcome to <i>The programmer's hangout</i>.</p>
<p id=paragraph-2> <p id="paragraph-2">
This is the place for programmers of any skill level to, well, hangout This is the place for programmers of any skill level to, well, hangout
with other fellow programmers. Whether you have just written 5 lines of with other fellow programmers. Whether you have just written 5 lines of
code or been a code nerd for 15 years, you are always welcome! code or been a code nerd for 15 years, you are always welcome!
</p> </p>
<script> <script>
let element = document.getElementById("paragraph-3"); let element = document.getElementById("paragraph-3");
// The one writing this might think this will add another paragraph to // The one writing this might think this will add another paragraph to
// the page, which is not how it works. // the page, which is not how it works.
// The browser, failing to find any element with ID "paragraph-3" from // The browser, failing to find any element with ID "paragraph-3" from
// the page, returns null. // the page, returns null.
element.innerText = "When joining, make sure you read the rules."; element.innerText = "When joining, make sure you read the rules.";
</script> </script>
</body> </body>
</html> </html>
``` ```
@@ -184,11 +184,11 @@ sure that situation is handled properly.
```js ```js
async function getUserID(username) { async function getUserID(username) {
// Assuming "username" is guaranteed to be a string. // Assuming "username" is guaranteed to be a string.
let user = await botClient.fetchUser(username); let user = await botClient.fetchUser(username);
if (user == null) throw "There is no user with that name."; if (user == null) throw "There is no user with that name.";
// It is guaranteed now that "user" isn't null. // It is guaranteed now that "user" isn't null.
return user.id; return user.id;
} }
``` ```
@@ -200,10 +200,8 @@ ultimately receive a value, the error won't be able to occur.
```js ```js
let payload; let payload;
let rolledValue = Math.random(); let rolledValue = Math.random();
if (rolledValue > 0.5) if (rolledValue > 0.5) payload = { id: 169323, message: "Welcome to TPH." };
payload = { id: 169323, message: "Welcome to TPH." }; else payload = { id: 173205, message: "TPH has been waiting for you." };
else
payload = { id: 173205, message: "TPH has been waiting for you." };
// In either case, "payload" is guaranteed to be assigned an actual value. // In either case, "payload" is guaranteed to be assigned an actual value.
botClient.sendMessage(serverJoiner, payload.message); botClient.sendMessage(serverJoiner, payload.message);
``` ```
@@ -215,17 +213,17 @@ provide default values for function arguments, if applicable.
```js ```js
function sendEmbed(content, options = { color: "#888", dismissable: false }) { function sendEmbed(content, options = { color: "#888", dismissable: false }) {
let embed = botClient.createEmbed(); let embed = botClient.createEmbed();
embed.setContent(content); embed.setContent(content);
embed.setColor(options.color); embed.setColor(options.color);
embed.setDismissable(options.dismissable); embed.setDismissable(options.dismissable);
botClient.sendEmbed(embed); botClient.sendEmbed(embed);
} }
sendEmbed( sendEmbed("The programmer's hangout: https://theprogrammershangout.com", {
"The programmer's hangout: https://theprogrammershangout.com", color: "#763989",
{ color: "#763989", dismissable: true } dismissable: true,
); });
sendEmbed("Example site: https://example.com"); sendEmbed("Example site: https://example.com");
// No value is passed to "options" by the caller, // No value is passed to "options" by the caller,