Skip to content

Commit a38ddcd

Browse files
author
Ron B
committed
Merge example with main repo
1 parent b2d2e19 commit a38ddcd

File tree

7 files changed

+136
-57
lines changed

7 files changed

+136
-57
lines changed

example/.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TOKEN=YOUR_DISCORD_BOT_TOKEN

example/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Cookiecord Example Bot
2+
An example of a bot that uses Cookiecord, this example should show off all major features.

example/example.ts

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import {
2+
command,
3+
Module,
4+
listener,
5+
default as CookiecordClient,
6+
getUserPermission,
7+
getMemberPermission
8+
} from "../src";
9+
import { Message, GuildMember, User } from "discord.js";
10+
import { Permission } from "../src";
11+
12+
export default class ExampleModule extends Module {
13+
constructor(client: CookiecordClient) {
14+
super(client);
15+
}
16+
17+
@command({ description: "asd" })
18+
test(msg: Message, a: string, b: number, u: User, m: GuildMember) {
19+
msg.reply(a + b + u.tag + m.nickname);
20+
}
21+
22+
@command({ description: "abc", aliases: ["gc"] })
23+
guildcount(msg: Message, offset: number) {
24+
msg.reply(this.client.guilds.size + offset);
25+
}
26+
27+
@listener({ event: "message" })
28+
onTest(msg: Message) {
29+
console.log("onTest", msg.content);
30+
}
31+
32+
@command({ description: "pong" })
33+
ping(msg: Message) {
34+
msg.reply("Pong. :ping_pong:");
35+
}
36+
@command({
37+
permission: Permission.GUILD_MOD,
38+
description: "Checking if user is mod or higher"
39+
})
40+
modcheck(msg: Message) {
41+
if (!msg.member) return;
42+
msg.reply(
43+
`permission = ${getMemberPermission(this.client, msg.member)}`
44+
);
45+
}
46+
@command({
47+
description: "one big string for all of the args",
48+
single: true
49+
})
50+
single(msg: Message, str: string) {
51+
msg.reply("You said " + str);
52+
}
53+
}

example/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import CookiecordClient from "../src";
2+
import de from "dotenv";
3+
import ExampleModule from "./example";
4+
de.config();
5+
6+
const client = new CookiecordClient({}, {});
7+
new ExampleModule(client);
8+
client.login(process.env.TOKEN);

package.json

+11-8
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
"author": "RONTheCookie <[email protected]>",
88
"license": "GPL-3.0",
99
"dependencies": {
10-
"@hapi/joi": "^16.1.7",
11-
"@types/node": "^12.7.2",
12-
"@types/ws": "^6.0.3",
13-
"discord.js": "discordjs/discord.js",
14-
"reflect-metadata": "^0.1.13",
15-
"typescript": "^3.6.3"
10+
"discord.js": "discordjs/discord.js"
1611
},
1712
"scripts": {
18-
"install": "tsc"
13+
"prepublish": "tsc",
14+
"example": "ts-node example"
1915
},
2016
"devDependencies": {
21-
"ts-node": "^8.4.1"
17+
"@hapi/joi": "^16.1.7",
18+
"@types/dotenv": "^8.2.0",
19+
"@types/node": "^13.5.0",
20+
"@types/ws": "^6.0.3",
21+
"dotenv": "^8.2.0",
22+
"reflect-metadata": "^0.1.13",
23+
"ts-node": "^8.4.1",
24+
"typescript": "^3.6.3"
2225
}
2326
}

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// "sourceMap": true, /* Generates corresponding '.map' file. */
1818
// "outFile": "./", /* Concatenate and emit output to single file. */
1919
"outDir": "./dist", /* Redirect output structure to the directory. */
20-
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
20+
"rootDirs": ["./src","./example"], /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
2121
// "composite": true, /* Enable project compilation */
2222
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
2323
// "removeComments": true, /* Do not emit comments to output. */

yarn.lock

+60-48
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88
integrity sha512-4ek19SmNcPI92942RkuBrZrBK8hg7nG+ae/skkNNDeOaUG+XvxTPkv/jPZVgXwVPDkU5EFsewsI+0n4dTwFvgA==
99

1010
"@hapi/address@^2.1.2":
11-
version "2.1.2"
12-
resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.2.tgz#1c794cd6dbf2354d1eb1ef10e0303f573e1c7222"
13-
integrity sha512-O4QDrx+JoGKZc6aN64L04vqa7e41tIiLU+OvKdcYaEMP97UttL0f9GIi9/0A4WAMx0uBd6SidDIhktZhgOcN8Q==
11+
version "2.1.4"
12+
resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5"
13+
integrity sha512-QD1PhQk+s31P1ixsX0H0Suoupp3VMXzIVMSwobR3F3MSUO2YCV0B7xqLcUw/Bh8yuvd3LhpyqLQWTNcRmp6IdQ==
1414

1515
"@hapi/formula@^1.2.0":
1616
version "1.2.0"
1717
resolved "https://registry.yarnpkg.com/@hapi/formula/-/formula-1.2.0.tgz#994649c7fea1a90b91a0a1e6d983523f680e10cd"
1818
integrity sha512-UFbtbGPjstz0eWHb+ga/GM3Z9EzqKXFWIbSOFURU0A/Gku0Bky4bCk9/h//K2Xr3IrCfjFNhMm4jyZ5dbCewGA==
1919

2020
"@hapi/hoek@^8.2.4", "@hapi/hoek@^8.3.0":
21-
version "8.3.2"
22-
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-8.3.2.tgz#91e7188edebc5d876f0b91a860f555ff06f0782b"
23-
integrity sha512-NP5SG4bzix+EtSMtcudp8TvI0lB46mXNo8uFpTDw6tqxGx4z5yx+giIunEFA0Z7oUO4DuWrOJV9xqR2tJVEdyA==
21+
version "8.5.0"
22+
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-8.5.0.tgz#2f9ce301c8898e1c3248b0a8564696b24d1a9a5a"
23+
integrity sha512-7XYT10CZfPsH7j9F1Jmg1+d0ezOux2oM2GfArAzLwWe4mE2Dr3hVjsAL6+TFY49RRJlCdJDMw3nJsLFroTc8Kw==
2424

2525
"@hapi/joi@^16.1.7":
26-
version "16.1.7"
27-
resolved "https://registry.yarnpkg.com/@hapi/joi/-/joi-16.1.7.tgz#360857223a87bb1f5f67691537964c1b4908ed93"
28-
integrity sha512-anaIgnZhNooG3LJLrTFzgGALTiO97zRA1UkvQHm9KxxoSiIzCozB3RCNCpDnfhTJD72QlrHA8nwGmNgpFFCIeg==
26+
version "16.1.8"
27+
resolved "https://registry.yarnpkg.com/@hapi/joi/-/joi-16.1.8.tgz#84c1f126269489871ad4e2decc786e0adef06839"
28+
integrity sha512-wAsVvTPe+FwSrsAurNt5vkg3zo+TblvC5Bb1zMVK6SJzZqw9UrJnexxR+76cpePmtUZKHAPxcQ2Bf7oVHyahhg==
2929
dependencies:
3030
"@hapi/address" "^2.1.2"
3131
"@hapi/formula" "^1.2.0"
@@ -45,15 +45,22 @@
4545
dependencies:
4646
"@hapi/hoek" "^8.3.0"
4747

48-
"@types/node@*", "@types/node@^12.7.2":
49-
version "12.11.7"
50-
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.11.7.tgz#57682a9771a3f7b09c2497f28129a0462966524a"
51-
integrity sha512-JNbGaHFCLwgHn/iCckiGSOZ1XYHsKFwREtzPwSGCVld1SGhOlmZw2D4ZI94HQCrBHbADzW9m4LER/8olJTRGHA==
48+
"@types/dotenv@^8.2.0":
49+
version "8.2.0"
50+
resolved "https://registry.yarnpkg.com/@types/dotenv/-/dotenv-8.2.0.tgz#5cd64710c3c98e82d9d15844375a33bf1b45d053"
51+
integrity sha512-ylSC9GhfRH7m1EUXBXofhgx4lUWmFeQDINW5oLuS+gxWdfUeW4zJdeVTYVkexEW+e2VUvlZR2kGnGGipAWR7kw==
52+
dependencies:
53+
dotenv "*"
54+
55+
"@types/node@*", "@types/node@^13.5.0":
56+
version "13.5.0"
57+
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.5.0.tgz#4e498dbf355795a611a87ae5ef811a8660d42662"
58+
integrity sha512-Onhn+z72D2O2Pb2ql2xukJ55rglumsVo1H6Fmyi8mlU9SvKdBk/pUSUAiBY/d9bAOF7VVWajX3sths/+g6ZiAQ==
5259

5360
"@types/ws@^6.0.3":
54-
version "6.0.3"
55-
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-6.0.3.tgz#b772375ba59d79066561c8d87500144d674ba6b3"
56-
integrity sha512-yBTM0P05Tx9iXGq00BbJPo37ox68R5vaGTXivs6RGh/BQ6QP5zqZDGWdAO6JbRE/iR1l80xeGAwCQS2nMV9S/w==
61+
version "6.0.4"
62+
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-6.0.4.tgz#7797707c8acce8f76d8c34b370d4645b70421ff1"
63+
integrity sha512-PpPrX7SZW9re6+Ha8ojZG4Se8AZXgf0GK6zmfqEuCsY49LFDNXO3SByp44X3dFEqtB73lkCDAdUazhAjVPiNwg==
5764
dependencies:
5865
"@types/node" "*"
5966

@@ -65,9 +72,9 @@ abort-controller@^3.0.0:
6572
event-target-shim "^5.0.0"
6673

6774
arg@^4.1.0:
68-
version "4.1.1"
69-
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.1.tgz#485f8e7c390ce4c5f78257dbea80d4be11feda4c"
70-
integrity sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==
75+
version "4.1.2"
76+
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.2.tgz#e70c90579e02c63d80e3ad4e31d8bfdb8bd50064"
77+
integrity sha512-+ytCkGcBtHZ3V2r2Z06AncYO8jz46UEamcspGoU8lHcEbpn6J77QK0vdWvChsclg/tM5XIJC5tnjmPp7Eq6Obg==
7178

7279
async-limiter@~1.0.0:
7380
version "1.0.1"
@@ -97,13 +104,13 @@ delayed-stream@~1.0.0:
97104
integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk=
98105

99106
diff@^4.0.1:
100-
version "4.0.1"
101-
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.1.tgz#0c667cb467ebbb5cea7f14f135cc2dba7780a8ff"
102-
integrity sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==
107+
version "4.0.2"
108+
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
109+
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==
103110

104111
discord.js@discordjs/discord.js:
105112
version "12.0.0-dev"
106-
resolved "https://codeload.github.com/discordjs/discord.js/tar.gz/9bcb6a04ba43f7d6eebd48c81b84c227cd94a094"
113+
resolved "https://codeload.github.com/discordjs/discord.js/tar.gz/030d263a9e018a766c5f399624fe4f8ec2b7349c"
107114
dependencies:
108115
"@discordjs/collection" "^0.1.1"
109116
abort-controller "^3.0.0"
@@ -115,6 +122,11 @@ discord.js@discordjs/discord.js:
115122
tweetnacl "^1.0.1"
116123
ws "^6.1.3"
117124

125+
dotenv@*, dotenv@^8.2.0:
126+
version "8.2.0"
127+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
128+
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==
129+
118130
event-target-shim@^5.0.0:
119131
version "5.0.1"
120132
resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789"
@@ -134,17 +146,17 @@ make-error@^1.1.1:
134146
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8"
135147
integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==
136148

137-
mime-db@1.40.0:
138-
version "1.40.0"
139-
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.40.0.tgz#a65057e998db090f732a68f6c276d387d4126c32"
140-
integrity sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==
149+
mime-db@1.43.0:
150+
version "1.43.0"
151+
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.43.0.tgz#0a12e0502650e473d735535050e7c8f4eb4fae58"
152+
integrity sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==
141153

142154
mime-types@^2.1.12:
143-
version "2.1.24"
144-
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.24.tgz#b6f8d0b3e951efb77dedeca194cff6d16f676f81"
145-
integrity sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==
155+
version "2.1.26"
156+
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.26.tgz#9c921fc09b7e149a65dfdc0da4d20997200b0a06"
157+
integrity sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==
146158
dependencies:
147-
mime-db "1.40.0"
159+
mime-db "1.43.0"
148160

149161
node-fetch@^2.3.0:
150162
version "2.6.0"
@@ -157,9 +169,9 @@ pako@^1.0.8:
157169
integrity sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==
158170

159171
prism-media@^1.0.0:
160-
version "1.1.0"
161-
resolved "https://registry.yarnpkg.com/prism-media/-/prism-media-1.1.0.tgz#64fd9abf64719d627b99360bfbe1a81d3ac0c593"
162-
integrity sha512-W+oxjRyjtd7hw3pefNZuc7YEZ6VICORJvVNfCPs0+7CsJ43CqMjGAYGjPL3hQ82vw03EVra+CiX4zisqOBUUGw==
172+
version "1.2.0"
173+
resolved "https://registry.yarnpkg.com/prism-media/-/prism-media-1.2.0.tgz#8528aa71dc906bfc1566e9bb59d57986a7fd0e20"
174+
integrity sha512-zjcO/BLVlfxWqFpEUlDyL1R9XXMquasNP4xpeYDPPZi/Zcz0i6OXoqcvxOLgbRVPsJXVd29vlYmRx2bts+hzEw==
163175

164176
reflect-metadata@^0.1.13:
165177
version "0.1.13"
@@ -172,9 +184,9 @@ setimmediate@^1.0.5:
172184
integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=
173185

174186
source-map-support@^0.5.6:
175-
version "0.5.15"
176-
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.15.tgz#20fe16f16e74644e21a396c78c841fa66e35df6c"
177-
integrity sha512-wYF5aX1J0+V51BDT3Om7uXNn0ct2FWiV4bvwiGVefxkm+1S1o5jsecE5lb2U28DDblzxzxeIDbTVpXHI9D/9hA==
187+
version "0.5.16"
188+
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.16.tgz#0ae069e7fe3ba7538c64c98515e35339eac5a042"
189+
integrity sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==
178190
dependencies:
179191
buffer-from "^1.0.0"
180192
source-map "^0.6.0"
@@ -185,25 +197,25 @@ source-map@^0.6.0:
185197
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
186198

187199
ts-node@^8.4.1:
188-
version "8.4.1"
189-
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.4.1.tgz#270b0dba16e8723c9fa4f9b4775d3810fd994b4f"
190-
integrity sha512-5LpRN+mTiCs7lI5EtbXmF/HfMeCjzt7DH9CZwtkr6SywStrNQC723wG+aOWFiLNn7zT3kD/RnFqi3ZUfr4l5Qw==
200+
version "8.6.2"
201+
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.6.2.tgz#7419a01391a818fbafa6f826a33c1a13e9464e35"
202+
integrity sha512-4mZEbofxGqLL2RImpe3zMJukvEvcO1XP8bj8ozBPySdCUXEcU5cIRwR0aM3R+VoZq7iXc8N86NC0FspGRqP4gg==
191203
dependencies:
192204
arg "^4.1.0"
193205
diff "^4.0.1"
194206
make-error "^1.1.1"
195207
source-map-support "^0.5.6"
196-
yn "^3.0.0"
208+
yn "3.1.1"
197209

198210
tweetnacl@^1.0.1:
199-
version "1.0.1"
200-
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.1.tgz#2594d42da73cd036bd0d2a54683dd35a6b55ca17"
201-
integrity sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A==
211+
version "1.0.2"
212+
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.2.tgz#39fba8d1f7a34706a3fc1fd8c04afcad7bb9e689"
213+
integrity sha512-+8aPRjmXgf1VqvyxSlBUzKzeYqVS9Ai8vZ28g+mL7dNQl1jlUTCMDZnvNQdAS1xTywMkIXwJsfipsR/6s2+syw==
202214

203215
typescript@^3.6.3:
204-
version "3.6.4"
205-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.4.tgz#b18752bb3792bc1a0281335f7f6ebf1bbfc5b91d"
206-
integrity sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==
216+
version "3.7.5"
217+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae"
218+
integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==
207219

208220
ws@^6.1.3:
209221
version "6.2.1"
@@ -212,7 +224,7 @@ ws@^6.1.3:
212224
dependencies:
213225
async-limiter "~1.0.0"
214226

215-
yn@^3.0.0:
227+
yn@3.1.1:
216228
version "3.1.1"
217229
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
218230
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==

0 commit comments

Comments
 (0)