mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Merge typings into master
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
|||||||
[submodule "typings"]
|
|
||||||
path = typings
|
|
||||||
url = https://github.com/discordjs/discord.js-typings
|
|
||||||
@@ -22,3 +22,5 @@ docs/
|
|||||||
webpack.config.js
|
webpack.config.js
|
||||||
.github/
|
.github/
|
||||||
test/
|
test/
|
||||||
|
tsconfig.json
|
||||||
|
tslint.json
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"docs:test": "docgen --source src --custom docs/index.yml",
|
"docs:test": "docgen --source src --custom docs/index.yml",
|
||||||
"lint": "eslint src *.js",
|
"lint": "eslint src *.js",
|
||||||
"lint:fix": "eslint --fix src",
|
"lint:fix": "eslint --fix src",
|
||||||
|
"lint:typings": "tslint index.d.ts discord.js-test.ts",
|
||||||
"build:browser": "webpack",
|
"build:browser": "webpack",
|
||||||
"prepublishOnly": "npm run test && NODE_ENV=production npm run build:browser"
|
"prepublishOnly": "npm run test && NODE_ENV=production npm run build:browser"
|
||||||
},
|
},
|
||||||
@@ -54,6 +55,9 @@
|
|||||||
"discord.js-docgen": "discordjs/docgen",
|
"discord.js-docgen": "discordjs/docgen",
|
||||||
"eslint": "^5.0.1",
|
"eslint": "^5.0.1",
|
||||||
"json-filter-loader": "^1.0.0",
|
"json-filter-loader": "^1.0.0",
|
||||||
|
"tslint": "^3.15.1",
|
||||||
|
"tslint-config-typings": "^0.2.4",
|
||||||
|
"typescript": "^3.0.1",
|
||||||
"uglifyjs-webpack-plugin": "^1.1.8",
|
"uglifyjs-webpack-plugin": "^1.1.8",
|
||||||
"webpack": "^4.5.0",
|
"webpack": "^4.5.0",
|
||||||
"webpack-cli": "^3.0.1"
|
"webpack-cli": "^3.0.1"
|
||||||
|
|||||||
13
tsconfig.json
Normal file
13
tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es6",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"forceConsistentCasingInFileNames": true
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"typings/index.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
62
tslint.json
Normal file
62
tslint.json
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"tslint-config-typings"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"class-name": true,
|
||||||
|
"comment-format": [
|
||||||
|
true,
|
||||||
|
"check-space"
|
||||||
|
],
|
||||||
|
"indent": [
|
||||||
|
true,
|
||||||
|
"tabs"
|
||||||
|
],
|
||||||
|
"no-duplicate-variable": true,
|
||||||
|
"no-unused-variable": [false],
|
||||||
|
"no-eval": true,
|
||||||
|
"no-internal-module": true,
|
||||||
|
"no-trailing-whitespace": true,
|
||||||
|
"no-unsafe-finally": true,
|
||||||
|
"no-var-keyword": true,
|
||||||
|
"one-line": [
|
||||||
|
true,
|
||||||
|
"check-open-brace",
|
||||||
|
"check-whitespace"
|
||||||
|
],
|
||||||
|
"quotemark": [
|
||||||
|
true,
|
||||||
|
"single"
|
||||||
|
],
|
||||||
|
"semicolon": [
|
||||||
|
true,
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"triple-equals": [
|
||||||
|
true,
|
||||||
|
"allow-null-check"
|
||||||
|
],
|
||||||
|
"typedef-whitespace": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"call-signature": "nospace",
|
||||||
|
"index-signature": "nospace",
|
||||||
|
"parameter": "nospace",
|
||||||
|
"property-declaration": "nospace",
|
||||||
|
"variable-declaration": "nospace"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"variable-name": [
|
||||||
|
true,
|
||||||
|
"ban-keywords"
|
||||||
|
],
|
||||||
|
"whitespace": [
|
||||||
|
true,
|
||||||
|
"check-branch",
|
||||||
|
"check-decl",
|
||||||
|
"check-operator",
|
||||||
|
"check-separator",
|
||||||
|
"check-type"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
1
typings
1
typings
Submodule typings deleted from db2a6e498b
69
typings/discord.js-test.ts
Normal file
69
typings/discord.js-test.ts
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/// <reference path='index.d.ts' />
|
||||||
|
|
||||||
|
import { Collector, Message, CollectorFilter, Client, CollectorHandler, MessageReaction, Collection, User, ReactionCollectorOptions, Snowflake } from 'discord.js';
|
||||||
|
|
||||||
|
const client = new Client({
|
||||||
|
disableEveryone: false,
|
||||||
|
disabledEvents: ['GUILD_MEMBER_ADD']
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('message', (message) => {
|
||||||
|
if (message.content === 'hello') {
|
||||||
|
message.channel.sendMessage('o/');
|
||||||
|
}
|
||||||
|
|
||||||
|
const collector: ReactionCollector = new ReactionCollector(message,
|
||||||
|
(reaction: MessageReaction) => reaction.emoji.toString() === '👌',
|
||||||
|
{ time: 30e3 });
|
||||||
|
collector.on('end', collected => console.log(collected));
|
||||||
|
});
|
||||||
|
|
||||||
|
client.login('dsfsd754.4fds4f68d4f6sd46f4s.7878easfdsgdfFDSIJIO');
|
||||||
|
|
||||||
|
export class TestCollector extends Collector<Snowflake, Message> {
|
||||||
|
public filter: CollectorFilter;
|
||||||
|
public constructor(client: Client, filter: CollectorFilter, ) {
|
||||||
|
super(client, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public handle(message: Message): CollectorHandler<Snowflake, Message> {
|
||||||
|
return { key: message.id, value: message };
|
||||||
|
}
|
||||||
|
|
||||||
|
public cleanup(): void {}
|
||||||
|
public postCheck(): null { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
class ReactionCollector extends Collector<Snowflake, MessageReaction> {
|
||||||
|
public message: Message;
|
||||||
|
public users: Collection<Snowflake, User>;
|
||||||
|
public total: number;
|
||||||
|
public options: ReactionCollectorOptions;
|
||||||
|
public constructor(message: Message, filter: CollectorFilter, options?: ReactionCollectorOptions) {
|
||||||
|
super(message.client, filter, options || {});
|
||||||
|
this.message = message;
|
||||||
|
this.users = new Collection<Snowflake, User>();
|
||||||
|
this.total = 0;
|
||||||
|
this.client.on('messageReactionAdd', this.listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public handle(reaction: MessageReaction): CollectorHandler<Snowflake, MessageReaction> {
|
||||||
|
if (reaction.message.id !== this.message.id) { return null; }
|
||||||
|
return {
|
||||||
|
key: reaction.emoji.id || reaction.emoji.name,
|
||||||
|
value: reaction
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public postCheck(reaction: MessageReaction, user: User): string {
|
||||||
|
this.users.set(user.id, user);
|
||||||
|
if (this.options.max && ++this.total >= this.options.max) { return 'limit'; }
|
||||||
|
if (this.options.maxEmojis && this.collected.size >= this.options.maxEmojis) { return 'emojiLimit'; }
|
||||||
|
if (this.options.maxUsers && this.users.size >= this.options.maxUsers) { return 'userLimit'; }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public cleanup(): void {
|
||||||
|
this.client.removeListener('messageReactionAdd', this.listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
2151
typings/index.d.ts
vendored
Normal file
2151
typings/index.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user