Commit Graph

3050 Commits

Author SHA1 Message Date
Alex Gravely
0484fe8e9d docs: Change token explanation (#1331)
man I wish people read more
2019-06-21 17:20:19 -04:00
Christopher Felegy
cd288923c3 [ifcbrk] feature: suppress messages
yeah man I support the first amendment
2019-06-21 17:18:29 -04:00
Passive
1e8aa080ab Fix #1327 Color.ToString returns wrong value (#1328)
* Match debugger display value

https://github.com/discord-net/Discord.Net/issues/1327

* Use string.format to convert raw value to hex

* Remove nested string.format
2019-06-21 16:28:44 +01:00
Chris Johnston
a797be9ca0 test: Split Unit and Integration tests into separate projects (#1290)
* Squashed commit of test rewrite changes

fix missing priority speaker flag

rewrite the TestChannelPermissionModify test

add test for GuildPermission modify

separate unit and integration tests, start writing channel and guild permission tests

copy over the color tests

copy over the emote tests

copy the token utils tests

make the mocked entities sealed classes

copy the TypeReaderTests class

properly dispose the CommandService in the TypeReaderTests

start writing tests for EmbedBuilder and related classes

test that properties throw ArgumentException when invalid

add tests for the embed length property

add withFooter tests

finish adding tests to EmbedBuilder

fix bug in value validation of EmbedFieldBuilder

hey, these tests actually found a bug!

add tests for the MentionUtils class

add tests for the Format util class

remove all of the old tests

add analyzer tests (copied from old tests)

add tests for the SnowflakeUtils class

add integration tests

these get around the issue of state persisting between tests by creating and deleting a guild for each set of tests. these shouldn't be run excessively because of the rate limits, but should be fine every now and then

remove unnecessary launchSettings.json

update outdated string

don't create a new guild each time, as that can result in errors

this can happen if a bot creates too many guilds without properly deleting them

add some tests that show that guild can be modified

await async assert

add more measures that created channels are deleted when done

remove "Test" prefix from test method names

I think that this prefix when already displayed under a class with a suffix of "Tests" is redundant

Remove mention of old test project

fix an issue from forgetting to await Assert.ThrowsAsync

explicitly disable parallelization on integration tests

add test for GuildPermission modify

separate unit and integration tests, start writing channel and guild permission tests

copy over the color tests

copy over the emote tests

make the mocked entities sealed classes

properly dispose the CommandService in the TypeReaderTests

fix bug in value validation of EmbedFieldBuilder

hey, these tests actually found a bug!

add tests for the MentionUtils class

add tests for the Format util class

remove all of the old tests

add analyzer tests (copied from old tests)

add tests for the SnowflakeUtils class

add integration tests

these get around the issue of state persisting between tests by creating and deleting a guild for each set of tests. these shouldn't be run excessively because of the rate limits, but should be fine every now and then

remove unnecessary launchSettings.json

update outdated string

don't create a new guild each time, as that can result in errors

this can happen if a bot creates too many guilds without properly deleting them

add more measures that created channels are deleted when done

remove "Test" prefix from test method names

I think that this prefix when already displayed under a class with a suffix of "Tests" is redundant

Remove mention of old test project

fix an issue from forgetting to await Assert.ThrowsAsync

explicitly disable parallelization on integration tests

update the azure CI build script

separate execution of test projects so that if one fails the other will not pass

one of the unit tests failed, but the analzyer tests passed

fix test that would break in different timezones

enable the integration tests (only on dev branch)

* Squashed commit of test rewrite changes

fix missing priority speaker flag

rewrite the TestChannelPermissionModify test

add test for GuildPermission modify

separate unit and integration tests, start writing channel and guild permission tests

copy over the color tests

copy over the emote tests

copy the token utils tests

make the mocked entities sealed classes

copy the TypeReaderTests class

properly dispose the CommandService in the TypeReaderTests

start writing tests for EmbedBuilder and related classes

test that properties throw ArgumentException when invalid

add tests for the embed length property

add withFooter tests

finish adding tests to EmbedBuilder

fix bug in value validation of EmbedFieldBuilder

hey, these tests actually found a bug!

add tests for the MentionUtils class

add tests for the Format util class

remove all of the old tests

add analyzer tests (copied from old tests)

add tests for the SnowflakeUtils class

add integration tests

these get around the issue of state persisting between tests by creating and deleting a guild for each set of tests. these shouldn't be run excessively because of the rate limits, but should be fine every now and then

remove unnecessary launchSettings.json

update outdated string

don't create a new guild each time, as that can result in errors

this can happen if a bot creates too many guilds without properly deleting them

add some tests that show that guild can be modified

await async assert

add more measures that created channels are deleted when done

remove "Test" prefix from test method names

I think that this prefix when already displayed under a class with a suffix of "Tests" is redundant

Remove mention of old test project

fix an issue from forgetting to await Assert.ThrowsAsync

explicitly disable parallelization on integration tests

add test for GuildPermission modify

separate unit and integration tests, start writing channel and guild permission tests

copy over the color tests

copy over the emote tests

make the mocked entities sealed classes

properly dispose the CommandService in the TypeReaderTests

fix bug in value validation of EmbedFieldBuilder

hey, these tests actually found a bug!

add tests for the MentionUtils class

add tests for the Format util class

remove all of the old tests

add analyzer tests (copied from old tests)

add tests for the SnowflakeUtils class

add integration tests

these get around the issue of state persisting between tests by creating and deleting a guild for each set of tests. these shouldn't be run excessively because of the rate limits, but should be fine every now and then

remove unnecessary launchSettings.json

update outdated string

don't create a new guild each time, as that can result in errors

this can happen if a bot creates too many guilds without properly deleting them

add more measures that created channels are deleted when done

remove "Test" prefix from test method names

I think that this prefix when already displayed under a class with a suffix of "Tests" is redundant

Remove mention of old test project

fix an issue from forgetting to await Assert.ThrowsAsync

explicitly disable parallelization on integration tests

update the azure CI build script

separate execution of test projects so that if one fails the other will not pass

one of the unit tests failed, but the analzyer tests passed

fix test that would break in different timezones

enable the integration tests (only on dev branch)

* Update mocked channels for changed SendFileAsync signature

* comment out the integration tests from the build script

no bot token is provided to this script, and use of integration tests in CI is questionable here

* force rebuild because Azure linux build broke
2019-06-12 16:08:03 -04:00
Chris Johnston
40844b9e13 feature(binbrk): Add properties missing from User and Activity models (#1237)
* WIP commit, update IActivity and IUser with missing types

* incomplete implementation of interfaces

* Add implementation of activity flags, and extension method to check flag

* remove usings that were not required

* clean up files and add documentation where missing

* remove unused usings

* Add remark saying that premium_type info may be inaccessible to bots

it seems that this information can not be accessed by any user,
and may require the identity oauth scope

* Add locale property to the user model

adds the locale property to the user model, which appears not to be
specified for bots

* rename ActivityFlags

* Add incomplete xmldoc to ActivityFlag

Added xmldoc to the ActivityFlag type, excluded flags that i was unsure about

* rename the UserFlags file

* Add incomplete xmldoc to UserFlag enum

* Remove unnecessary extension methods and use built-in functionality

* use <c> tag for xmldoc 'null's

* Add xmldoc for JoinRequest ActivityFlag

* improve the PremiumType xmldoc

* Add zero activityflag

* Add summary tag verbs, example of IUser locale

* Rename Flag enum types to use Properties suffix

* Expose the details field in the Game model

* update Activity extension methods to support Details field

* Use inherited Details implementation in RichGame

* lint: remove commented out code from debugging

* Fix issue in previous commit

* Move oauth-only user fields to SelfUser classes

Moves the implementation of the Flags, PremiumType, and Locale user fields to ISelfUser classes. In testing, it seemed that normal bot accounts did not have this information supplied to them. When tested with a Bearer token in the Rest client, these fields are set.

* remove old HypeSquadEvents flag that appears to have been replaced with the new HypeSquad flags
2019-06-12 16:00:30 -04:00
Christopher Felegy
10463cfdd2 meta: bump version to v2.2.0-dev, update CHANGELOG 2019-06-08 23:13:11 -04:00
Christopher Felegy
dfd82a5ab7 meta: v2.1.1 2019-06-08 20:14:45 -04:00
Christopher Felegy
d287ed1d4c fix: add EmbedTypeConverter with unknown handling
Prevents messages with an unknown EmbedType from failing to unmarshal
2019-06-08 19:40:07 -04:00
Casino Boyale
1cc5d7321b fix: fixed optionals having IsSpecified true when objects weren't in cache (#1323)
* Fixed optionals having IsSpecified true when objects weren't in cache

* Removed double null check
2019-06-06 16:22:34 -04:00
Christopher Felegy
2e95c4913b fix: ignore escape behavior on remainder parameters (#994)
Co-authored-by: Quahu <quahu@gmail.com>
2019-06-05 17:13:29 -04:00
Christopher Felegy
a8c853f1ec Revert "Merge remote-tracking branch 'quahu/dev' into dev"
This reverts commit 8fb0d5dc13, reversing
changes made to 3e65e03b85.
2019-06-05 17:11:06 -04:00
Christopher Felegy
8fb0d5dc13 Merge remote-tracking branch 'quahu/dev' into dev 2019-06-05 17:07:42 -04:00
Christopher Felegy
3e65e03b85 meta: bump Ix.Net to 3.2.0 2019-06-05 16:47:57 -04:00
Christopher Felegy
46da3523d0 docs: update TextChannelProperties to 6-hour slow mode 2019-06-05 16:37:55 -04:00
Chris Johnston
fc48c6606d feature: Disconnect guild members from voice channels (#1311)
* Feature: Disconnect users from voice channels

Updates GuildUserProperties to allow for setting either Channel or ChannelId to null, which will disconnect users from voice channels.

The type of ChannelId has been updated from a ulong to ulong?, which matches the latest api documentation.

* docs: update xmldoc wording

* breaking workaround, revert ChannelId to ulong

This is a workaround to prevent this PR from being a breaking
change. Reverts the type of GuildUserProperties#ChannelId to a
ulong from a ulong?. Guild Users may no longer be kicked by
setting this property to null, but setting
GuildUserProperties#Channel should still work.
2019-06-05 13:41:18 -04:00
Jyrka98
4433ca741b fix: Update maximum value for SlowModeInterval (#1320)
Discord allows the slow mode to be up to 6 hours.
2019-06-05 11:55:50 -04:00
Christopher Felegy
63ccd05faa lint: newline on Emote#GetHashCode 2019-06-04 14:05:59 -04:00
Tiago Cabral
1b54883896 fix: Changed Emote GetHashCode to not include Name (#1317)
Continuation of commit abf3e90 attempt to fix Emote comparisons,
as Hash comparisons are done before Equals in Comparers
2019-06-04 14:04:53 -04:00
Casino Boyale
abf3e905f2 fix: Changed Emote equals to not compare emote names (#1316)
In reference to what was discussed in the dnet channel.
2019-06-03 13:14:20 -04:00
Chris Johnston
1f55f01866 feature(internal): Set the @everyone IRole for @everyone and @here tags (#1313)
* Set the @everyone IRole for @everyone and @here tags

Adds support for setting the IRole corresponding to @everyone or @here in a the tags of a message. Previously this would only set the TagType, but leave the value as null.

This does not distinguish between @everyone and @here, as that's done using TagType. The values of both will be the same.

This issue was suggested by @TheCasino

* use the EveryoneRole property

oops

* use null conditional operator instead of a null check
2019-06-02 19:53:26 -04:00
Christopher Felegy
4d7de176d0 meta: add versioning guarantees to README 2019-06-02 19:52:39 -04:00
Christopher Felegy
c78a6790b1 fix: don't raise REST log events twice
The DiscordSocketClient and DiscordSocketRestClient share the same
backing API client, so the Log events on both clients will be raised
from the same API calls. Proxying log events from the
DiscordSocketRestClient then means that the Log event the user hooks
into will be raised twice for a single log message.

Thanks to @TheCasino for noticing this.
2019-05-19 12:16:37 -04:00
Christopher Felegy
bc66d7ea4e meta: bump version to 2.1.1-dev 2019-05-19 12:14:36 -04:00
Christopher Felegy
c9e2c034f8 ci: use buildTag variable 2019-05-19 10:43:37 -04:00
Christopher Felegy
89da65af96 ci: deploy on tags 2019-05-19 10:42:19 -04:00
Christopher Felegy
8118c11efe ci: build/tag includes must be a list 2019-05-19 10:36:08 -04:00
Christopher Felegy
53e0202677 meta: CI should build tag commits as well 2019-05-19 10:33:05 -04:00
Christopher Felegy
63381f1204 meta: v2.1.0
happy patch saturday
2019-05-18 22:26:16 -04:00
Christopher Felegy
03304ff364 lint: ClientExtensions should be a member of Discord.Rest 2019-05-18 17:42:57 -04:00
Alex Gravely
1356ea9736 feature: Add AddGuildUserAsync guild ID extension method. (#1240) 2019-05-18 17:40:04 -04:00
Alex Gravely
655a0069a1 docs: Add Webhook example. (#1241)
* Add Webhook example.

* Fix spacing.

* Update to use webhook URL ctor.
2019-05-18 17:24:06 -04:00
Chris Johnston
4eb958dcee test: Fix broken ChannelPermissions test, refactor TestChannelPermissionModify (#1287)
* fix missing priority speaker flag

* rewrite the TestChannelPermissionModify test
2019-05-18 17:21:24 -04:00
Christopher Felegy
f6e320053b fix: ensure that exceptions will be logged
Resolves #1238.

I'm not sure where this bug came from, a git blame revealed no change to
the timed event handler code since it was initiall written two years
ago.

I've found that when the event handler times out, the handler task will
be manually completed (as opposed to within Task.WhenAny), which then
bubbles the exception and allows the error to be logged.

Ensuring that the handler is completed individually, regardless of
whether or not the timeout task completed, seems to fix this problem.
2019-05-18 09:42:37 -04:00
Christopher Felegy
a44c13af78 fix: call OnLogin/OnLogout on DiscordSocketRestClient
Resolves #1277.
2019-05-18 09:32:49 -04:00
Chris Johnston
f3b20b2b6d feature: Add support for spoiler formatting & attachments (#1255)
Resolves #1216.

* Add support for spoiler formatting

* Implement support for sending message attachments that are spoilers

* use consistent naming

* update docstring for new isSpoiler param

* move extension method to be under core project, make spoiler prefix a const

* typo fix

* update missing xmldocs

* move SpoilerPrefix const outside of interface

* Add isSpoiler support to webhook client

adds the isSpoiler field to uploading files with a webhook, which will only
insert "SPOILER_" to the start of the filename. This does not include other
fields in the payload, as this is not in the documentation, and was not observed
like in the regular client
2019-05-17 19:28:40 -04:00
Christopher Felegy
76f82d687b perf: only allocate cacheableList once 2019-05-17 19:20:55 -04:00
Christopher Felegy
358b9e7b7b lint: fix docstring inconsistency 2019-05-17 19:09:07 -04:00
Christopher Felegy
03e6401d19 lint: clean up bulk delete PR 2019-05-17 19:08:20 -04:00
NovusTheory
dec353e57f feature: messages bulk deleted event (from previous PR #1120) (#1236)
* Reimplement messags bulk deleted event RogueException/Discord.Net#1120

* Update remark

* Backwards compatability with config option
2019-05-17 18:49:36 -04:00
GreemDev
b52b54d80c fix: EmbedBuilderExtensions no longer has an extension for WithAuthor(IGuildUser). (#1294)
The embed should not display nickname#discriminator as that's incorrect.
So the extension was scrapped altogether to use the IUser (and by inheritance, IGuildUser) one.
2019-05-13 18:30:38 -04:00
Still Hsu
4309550ca0 docs: Main docs update (#1304)
* Remove template in favor of official samples

* Fixed a variable name copy pasta mistake

line 35 was _database.GetData() instead of DBService.GetData()

* Experimental theme change

* Change paragraph, code, heading fonts
* Widen viewport

* Update DocFX.Plugins.LastModified v1.2.3

* Exclude Discord.API in docs

* Add remarks for SocketReaction properties

* Add examples for BaseSocketClient.Events

* Add additional clarification for some methods

* Move IUser and IGuildChannel examples

* Clarify several guides samples with notes

- Reword TypeReader comment to avoid giving the idea that the sample itself is "obsolete"
- Remove CommandException logging comment regarding C#7.0 as the version is now the standard across VS2017 and up
- Remove suggestion about handling result in command handler since it is now advised to use CommandExecuted instead
+ Add additional comment to clarify ctor for DI setup

* Add/migrate code examples

* Incorporate material design theme

License @ https://github.com/ovasquez

* Update installation and nightly guide

* Fix improper indentations made obvious by the widen viewport
* Fix minor grammar issues
+ Add installation for nightly build using dotnet CLI

* Fix nav level indentation

* Revise "Your First Bot" article

* Merge some paragraphs to avoid clutter while keeping readability
* Reword the use of command framework
+ Add additional warning/note about environment variable

* Add additional indent level

* Fix indentation text warping

* Remove connections sample

* Update logging sample

Remove redundant part of the sample

* Remove mention of RPC

* Remove misleading section about commands

- Remove command sample from complete snippet
* Revise "Your First Bot" command paragraphs
* Change wording to hint devs that additional command parser packages may be available, as more and more begin to crop up

* Update themes

* Add XML docs contribution guidelines


Update guidelines

* Update CommandExecuted remarks

* Fix precondition remarks typo
no one saw that ok

* Fix permission sample in docfx

* Fix IMessageChannel samples

* Update docs/_template/light-dark-theme/styles/docfx.vendor.minify.css

Co-Authored-By: Still34 <341464@gmail.com>

* Update docs/_template/light-dark-theme/styles/material.css

Co-Authored-By: Still34 <341464@gmail.com>

* Update docs/_template/light-dark-theme/styles/material.css

Co-Authored-By: Still34 <341464@gmail.com>
2019-05-13 18:29:47 -04:00
Chris Johnston
5ea3e113b8 docs: add missing xmldoc for inherited properties and NotAGuildErrorMessage (#1301)
- adds inheritdoc tag to the inherited ErrorMessage properties of several attributes

- adds xmldoc summary for the NotAGuildErrorMessage properties
2019-05-13 18:28:13 -04:00
Chris Johnston
bb61efabf3 feature: Check for whitespace or newline characters in tokens (#1305)
* Trim whitespace from tokens before logging in

This change trims whitespace characters from the supplied token before it is used to log in. Users can encounter this accidentally if they read their token from a file that ends with a blank line.

Leading whitespace will make the token invalid. Trailing whitespace or \n (not \r\n) will also fail to log in. \r\n (CRLF) doesn't fail because of the line break style for http request headers.

* revert trimming api token

* add check for whitespace or newline characters to existing token validation

Checks to see if a token contains any illegal characters, like whitespace or a newline. If it is, throws an ArgumentException warning the user that their token may be invalid.

I considered only checking the first and last character, but given that a token containing whitespace or a newline wouldn't work either I figured this made sense.

* removed unused usings

These were leftover from a previous approach using an ImmutableHashSet
2019-05-13 18:27:45 -04:00
Still Hsu
0275f7df50 docs: Update copyright year and docs version (#1243) 2019-05-04 17:18:25 -04:00
Chris Johnston
f2113c7c2b feature: Add webhook url overload for DiscordWebhookClient (#1260)
* Add webhook url overload for DiscordWebhookClient

Adds an overloaded constructor for `DiscordWebhookClient` which accepts the webhook URL. This URL is parsed using a regex for the id and token. If the token is invalid an `ArgumentException` is thrown.

* add null or whitespace check

* add some tests for the new DiscordWebhookClient constructor

* make the Regex static, specify flags

* update regex to look for "discordapp"

* specify reason why exception is thrown despite regex match

* move parsing logic into new function for testing
2019-05-04 17:14:32 -04:00
Chris Johnston
1ae42207f8 feature: Fix #1270 Add the AuthorId to MessageDeleteAuditLogData (#1271)
* Fix #1270 Add the AuthorId to MessageDeleteAuditLogData

Fix #1270

Adds the AuthorId property to MessageDeleteAuditLogData, which is set
by the TargetId in the audit log entry data.
This property is the user id that created those messages in the first place.
I am not aware of an instance of when this value would not be supplied.

* Adjust xmldoc wording
2019-05-04 17:08:46 -04:00
Still Hsu
00d3f5a8e5 feature: Add GuildMemberJoin MessageType(#1263) 2019-05-04 17:08:18 -04:00
Still Hsu
e03c5274f8 feature: Add GetCategory method (#1261) 2019-05-04 17:07:56 -04:00
Chris Johnston
9084c4214e feature: Fix #1280 Add NewsChannel Types (#1293)
* add News channel type

* remove (very outdated) todo

* add [Socket/Rest]NewsChannel types

* update TextChannel properties to include a Type optional parameter with validation

as of writing, this feature is still only available to verified guilds, which makes it impossible for testing.

* actually create the news channels when given the type

* throw NotSupportedException in News channel

throw a NotSupportedException whenever trying to use SlowModeInterval or anything related to overwrite permissions

* make RestNewsChannel throw NotSupportedException also

* remove the (untested) ability to change channel types
2019-05-04 17:07:31 -04:00
Christopher Felegy
2254a99942 meta: bump version to 2.1.0-dev 2019-05-04 17:05:26 -04:00