mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Add disableEveryone option (#400)
* Added support for new game objects bot.setStreaming(name, url, type, callback); added logic for Internal setStatus updated to check if string or object * Add disableEveryone option * forgot to compile oh well, it can be squash merged
This commit is contained in:
@@ -49,6 +49,11 @@ rateLimitAsError
|
||||
|
||||
Have the lib throw a rejection Promise/callback when being ratelimited, instead of auto-retrying.
|
||||
|
||||
disableEveryone
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Have the lib insert a zero width space between here and everyone mentions disabling them.
|
||||
|
||||
shardCount
|
||||
~~~~~~~~~~
|
||||
|
||||
@@ -195,6 +200,7 @@ Sends a message to the specified channel.
|
||||
- **file** - (Optional) `object`, containing:
|
||||
- **file** - a `File Resolvable`_
|
||||
- **name** - (Optional) `String`, filename to upload file as
|
||||
- **disableEveryone** - (Optional) `Boolean`, disable `here` and `everyone` mentions
|
||||
- **callback** - `function` that takes the following parameters:
|
||||
- **error** - error object if any occurred
|
||||
- **message** - the sent Message_
|
||||
|
||||
@@ -79,6 +79,7 @@ var Client = (function (_EventEmitter) {
|
||||
this.options.guildCreateTimeout = options.guildCreateTimeout || 1000;
|
||||
this.options.shardId = options.shardId || 0;
|
||||
this.options.shardCount = options.shardCount || 0;
|
||||
this.options.disableEveryone = options.disableEveryone || false;
|
||||
|
||||
if (typeof options.shardCount === "number" && typeof options.shardId === "number" && options.shardCount > 0) {
|
||||
this.options.shard = [options.shardId, options.shardCount];
|
||||
|
||||
@@ -727,6 +727,10 @@ var InternalClient = (function () {
|
||||
return this.resolver.resolveChannel(where).then(function (destination) {
|
||||
var content = _this15.resolver.resolveString(_content);
|
||||
|
||||
if (_this15.client.options.disableEveryone || options.disableEveryone) {
|
||||
content = content.replace(/(@)(everyone|here)/g, "$1$2");
|
||||
}
|
||||
|
||||
if (options.file) {
|
||||
return _this15.resolver.resolveFile(options.file.file).then(function (file) {
|
||||
return _this15.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(destination.id), true, {
|
||||
@@ -770,6 +774,9 @@ var InternalClient = (function () {
|
||||
content = {
|
||||
content: this.resolver.resolveString(content)
|
||||
};
|
||||
if (this.client.options.disableEveryone) {
|
||||
content.content = content.content.replace(/(@)(everyone|here)/g, "$1$2");
|
||||
}
|
||||
}
|
||||
|
||||
return this.resolver.resolveChannel(where).then(function (channel) {
|
||||
|
||||
@@ -53,6 +53,7 @@ export default class Client extends EventEmitter {
|
||||
this.options.guildCreateTimeout = options.guildCreateTimeout || 1000;
|
||||
this.options.shardId = options.shardId || 0;
|
||||
this.options.shardCount = options.shardCount || 0;
|
||||
this.options.disableEveryone = options.disableEveryone || false;
|
||||
|
||||
if (typeof options.shardCount === "number" && typeof options.shardId === "number" && options.shardCount > 0) {
|
||||
this.options.shard = [options.shardId, options.shardCount];
|
||||
|
||||
@@ -616,6 +616,10 @@ export default class InternalClient {
|
||||
.then(destination => {
|
||||
var content = this.resolver.resolveString(_content);
|
||||
|
||||
if (this.client.options.disableEveryone || options.disableEveryone) {
|
||||
content = content.replace(/(@)(everyone|here)/g, '$1\u200b$2');
|
||||
}
|
||||
|
||||
if (options.file) {
|
||||
return this.resolver.resolveFile(options.file.file)
|
||||
.then(file =>
|
||||
@@ -655,6 +659,9 @@ export default class InternalClient {
|
||||
content = {
|
||||
content: this.resolver.resolveString(content)
|
||||
};
|
||||
if (this.client.options.disableEveryone) {
|
||||
content.content = content.content.replace(/(@)(everyone|here)/g, '$1\u200b$2');
|
||||
}
|
||||
}
|
||||
|
||||
return this.resolver.resolveChannel(where)
|
||||
|
||||
Reference in New Issue
Block a user