Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС

Discord сСрвСр ΠΈ гильдия-Ρ‡Π°Ρ‚ сообщСства

Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. ΠšΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΏΡ€ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π€ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС

ВсСм ΠΏΡ€ΠΈΠ²Π΅Ρ‚. НапоминаСм, Ρ‡Ρ‚ΠΎ Ρƒ нашСго русскоязычного сообщСства Π΅ΡΡ‚ΡŒ свой Discord сСрвСр, Π½Π° ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ Π²Ρ‹ всСгда ΠΌΠΎΠΆΠ΅Ρ‚Π΅ Π·Π°Π΄Π°Ρ‚ΡŒ вопросы Π΄Ρ€ΡƒΠ³ΠΈΠΌ ΠΈΠ³Ρ€ΠΎΠΊΠ°ΠΌ, Π½Π°ΠΉΡ‚ΠΈ Π½ΠΎΠ²Ρ‹Ρ… Π·Π½Π°ΠΊΠΎΠΌΡ‹Ρ…, гильдии, ΠΈΠ»ΠΈ просто компанию Π½Π° нСсколько часов ΠΈΠ³Ρ€Ρ‹. Π’Π°ΠΊΠΆΠ΅ для удобства ΠΈΠ³Ρ€ΠΎΠΊΠΎΠ² Π±Ρ‹Π»Π° создана «гильдия-Ρ‡Π°Ρ‚Β», которая ΠΏΠΎΠ·Π²ΠΎΠ»ΠΈΡ‚ Π²Π°ΠΌ всС Ρ‚ΠΎ ΠΆΠ΅ самоС Ρ‚ΠΎΠ»ΡŒΠΊΠΎ прямо Π² ΠΈΠ³Ρ€Π΅.

НСкотороС врСмя гильдия Π½Π°Ρ…ΠΎΠ΄ΠΈΠ»Π°ΡΡŒ Π² Ρ€Π΅ΠΆΠΈΠΌΠ΅ тСстирования ΠΈ Π½Π΅ΠΏΠ»ΠΎΡ…ΠΎ сСбя ΠΏΠΎΠΊΠ°Π·Π°Π»Π°, Ρ‚Π°ΠΊ Ρ‡Ρ‚ΠΎ Π±Ρ‹Π»ΠΎ Ρ€Π΅ΡˆΠ΅Π½ΠΎ Π΄Π°Π»Π΅Π΅ Π΅Ρ‘ Ρ€Π°Π·Π²ΠΈΠ²Π°Ρ‚ΡŒ.
Π“ΠΈΠ»ΡŒΠ΄ΠΈΡ создана Π½Π΅ для Ρ‚ΠΎΠ³ΠΎ, Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΡΡ‚Π°Ρ‚ΡŒ ΠΊΡ€ΡƒΠΏΠ½ΠΎΠΉ Π“Π˜, Π΄ΠΎΠ±ΠΈΠ²Π°ΡŽΡ‰Π΅ΠΉΡΡ Ρ‡Π΅Π³ΠΎ-Π»ΠΈΠ±ΠΎ. По сути, это Π²Ρ‹Π΄Π΅Π»Π΅Π½Π½Ρ‹ΠΉ Π²Π½ΡƒΡ‚Ρ€ΠΈΠΈΠ³Ρ€ΠΎΠ²ΠΎΠΉ Ρ‡Π°Ρ‚, Π³Π΄Π΅ Π²Ρ‹ смоТСтС Π½Π°ΠΉΡ‚ΠΈ русскоязычных ΠΈΠ³Ρ€ΠΎΠΊΠΎΠ², находящихся Π½Π° Π΄Π°Π½Π½Ρ‹ΠΉ ΠΌΠΎΠΌΠ΅Π½Ρ‚ Π² ΠΈΠ³Ρ€Π΅, ΠΈ ΠΏΠΎΠΉΡ‚ΠΈ с Π½ΠΈΠΌΠΈ ΠΏΠΎ своим ΠΈΠ³Ρ€ΠΎΠ²Ρ‹ΠΌ Π΄Π΅Π»Π°ΠΌ.
Π Π΅ΠΏΡ€Π΅Π·Π΅Π½Ρ‚Π° Π½Π΅ трСбуСтся, ΠΊΠ°ΠΊΠΈΡ…-Π»ΠΈΠ±ΠΎ сборов, ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΡΡ‚Π² ΠΈ Ρ‚Ρ€Π΅Π±ΠΎΠ²Π°Π½ΠΈΠΉ (ΠΊΡ€ΠΎΠΌΠ΅ ΠΊΠ°ΠΊ Π½ΠΎΡ€ΠΌΠ°Π»ΡŒΠ½ΠΎ ΠΎΠ±Ρ‰Π°Ρ‚ΡŒΡΡ ΠΈ Π½Π΅ Π½Π°Ρ€ΡƒΡˆΠ°Ρ‚ΡŒ Π±Π°Π½Π°Π»ΡŒΠ½Ρ‹Ρ… ΠΏΡ€Π°Π²ΠΈΠ» Ρ…ΠΎΡ€ΠΎΡˆΠ΅Π³ΠΎ Ρ‚ΠΎΠ½Π°) Π½Π΅Ρ‚.

Π”Ρ€ΡƒΠ³ΠΈΠ΅ гильдии ΠΌΠΎΠ³ΡƒΡ‚ Π·Π°Π½ΠΈΠΌΠ°Ρ‚ΡŒΡΡ Ρ€Π΅ΠΊΡ€ΡƒΡ‚ΠΈΠ½Π³ΠΎΠΌ Π² Ρ‡Π°Ρ‚Π΅ гильдии сообщСства (Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π½Π΅ Π½Π°Π΄ΠΎ ΡΠΏΠ°ΠΌΠΈΡ‚ΡŒ, поТалуйста), это Ρ‚ΠΎΠ»ΡŒΠΊΠΎ привСтствуСтся β€” Π²Ρ‹ ΠΌΠΎΠΆΠ΅Ρ‚Π΅ Π½Π°ΠΉΡ‚ΠΈ здСсь Π½ΠΎΠ²Ρ‹Ρ… людСй для вашСй гильдии.

ΠŸΠΎΠ»ΡƒΡ‡ΠΈΠ»ΡΡ Π²ΠΏΠΎΠ»Π½Π΅ ΡƒΠ΄ΠΎΠ±Π½Ρ‹ΠΉ инструмСнт для поиска Π½ΠΎΠ²Ρ‹Ρ… Π΄Ρ€ΡƒΠ·Π΅ΠΉ, Ρ‚ΠΎΠ²Π°Ρ€ΠΈΡ‰Π΅ΠΉ ΠΈ ΡΠΎΠ³ΠΈΠ»ΡŒΠ΄ΠΈΠΉΡ†Π΅Π².
Π§Ρ‚ΠΎΠ±Ρ‹ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ ΠΏΡ€ΠΈΠ³Π»Π°ΡˆΠ΅Π½ΠΈΠ΅ Π² гильдию, Π½Π°ΠΏΠΈΡˆΠΈΡ‚Π΅ Π½ΠΈΠΊ Π² Π²Ρ‹Π΄Π΅Π»Π΅Π½Π½Ρ‹ΠΉ ΠΊΠ°Π½Π°Π» Π² дискордС (#community_guild) ΠΈ ΠΆΠ΄ΠΈΡ‚Π΅ ΠΏΡ€ΠΈΠ³Π»Π°ΡˆΠ΅Π½ΠΈΡ Π² ΠΈΠ³Ρ€Π΅.

И Π΅Ρ‰Π΅ Ρ€Π°Π· ссылка для Π²Ρ…ΠΎΠ΄Π° Π½Π° Discord сСрвСр β€” https://discord.gg/cAPSahg

Ну ΠΈ Π½Π΅ Π·Π°Π±Ρ‹Π²Π°Π΅ΠΌ ΠΏΡ€ΠΎ сообщСство Π² VK, Π³Π΄Π΅ Π²Π°ΠΌ Ρ‚Π°ΠΊΠΆΠ΅ отвСтят Π½Π° вопросы ΠΏΠΎ ΠΈΠ³Ρ€Π΅ ΠΈ Π³Π΄Π΅ Π΅ΡΡ‚ΡŒ Π²Ρ‹Π΄Π΅Π»Π΅Π½Π½Ρ‹Π΅ Ρ‚Π΅ΠΌΡ‹ для поиска Π΄Ρ€ΡƒΠ·Π΅ΠΉ ΠΈ гильдий.

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

ВступлСниС

ВсСм ΠΏΡ€ΠΈΠ²Π΅Ρ‚! НСдавно я написал Discord Π±ΠΎΡ‚Π° для World of Warcraft гильдии. Он рСгулярно Π·Π°Π±ΠΈΡ€Π°Π΅Ρ‚ Π΄Π°Π½Π½Ρ‹Π΅ ΠΎΠ± ΠΈΠ³Ρ€ΠΎΠΊΠ°Ρ… с сСрвСров ΠΈΠ³Ρ€Ρ‹ ΠΈ ΠΏΠΈΡˆΠ΅Ρ‚ сообщСния Π² Discord ΠΎ Ρ‚ΠΎΠΌ Ρ‡Ρ‚ΠΎ ΠΊ гильдии присоСдинился Π½ΠΎΠ²Ρ‹ΠΉ ΠΈΠ³Ρ€ΠΎΠΊ ΠΈΠ»ΠΈ ΠΎ Ρ‚ΠΎΠΌ Ρ‡Ρ‚ΠΎ гильдию ΠΏΠΎΠΊΠΈΠ½ΡƒΠ» старый ΠΈΠ³Ρ€ΠΎΠΊ. ΠœΠ΅ΠΆΠ΄Ρƒ собой ΠΌΡ‹ ΠΏΡ€ΠΎΠ·Π²Π°Π»ΠΈ этого Π±ΠΎΡ‚Π° Π‘Π°Ρ‚Ρ€Π°ΠΊ.

ΠžΡ‚ вас Π½Π΅ потрСбуСтся Π½ΠΈΠΊΠ°ΠΊΠΈΡ… Π·Π½Π°Π½ΠΈΠΉ ΠΎΠ± ΠΈΠ³Ρ€Π΅. Π― написал ΠΌΠ°Ρ‚Π΅Ρ€ΠΈΠ°Π» Ρ‚Π°ΠΊ Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΌΠΎΠΆΠ½ΠΎ Π±Ρ‹Π»ΠΎ Π°Π±ΡΡ‚Ρ€Π°Π³ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒΡΡ ΠΎΡ‚ ΠΈΠ³Ρ€Ρ‹ ΠΈ сдСлал Π·Π°Π³Π»ΡƒΡˆΠΊΡƒ для Π΄Π°Π½Π½Ρ‹Ρ… ΠΎΠ± ΠΈΠ³Ρ€ΠΎΠΊΠ°Ρ…. Но Ссли Ρƒ вас Π΅ΡΡ‚ΡŒ учСтная запись Π² Battle.net, Ρ‚ΠΎ Π²Ρ‹ смоТСтС ΠΏΠΎΠ»ΡƒΡ‡Π°Ρ‚ΡŒ Ρ€Π΅Π°Π»ΡŒΠ½Ρ‹Π΅ Π΄Π°Π½Π½Ρ‹Π΅.

Для понимания ΠΌΠ°Ρ‚Π΅Ρ€ΠΈΠ°Π»Π°, ΠΎΡ‚ вас оТидаСтся хотя Π±Ρ‹ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡŒΠ½Ρ‹ΠΉ ΠΎΠΏΡ‹Ρ‚ создания Π²Π΅Π± сСрвисов с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ Ρ„Ρ€Π΅ΠΉΠΌΠ²ΠΎΡ€ΠΊΠ° ASP.NET ΠΈ нСбольшой ΠΎΠΏΡ‹Ρ‚ Ρ€Π°Π±ΠΎΡ‚Ρ‹ с Docker.

На ΠΊΠ°ΠΆΠ΄ΠΎΠΌ шагС Π±ΡƒΠ΄Π΅ΠΌ постСпСнно Π½Π°Ρ€Π°Ρ‰ΠΈΠ²Π°Ρ‚ΡŒ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΎΠ½Π°Π».

Π‘ΠΎΠ·Π΄Π°Π΄ΠΈΠΌ Π½ΠΎΠ²Ρ‹ΠΉ web api ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ с ΠΎΠ΄Π½ΠΈΠΌ ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»Π»Π΅Ρ€ΠΎΠΌ /check. ΠŸΡ€ΠΈ ΠΎΠ±Ρ€Π°Ρ‰Π΅Π½ΠΈΠΈ ΠΊ этому адрСсу Π±ΡƒΠ΄Π΅ΠΌ ΠΎΡ‚ΠΏΡ€Π°Π²Π»ΡΡ‚ΡŒ строку β€œHello!” Π² Discord Ρ‡Π°Ρ‚.

Научимся ΠΏΠΎΠ»ΡƒΡ‡Π°Ρ‚ΡŒ Π΄Π°Π½Π½Ρ‹Π΅ ΠΎ составС гильдии с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ Π³ΠΎΡ‚ΠΎΠ²ΠΎΠΉ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ ΠΈΠ»ΠΈ Π·Π°Π³Π»ΡƒΡˆΠΊΠΈ.

Научимся ΡΠΎΡ…Ρ€Π°Π½ΡΡ‚ΡŒ Π² кэш ΠΏΠΎΠ»ΡƒΡ‡Π΅Π½Π½Ρ‹ΠΉ список ΠΈΠ³Ρ€ΠΎΠΊΠΎΠ² Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΏΡ€ΠΈ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΡ… ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ°Ρ… Π½Π°Ρ…ΠΎΠ΄ΠΈΡ‚ΡŒ различия с ΠΏΡ€Π΅Π΄Ρ‹Π΄ΡƒΡ‰Π΅ΠΉ вСрсиСй списка. Обо всСх измСнСниях Π±ΡƒΠ΄Π΅ΠΌ ΠΏΠΈΡΠ°Ρ‚ΡŒ Π² Discord.

НапишСм Dockerfile для нашСго ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° ΠΈ размСстим ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ Π½Π° хостингС Heroku.

ΠŸΠΎΡΠΌΠΎΡ‚Ρ€ΠΈΠΌ Π½Π° нСсколько способов ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ пСриодичСскоС Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΊΠΎΠ΄Π°.

Π Π΅Π°Π»ΠΈΠ·ΡƒΠ΅ΠΌ Π°Π²Ρ‚ΠΎΠΌΠ°Ρ‚ΠΈΡ‡Π΅ΡΠΊΡƒΡŽ сборку, запуск тСстов ΠΈ ΠΏΡƒΠ±Π»ΠΈΠΊΠ°Ρ†ΠΈΡŽ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° послС ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΠΊΠΎΠΌΠΌΠΈΡ‚Π° Π² master

Π¨Π°Π³ 1. ΠžΡ‚ΠΏΡ€Π°Π²Π»ΡΠ΅ΠΌ сообщСниС Π² Discord

Нам потрСбуСтся ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ Π½ΠΎΠ²Ρ‹ΠΉ ASP.NET Core Web API ΠΏΡ€ΠΎΠ΅ΠΊΡ‚.

Π”ΠΎΠ±Π°Π²ΠΈΠΌ ΠΊ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Ρƒ Π½ΠΎΠ²Ρ‹ΠΉ ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»Π»Π΅Ρ€

ΠŸΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ Π΅Π³ΠΎ ΠΌΠΎΠΆΠ½ΠΎ Π² ΠΏΡƒΠ½ΠΊΡ‚Π΅ integrations Π² настройках любого тСкстового ΠΊΠ°Π½Π°Π»Π° вашСго Discord сСрвСра.

Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. ΠšΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΏΡ€ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π€ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордСБозданиС webhook

Π”ΠΎΠ±Π°Π²ΠΈΠΌ webhook Π² appsettings.json нашСго ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°. ПозТС ΠΌΡ‹ унСсСм Π΅Π³ΠΎ Π² ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Π΅ окруТСния Heroku. Если Π²Ρ‹ Π½Π΅ Π·Π½Π°ΠΊΠΎΠΌΡ‹ с Ρ‚Π΅ΠΌ ΠΊΠ°ΠΊ Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ с ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠ΅ΠΉ Π² ASP Core ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°Ρ… ΠΏΡ€Π΅Π΄Π²Π°Ρ€ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ ΠΈΠ·ΡƒΡ‡ΠΈΡ‚Π΅ эту Ρ‚Π΅ΠΌΡƒ.

Π’Π΅ΠΏΠ΅Ρ€ΡŒ создадим Π½ΠΎΠ²Ρ‹ΠΉ сСрвис DiscordBroker, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ ΡƒΠΌΠ΅Π΅Ρ‚ ΠΎΡ‚ΠΏΡ€Π°Π²Π»ΡΡ‚ΡŒ сообщСния Π² Discord. Π‘ΠΎΠ·Π΄Π°ΠΉΡ‚Π΅ ΠΏΠ°ΠΏΠΊΡƒ Services ΠΈ помСститС Ρ‚ΡƒΠ΄Π° Π½ΠΎΠ²Ρ‹ΠΉ класс, эта ΠΏΠ°ΠΏΠΊΠ° Π½Π°ΠΌ Π΅Ρ‰Π΅ пригодится.

По сути этот Π½ΠΎΠ²Ρ‹ΠΉ сСрвис Π΄Π΅Π»Π°Π΅Ρ‚ post запрос ΠΏΠΎ адрСсу ΠΈΠ· webhook ΠΈ содСрТит сообщСниС Π² Ρ‚Π΅Π»Π΅ запроса.

Как Π²ΠΈΠ΄ΠΈΡ‚Π΅, ΠΌΡ‹ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΠΌ Π²Π½Π΅Π΄Ρ€Π΅Π½ΠΈΠ΅ зависимостСй. IConfiguration ΠΏΠΎΠ·Π²ΠΎΠ»ΠΈΡ‚ Π½Π°ΠΌ Π΄ΠΎΡΡ‚Π°Ρ‚ΡŒ webhook ΠΈΠ· ΠΊΠΎΠ½Ρ„ΠΈΠ³ΠΎΠ², Π° IHttpClientFactory ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ Π½ΠΎΠ²Ρ‹ΠΉ HttpClient.

ΠšΡ€ΠΎΠΌΠ΅ Ρ‚ΠΎΠ³ΠΎ, я ΠΈΠ·Π²Π»Π΅ΠΊ интСрфСйс этого класса, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π² дальнСйшСм ΠΌΠΎΠΆΠ½ΠΎ Π±Ρ‹Π»ΠΎ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ Π΅Π³ΠΎ Π·Π°Π³Π»ΡƒΡˆΠΊΡƒ ΠΏΡ€ΠΈ тСстировании. Π”Π΅Π»Π°ΠΉΡ‚Π΅ это для всСх сСрвисов ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΌΡ‹ Π±ΡƒΠ΄Π΅ΠΌ ΡΠΎΠ·Π΄Π°Π²Π°Ρ‚ΡŒ Π΄Π°Π»Π΅Π΅.

НС Π·Π°Π±ΡƒΠ΄ΡŒΡ‚Π΅ Ρ‡Ρ‚ΠΎ Π½ΠΎΠ²Ρ‹ΠΉ класс Π½ΡƒΠΆΠ½ΠΎ Π±ΡƒΠ΄Π΅Ρ‚ Π·Π°Ρ€Π΅Π³ΠΈΡΡ‚Ρ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Π² Startup.

А Ρ‚Π°ΠΊΠΆΠ΅ Π½ΡƒΠΆΠ½ΠΎ Π±ΡƒΠ΄Π΅Ρ‚ Π·Π°Ρ€Π΅Π³ΠΈΡΡ‚Ρ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ HttpClient, для Ρ€Π°Π±ΠΎΡ‚Ρ‹ IHttpClientFactory.

Π’Π΅ΠΏΠ΅Ρ€ΡŒ ΠΌΠΎΠΆΠ½ΠΎ Π²ΠΎΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒΡΡ Π½ΠΎΠ²Ρ‹ΠΌ классом Π² ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»Π»Π΅Ρ€Π΅.

ЗапуститС ΠΏΡ€ΠΎΠ΅ΠΊΡ‚, Π·Π°ΠΉΠ΄ΠΈΡ‚Π΅ ΠΏΠΎ адрСсу /check Π² Π±Ρ€Π°ΡƒΠ·Π΅Ρ€Π΅ ΠΈ ΡƒΠ±Π΅Π΄ΠΈΡ‚Π΅ΡΡŒ Ρ‡Ρ‚ΠΎ Π² Discord ΠΏΡ€ΠΈΡˆΠ»ΠΎ Π½ΠΎΠ²ΠΎΠ΅ сообщСниС.

Π¨Π°Π³ 2. ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌ Π΄Π°Π½Π½Ρ‹Π΅ ΠΈΠ· Battle.net

Π£ нас Π΅ΡΡ‚ΡŒ Π΄Π²Π° Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π°: ΠΏΠΎΠ»ΡƒΡ‡Π°Ρ‚ΡŒ Π΄Π°Π½Π½Ρ‹Π΅ ΠΈΠ· настоящих сСрвСров battle.net ΠΈΠ»ΠΈ ΠΈΠ· ΠΌΠΎΠ΅ΠΉ Π·Π°Π³Π»ΡƒΡˆΠΊΠΈ. Если Ρƒ вас Π½Π΅Ρ‚ Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° Π² battle.net, Ρ‚ΠΎ пропуститС ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΉ кусок ΡΡ‚Π°Ρ‚ΡŒΠΈ Π΄ΠΎ ΠΌΠΎΠΌΠ΅Π½Ρ‚Π° Π³Π΄Π΅ приводится рСализация Π·Π°Π³Π»ΡƒΡˆΠΊΠΈ.

ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌ Ρ€Π΅Π°Π»ΡŒΠ½Ρ‹Π΅ Π΄Π°Π½Π½Ρ‹Π΅

Π’Π°ΠΌ понадобится Π·Π°ΠΉΡ‚ΠΈ Π½Π° https://develop.battle.net/ ΠΈ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ Ρ‚Π°ΠΌ Π΄Π²Π΅ ΠΏΠ΅Ρ€ΡΠΎΠ½Π°Π»ΡŒΠ½Ρ‹Ρ… строки BattleNetId ΠΈ BattleNetSecret. Они Π±ΡƒΠ΄ΡƒΡ‚ Π½ΡƒΠΆΠ½Ρ‹ Π½Π°ΠΌ Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π°Π²Ρ‚ΠΎΡ€ΠΈΠ·ΠΎΠ²Π°Ρ‚ΡŒΡΡ Π² api ΠΏΠ΅Ρ€Π΅Π΄ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΊΠΎΠΉ запросов. ΠŸΠΎΠΌΠ΅ΡΡ‚ΠΈΡ‚Π΅ ΠΈΡ… Π² appsettings.

ΠŸΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΠΌ ΠΊ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Ρƒ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΡƒ ArgentPonyWarcraftClient.

Π‘ΠΎΠ·Π΄Π°Π΄ΠΈΠΌ Π½ΠΎΠ²Ρ‹ΠΉ класс BattleNetApiClient Π² ΠΏΠ°ΠΏΠΊΠ΅ Services.

Π’ конструкторС ΠΌΡ‹ создаСм Π½ΠΎΠ²Ρ‹ΠΉ экзСмпляр класса WarcraftClient.
Π­Ρ‚ΠΎΡ‚ класс относится ΠΊ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠ΅, ΠΊΠΎΡ‚ΠΎΡ€ΡƒΡŽ ΠΌΡ‹ установили Ρ€Π°Π½Π΅Π΅. Π‘ Π΅Π³ΠΎ ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ»ΡƒΡ‡Π°Ρ‚ΡŒ Π΄Π°Π½Π½Ρ‹Π΅ ΠΎΠ± ΠΈΠ³Ρ€ΠΎΠΊΠ°Ρ….

ΠšΡ€ΠΎΠΌΠ΅ этого, Π½ΡƒΠΆΠ½ΠΎ ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ Π² appsettings ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° Π΄Π²Π΅ Π½ΠΎΠ²Ρ‹Ρ… записи RealmName ΠΈ GuildName. RealmName это Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΈΠ³Ρ€ΠΎΠ²ΠΎΠ³ΠΎ ΠΌΠΈΡ€Π°, Π° GuildName это Π½Π°Π·Π²Π°Π½ΠΈΠ΅ гильдии. Π˜Ρ… Π±ΡƒΠ΄Π΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ ΠΊΠ°ΠΊ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹ ΠΏΡ€ΠΈ запросС.

Π‘Π΄Π΅Π»Π°Π΅ΠΌ ΠΌΠ΅Ρ‚ΠΎΠ΄ GetGuildMembers Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΏΠΎΠ»ΡƒΡ‡Π°Ρ‚ΡŒ состав гильдии ΠΈ создадим модСль WowCharacterToken которая Π±ΡƒΠ΄Π΅Ρ‚ ΠΏΡ€Π΅Π΄ΡΡ‚Π°Π²Π»ΡΡ‚ΡŒ собой ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΡŽ ΠΎΠ± ΠΈΠ³Ρ€ΠΎΠΊΠ΅.

Класс WowCharacterToken слСдуСт ΠΏΠΎΠΌΠ΅ΡΡ‚ΠΈΡ‚ΡŒ Π² ΠΏΠ°ΠΏΠΊΡƒ Models.

НС Π·Π°Π±ΡƒΠ΄ΡŒΡ‚Π΅ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ BattleNetApiClient Π² Startup.

Π‘Π΅Ρ€Π΅ΠΌ Π΄Π°Π½Π½Ρ‹Π΅ ΠΈΠ· Π·Π°Π³Π»ΡƒΡˆΠΊΠΈ

Для Π½Π°Ρ‡Π°Π»Π° создадим модСль WowCharacterToken ΠΈ помСстим Π΅Π΅ Π² ΠΏΠ°ΠΏΠΊΡƒ Models. Она прСдставляСт собой ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΡŽ ΠΎΠ± ΠΈΠ³Ρ€ΠΎΠΊΠ΅.

Π”Π°Π»ΡŒΡˆΠ΅ сдСлаСм Π²ΠΎΡ‚ Ρ‚Π°ΠΊΠΎΠΉ класс

Он Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ Π·Π°ΡˆΠΈΡ‚Ρ‹ΠΉ Π² Π½Π΅Π³ΠΎ список ΠΈΠ³Ρ€ΠΎΠΊΠΎΠ². ΠŸΡ€ΠΈ ΠΏΠ΅Ρ€Π²ΠΎΠΌ Π²Ρ‹Π·ΠΎΠ²Π΅ ΠΌΠ΅Ρ‚ΠΎΠ΄Π° ΠΌΡ‹ Π²Π΅Ρ€Π½Π΅ΠΌ ΠΎΠ΄ΠΈΠ½ список, ΠΏΡ€ΠΈ ΠΏΠΎΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΡ… Π΄Ρ€ΡƒΠ³ΠΎΠΉ. Π­Ρ‚ΠΎ Π½ΡƒΠΆΠ½ΠΎ Π½Π°ΠΌ Ρ‡Ρ‚ΠΎ ΡΠΌΠΎΠ΄Π΅Π»ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ ΠΈΠ·ΠΌΠ΅Π½Ρ‡ΠΈΠ²ΠΎΠ΅ ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ api. Π­Ρ‚ΠΎΠΉ Π·Π°Π³Π»ΡƒΡˆΠΊΠΈ Ρ…Π²Π°Ρ‚ΠΈΡ‚ Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΏΡ€ΠΎΠ΄ΠΎΠ»ΠΆΠΈΡ‚ΡŒ Π΄Π΅Π»Π°Ρ‚ΡŒ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚.

Π‘Π΄Π΅Π»Π°ΠΉΡ‚Π΅ интСрфСйс ΠΈ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΡ‚Π΅ всС Ρ‡Ρ‚ΠΎ ΠΌΡ‹ создали Π² Startup.

Π’Ρ‹Π²Π΅Π΄Π΅ΠΌ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Ρ‹ Π² Discord

ПослС Ρ‚ΠΎΠ³ΠΎ ΠΊΠ°ΠΊ ΠΌΡ‹ сдСлали BattleNetApiClient, ΠΈΠΌ ΠΌΠΎΠΆΠ½ΠΎ Π²ΠΎΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒΡΡ Π² ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»Π»Π΅Ρ€Π΅ Ρ‡Ρ‚ΠΎΠ±Ρ‹ вывСсти ΠΊΠΎΠ»-Π²ΠΎ ΠΈΠ³Ρ€ΠΎΠΊΠΎΠ² Π² Discord.

Π¨Π°Π³ 3. Находим Π½ΠΎΠ²Ρ‹Ρ… ΠΈ ΡƒΡˆΠ΅Π΄ΡˆΠΈΡ… ΠΈΠ³Ρ€ΠΎΠΊΠΎΠ²

НуТно Π½Π°ΡƒΡ‡ΠΈΡ‚ΡŒΡΡ ΠΎΠΏΡ€Π΅Π΄Π΅Π»ΡΡ‚ΡŒ ΠΊΠ°ΠΊΠΈΠ΅ ΠΈΠ³Ρ€ΠΎΠΊΠΈ появились ΠΈΠ»ΠΈ ΠΏΡ€ΠΎΠΏΠ°Π»ΠΈ ΠΈΠ· списка ΠΏΡ€ΠΈ ΠΏΠΎΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΡ… запросах ΠΊ api. Для этого ΠΌΡ‹ ΠΌΠΎΠΆΠ΅ΠΌ Π·Π°ΠΊΡΡˆΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ список Π² InMemory кэшС (Π² ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΈΠ²Π½ΠΎΠΉ памяти) ΠΈΠ»ΠΈ Π²ΠΎ внСшнСм Ρ…Ρ€Π°Π½ΠΈΠ»ΠΈΡ‰Π΅.

Если Π·Π°ΠΊΡΡˆΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ список Π² InMemory кэшС, Ρ‚ΠΎ ΠΌΡ‹ потСряСм Π΅Π³ΠΎ ΠΏΡ€ΠΈ пСрСзапускС прилоТСния. ΠŸΠΎΡΡ‚ΠΎΠΌΡƒ ΠΏΠΎΠ·ΠΆΠ΅ ΠΌΡ‹ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΠΌ Π±Π°Π·Ρƒ Π΄Π°Π½Π½Ρ‹Ρ… Redis ΠΊΠ°ΠΊ Π°Π΄Π΄ΠΎΠ½ Π² Heroku ΠΈ Π±ΡƒΠ΄Π΅ΠΌ ΠΊΠ΅ΡˆΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Ρ‚ΡƒΠ΄Π°.

А ΠΏΠΎΠΊΠ° Ρ‡Ρ‚ΠΎ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΠΌ InMemory кэш Π² Startup.

GuildRepository Π½ΡƒΠΆΠ½ΠΎ Π·Π°Ρ€Π΅Π³ΠΈΡΡ‚Ρ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ ΠΊΠ°ΠΊ Singletone Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡ‚ΡŒ, Ρ‡Ρ‚ΠΎΠ±Ρ‹ кэш Π½Π΅ пСрСсоздавался Π½Π° ΠΊΠ°ΠΆΠ΄Ρ‹ΠΉ запрос.

Π’Π΅ΠΏΠ΅Ρ€ΡŒ ΠΌΠΎΠΆΠ½ΠΎ Π½Π°ΠΏΠΈΡΠ°Ρ‚ΡŒ сСрвис ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π±ΡƒΠ΄Π΅Ρ‚ ΡΡ€Π°Π²Π½ΠΈΠ²Π°Ρ‚ΡŒ Π½ΠΎΠ²Ρ‹ΠΉ список ΠΈΠ³Ρ€ΠΎΠΊΠΎΠ² с сохранСнным.

Π’ качСствС Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΠΎΠ³ΠΎ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Π° ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ модСль Report. Π•Π΅ Π½ΡƒΠΆΠ½ΠΎ ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ ΠΈ ΠΏΠΎΠΌΠ΅ΡΡ‚ΠΈΡ‚ΡŒ Π² ΠΏΠ°ΠΏΠΊΡƒ Models.

ΠŸΡ€ΠΈΠΌΠ΅Π½ΠΈΠΌ GuildService Π² ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»Π»Π΅Ρ€Π΅.

Π’Π΅ΠΏΠ΅Ρ€ΡŒ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΠΌ Π² Discord ΠΊΠ°ΠΊΠΈΠ΅ ΠΈΠ³Ρ€ΠΎΠΊΠΈ ΠΏΡ€ΠΈΡΠΎΠ΅Π΄ΠΈΠ½ΠΈΠ»ΠΈΡΡŒ ΠΈΠ»ΠΈ ΠΏΠΎΠΊΠΈΠ½ΡƒΠ»ΠΈ гильдию.

Π­Ρ‚Ρƒ Π»ΠΎΠ³ΠΈΠΊΡƒ я Π΄ΠΎΠ±Π°Π²ΠΈΠ» Π² GuildService Π² ΠΊΠΎΠ½Π΅Ρ† ΠΌΠ΅Ρ‚ΠΎΠ΄Π° Check. ΠŸΠΈΡΠ°Ρ‚ΡŒ бизнСс Π»ΠΎΠ³ΠΈΠΊΡƒ Π² ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»Π»Π΅Ρ€Π΅ Π½Π΅ стоит, Ρƒ Π½Π΅Π³ΠΎ Π΄Ρ€ΡƒΠ³ΠΎΠ΅ Π½Π°Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅. Π’ самом Π½Π°Ρ‡Π°Π»Π΅ ΠΌΡ‹ Π΄Π΅Π»Π°Π»ΠΈ Ρ‚Π°ΠΌ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΊΡƒ сообщСния Π² Discord ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ Π΅Ρ‰Π΅ Π½Π΅ сущСствовало GuildService.

МоТно вывСсти большС ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΠΈ ΠΎΠ± ΠΈΠ³Ρ€ΠΎΠΊΠ΅. Π•Π΅ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ Ссли Π²ΠΎΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒΡΡ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΎΠΉ ArgentPonyWarcraftClient

Π― Ρ€Π΅ΡˆΠΈΠ» Π½Π΅ Π΄ΠΎΠ±Π°Π²Π»ΡΡ‚ΡŒ Π² ΡΡ‚Π°Ρ‚ΡŒΡŽ большС ΠΊΠΎΠ΄Π° Π² BattleNetApiClient, Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΡΡ‚Π°Ρ‚ΡŒΡ Π½Π΅ Ρ€Π°Π·Ρ€ΠΎΡΠ»Π°ΡΡŒ Π΄ΠΎ Π±Π΅Π·ΡƒΠΌΠ½Ρ‹Ρ… Ρ€Π°Π·ΠΌΠ΅Ρ€ΠΎΠ².

Unit тСсты

Π£ нас появился класс GuildService с Π½Π΅Ρ‚Ρ€ΠΈΠ²ΠΈΠ°Π»ΡŒΠ½ΠΎΠΉ Π»ΠΎΠ³ΠΈΠΊΠΎΠΉ, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π±ΡƒΠ΄Π΅Ρ‚ ΠΈΠ·ΠΌΠ΅Π½ΡΡ‚ΡŒΡΡ ΠΈ Ρ€Π°ΡΡˆΠΈΡ€ΡΡ‚ΡŒΡΡ Π² Π±ΡƒΠ΄ΡƒΡ‰Π΅ΠΌ. Π‘Ρ‚ΠΎΠΈΡ‚ Π½Π°ΠΏΠΈΡΠ°Ρ‚ΡŒ Π½Π° Π½Π΅Π³ΠΎ тСсты. Для этого Π½ΡƒΠΆΠ½ΠΎ Π±ΡƒΠ΄Π΅Ρ‚ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ Π·Π°Π³Π»ΡƒΡˆΠΊΠΈ для BattleNetApiClient, GuildRepository ΠΈ DiscordBroker. Π― ΡΠΏΠ΅Ρ†ΠΈΠ°Π»ΡŒΠ½ΠΎ просил ΡΠΎΠ·Π΄Π°Π²Π°Ρ‚ΡŒ интСрфСйсы для этих классов Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΌΠΎΠΆΠ½ΠΎ Π±Ρ‹Π»ΠΎ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ ΠΈΡ… Ρ„Π΅ΠΉΠΊΠΈ.

Π‘ΠΎΠ·Π΄Π°ΠΉΡ‚Π΅ Π½ΠΎΠ²Ρ‹ΠΉ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ для Unit тСстов. Π—Π°Π²Π΅Π΄ΠΈΡ‚Π΅ Π² Π½Π΅ΠΌ ΠΏΠ°ΠΏΠΊΡƒ Fakes ΠΈ сдСлайтС Ρ‚Ρ€ΠΈ Ρ„Π΅ΠΉΠΊΠ°.

Π­Ρ‚ΠΈ Ρ„Π΅ΠΉΠΊΠΈ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΡŽΡ‚ Π·Π°Ρ€Π°Π½Π΅Π΅ Π·Π°Π΄Π°Ρ‚ΡŒ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΠΎΠ΅ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ для ΠΌΠ΅Ρ‚ΠΎΠ΄ΠΎΠ². Для этих ΠΆΠ΅ Ρ†Π΅Π»Π΅ΠΉ ΠΌΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ ΠΏΠΎΠΏΡƒΠ»ΡΡ€Π½ΡƒΡŽ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΡƒ Moq. Но для нашСго простого ΠΏΡ€ΠΈΠΌΠ΅Ρ€Π° достаточно ΡΠ°ΠΌΠΎΠ΄Π΅Π»ΡŒΠ½Ρ‹Ρ… Ρ„Π΅ΠΉΠΊΠΎΠ².

ΠŸΠ΅Ρ€Π²Ρ‹ΠΉ тСст Π½Π° GuildService Π±ΡƒΠ΄Π΅Ρ‚ Π²Ρ‹Π³Π»ΡΠ΄Π΅Ρ‚ΡŒ Ρ‚Π°ΠΊ:

Как Π²ΠΈΠ΄Π½ΠΎ ΠΈΠ· названия, тСст позволяСт ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΈΡ‚ΡŒ Ρ‡Ρ‚ΠΎ ΠΌΡ‹ сохраним список ΠΈΠ³Ρ€ΠΎΠΊΠΎΠ², Ссли кэш пуст. Π—Π°ΠΌΠ΅Ρ‚ΡŒΡ‚Π΅, Π² ΠΊΠΎΠ½Ρ†Π΅ тСста ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ ΡΠΏΠ΅Ρ†ΠΈΠ°Π»ΡŒΠ½Ρ‹ΠΉ Π½Π°Π±ΠΎΡ€ ΠΌΠ΅Ρ‚ΠΎΠ΄ΠΎΠ² Should, Be. Π­Ρ‚ΠΎ ΠΌΠ΅Ρ‚ΠΎΠ΄Ρ‹ ΠΈΠ· Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ FluentAssertions, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΏΠΎΠΌΠΎΠ³Π°ΡŽΡ‚ Π½Π°ΠΌ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ Assertion Π±ΠΎΠ»Π΅Π΅ Ρ‡ΠΈΡ‚Π°Π±Π΅Π»ΡŒΠ½Ρ‹ΠΌ.

Π’Π΅ΠΏΠ΅Ρ€ΡŒ Ρƒ нас Π΅ΡΡ‚ΡŒ Π±Π°Π·Π° для написания тСстов. Π― ΠΏΠΎΠΊΠ°Π·Π°Π» Π²Π°ΠΌ ΠΎΡΠ½ΠΎΠ²Π½ΡƒΡŽ идСю, дальнСйшСС написаниС тСстов ΠΎΡΡ‚Π°Π²Π»ΡΡŽ Π²Π°ΠΌ.

Π“Π»Π°Π²Π½Ρ‹ΠΉ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΎΠ½Π°Π» ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° Π³ΠΎΡ‚ΠΎΠ². Π’Π΅ΠΏΠ΅Ρ€ΡŒ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ΄ΡƒΠΌΠ°Ρ‚ΡŒ ΠΎ Π΅Π³ΠΎ ΠΏΡƒΠ±Π»ΠΈΠΊΠ°Ρ†ΠΈΠΈ.

Π¨Π°Π³ 4. ΠŸΡ€ΠΈΠ²Π΅Ρ‚ Docker ΠΈ Heroku!

Π§Ρ‚ΠΎΠ±Ρ‹ ΡƒΠΏΠ°ΠΊΠΎΠ²Π°Ρ‚ΡŒ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ Π² Docker Π½Π°ΠΌ понадобится ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ Π² ΠΊΠΎΡ€Π½Π΅ рСпозитория Dockerfile со ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΌ содСрТимым

peon.dll это Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΌΠΎΠ΅Π³ΠΎ Solution. Peon пСрСводится ΠΊΠ°ΠΊ Π±Π°Ρ‚Ρ€Π°ΠΊ.

О Ρ‚ΠΎΠΌ ΠΊΠ°ΠΊ Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ с Docker ΠΈ Heroku ΠΌΠΎΠΆΠ½ΠΎ ΠΏΡ€ΠΎΡ‡ΠΈΡ‚Π°Ρ‚ΡŒ здСсь. Но я всС ΠΆΠ΅ ΠΎΠΏΠΈΡˆΡƒ ΠΏΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎΡΡ‚ΡŒ дСйствий.

Π’Π°ΠΌ понадобится ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ Π² Heroku, ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ Heroku CLI.

Π‘ΠΎΠ·Π΄Π°ΠΉΡ‚Π΅ Π½ΠΎΠ²Ρ‹ΠΉ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ Π² heroku ΠΈ свяТитС Π΅Π³ΠΎ с вашим Ρ€Π΅ΠΏΠΎΠ·ΠΈΡ‚ΠΎΡ€ΠΈΠ΅ΠΌ.

Π’Π΅ΠΏΠ΅Ρ€ΡŒ Π½Π°ΠΌ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ Ρ„Π°ΠΉΠ» heroku.yml Π² ΠΏΠ°ΠΏΠΊΠ΅ с ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ΠΎΠΌ. Π£ Π½Π΅Π³ΠΎ Π±ΡƒΠ΄Π΅Ρ‚ Ρ‚Π°ΠΊΠΎΠ΅ содСрТимоС:

Π”Π°Π»ΡŒΡˆΠ΅ Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΠΌ Π½Π΅Π±ΠΎΠ»ΡŒΡˆΡƒΡŽ Ρ‡Π΅Ρ€Π΅Π΄Ρƒ ΠΊΠΎΠΌΠ°Π½Π΄:

ΠœΠΎΠΆΠ΅Ρ‚Π΅ ΠΎΡ‚ΠΊΡ€Ρ‹Ρ‚ΡŒ ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π² Π±Ρ€Π°ΡƒΠ·Π΅Ρ€Π΅ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹:

ПослС Ρ‚ΠΎΠ³ΠΎ ΠΊΠ°ΠΊ ΠΌΡ‹ размСстили ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π² Heroku, Π½ΡƒΠΆΠ½ΠΎ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ Π±Π°Π·Ρƒ Π΄Π°Π½Π½Ρ‹Ρ… Redis для кэша. Как Π²Ρ‹ ΠΏΠΎΠΌΠ½ΠΈΡ‚Π΅ InMemory кэш Π±ΡƒΠ΄Π΅Ρ‚ ΠΈΡΡ‡Π΅Π·Π°Ρ‚ΡŒ послС пСрСзапуска прилоТСния.

УстановитС для нашСго Heroku прилоТСния бСсплатный Π°Π΄Π΄ΠΎΠ½ RedisCloud.

Π‘Ρ‚Ρ€ΠΎΠΊΡƒ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΡ для Redis ΠΌΠΎΠΆΠ½ΠΎ Π±ΡƒΠ΄Π΅Ρ‚ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ Ρ‡Π΅Ρ€Π΅Π· ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΡƒΡŽ окруТСния REDISCLOUD_URL. Она Π±ΡƒΠ΄Π΅Ρ‚ доступна, ΠΊΠΎΠ³Π΄Π° ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π±ΡƒΠ΄Π΅Ρ‚ Π·Π°ΠΏΡƒΡ‰Π΅Π½ΠΎ Π² экосистСмС Heroku.

Нам Π½ΡƒΠΆΠ½ΠΎ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ эту ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΡƒΡŽ Π² ΠΊΠΎΠ΄Π΅ прилоТСния.

Π‘ ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ Π½Π΅Π΅ ΠΌΠΎΠΆΠ½ΠΎ Π·Π°Ρ€Π΅Π³ΠΈΡΡ‚Ρ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Redis Ρ€Π΅Π°Π»ΠΈΠ·Π°Ρ†ΠΈΡŽ для IDistributedCache Π² Startup.

Π’ этом ΠΊΠΎΠ΄Π΅ ΠΌΡ‹ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΡƒΡŽ REDISCLOUD_URL ΠΈΠ· ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Ρ… окруТСния систСмы. ПослС этого ΠΌΡ‹ ΠΈΠ·Π²Π»Π΅ΠΊΠ»ΠΈ адрСс ΠΈ ΠΏΠ°Ρ€ΠΎΠ»ΡŒ Π±Π°Π·Ρ‹ Π΄Π°Π½Π½Ρ‹Ρ… с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ класса RedisUtils. Π•Π³ΠΎ написал я сам:

На этот класс ΠΌΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ простой Unit тСст.

ПослС Ρ‚ΠΎΠ³ΠΎ Ρ‡Ρ‚ΠΎ ΠΌΡ‹ сдСлали, GuildRepository Π±ΡƒΠ΄Π΅Ρ‚ ΡΠΎΡ…Ρ€Π°Π½ΡΡ‚ΡŒ кэш Π½Π΅ Π² ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΈΠ²Π½ΡƒΡŽ ΠΏΠ°ΠΌΡΡ‚ΡŒ, Π° Π² Redis. Нам Π΄Π°ΠΆΠ΅ Π½Π΅ Π½ΡƒΠΆΠ½ΠΎ Π½ΠΈΡ‡Π΅Π³ΠΎ ΠΌΠ΅Π½ΡΡ‚ΡŒ Π² ΠΊΠΎΠ΄Π΅ прилоТСния.

ΠžΠΏΡƒΠ±Π»ΠΈΠΊΡƒΠΉΡ‚Π΅ Π½ΠΎΠ²ΡƒΡŽ Π²Π΅Ρ€ΡΠΈΡŽ прилоТСния.

Π¨Π°Π³ 5. Π Π΅Π°Π»ΠΈΠ·ΡƒΠ΅ΠΌ цикличСскоС Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅

Нам Π½ΡƒΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ Ρ‚Π°ΠΊ Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° состава гильдии происходила рСгулярно, Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€ ΠΊΠ°ΠΆΠ΄Ρ‹Π΅ 15 ΠΌΠΈΠ½ΡƒΡ‚.

Π•ΡΡ‚ΡŒ нСсколько способов это Ρ€Π΅Π°Π»ΠΈΠ·ΠΎΠ²Π°Ρ‚ΡŒ:

Π¨Π°Π³ 6. АвтоматичСская сборка, ΠΏΡ€ΠΎΠ³ΠΎΠ½ тСстов ΠΈ публикация

Π’ΠΎ-ΠΏΠ΅Ρ€Π²Ρ‹Ρ…, Π·Π°ΠΉΠ΄ΠΈΡ‚Π΅ Π² настройки прилоТСния Π² Heroku.

Π’Π°ΠΌ Π΅ΡΡ‚ΡŒ ΠΏΡƒΠ½ΠΊΡ‚ Deploy. ΠŸΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΡ‚Π΅ Ρ‚Π°ΠΌ свой Github Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ ΠΈ Π²ΠΊΠ»ΡŽΡ‡ΠΈΡ‚Π΅ Automatic deploys послС ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΠΊΠΎΠΌΠΌΠΈΡ‚Π° Π² master.

Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. ΠšΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΏΡ€ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π€ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС

ΠŸΠΎΡΡ‚Π°Π²ΡŒΡ‚Π΅ Π³Π°Π»ΠΎΡ‡ΠΊΡƒ Ρƒ ΠΏΡƒΠ½ΠΊΡ‚Π° Wait for CI to pass before deploy. Нам Π½ΡƒΠΆΠ½ΠΎ Ρ‡Ρ‚ΠΎΠ±Ρ‹ Heroku доТидался сборки ΠΈ ΠΏΡ€ΠΎΠ³ΠΎΠ½ΠΊΠΈ тСстов. Если тСсты ΠΏΠΎΠΊΡ€Π°ΡΠ½Π΅ΡŽΡ‚, Ρ‚ΠΎ публикация Π½Π΅ случится.

Π‘Π΄Π΅Π»Π°Π΅ΠΌ сборку ΠΈ ΠΏΡ€ΠΎΠ³ΠΎΠ½ΠΊΡƒ тСстов Π² Github Actions.

Π—Π°ΠΉΠ΄ΠΈΡ‚Π΅ Π² Ρ€Π΅ΠΏΠΎΠ·ΠΈΡ‚ΠΎΡ€ΠΈΠΉ ΠΈ ΠΏΠ΅Ρ€Π΅ΠΉΠ΄ΠΈΡ‚Π΅ Π² ΠΏΡƒΠ½ΠΊΡ‚ Actions. Π’Π΅ΠΏΠ΅Ρ€ΡŒ создайтС Π½ΠΎΠ²Ρ‹ΠΉ workflow Π½Π° основС шаблона .NET

Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. ΠšΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΏΡ€ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π€ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС

Π’ Ρ€Π΅ΠΏΠΎΠ·ΠΈΡ‚ΠΎΡ€ΠΈΠΈ появится Π½ΠΎΠ²Ρ‹ΠΉ Ρ„Π°ΠΉΠ» dotnet.yml. Он описываСт процСсс сборки.

Как Π²ΠΈΠ΄ΠΈΡ‚Π΅ ΠΏΠΎ Π΅Π³ΠΎ содСрТимому, Π·Π°Π΄Π°Π½ΠΈΠ΅ build Π±ΡƒΠ΄Π΅Ρ‚ Π·Π°ΠΏΡƒΡΠΊΠ°Ρ‚ΡŒΡΡ послС ΠΏΡƒΡˆΠ° Π² Π²Π΅Ρ‚ΠΊΡƒ master.

Π‘ΠΎΠ΄Π΅Ρ€ΠΆΠΈΠΌΠΎΠ΅ самого задания нас ΠΏΠΎΠ»Π½ΠΎΡΡ‚ΡŒΡŽ устраиваСт. Если Π²Ρ‹ Π²Ρ‡ΠΈΡ‚Π°Π΅Ρ‚Π΅ΡΡŒ Π² Ρ‚ΠΎ Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΌ происходит, Ρ‚ΠΎ ΡƒΠ²ΠΈΠ΄ΠΈΡ‚Π΅ Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΌ происходит запуск ΠΊΠΎΠΌΠ°Π½Π΄ dotnet build ΠΈ dotnet test.

ΠœΠ΅Π½ΡΡ‚ΡŒ Π² этом Ρ„Π°ΠΉΠ»Π΅ Π½ΠΈΡ‡Π΅Π³ΠΎ Π½Π΅ Π½ΡƒΠΆΠ½ΠΎ, всС ΡƒΠΆΠ΅ Π±ΡƒΠ΄Π΅Ρ‚ Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ ΠΈΠ· ΠΊΠΎΡ€ΠΎΠ±ΠΊΠΈ.

Π—Π°ΠΏΡƒΡˆΡŒΡ‚Π΅ Ρ‡Ρ‚ΠΎ-Π½ΠΈΠ±ΡƒΠ΄ΡŒ Π² master ΠΈ посмотритС Ρ‡Ρ‚ΠΎ Π·Π°Π΄Π°Π½ΠΈΠ΅ запускаСтся. ΠšΡΡ‚Π°Ρ‚ΠΈ, ΠΎΠ½ΠΎ ΡƒΠΆΠ΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π±Ρ‹Π»ΠΎ Π·Π°ΠΏΡƒΡΡ‚ΠΈΡ‚ΡŒΡΡ послС создания Π½ΠΎΠ²ΠΎΠ³ΠΎ workflow.

Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. ΠšΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΏΡ€ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π€ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС

НадСюсь данная ΡΡ‚Π°Ρ‚ΡŒΡ ΠΏΠΎΠ΄ΠΊΠΈΠ½ΡƒΠ»Π° Π²Π°ΠΌ ΠΏΠ°Ρ€Ρƒ Π½ΠΎΠ²Ρ‹Ρ… ΠΈΠ΄Π΅ΠΉ ΠΈ Ρ‚Π΅ΠΌ для изучСния. Бпасибо Π·Π° Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅. Π£Π΄Π°Ρ‡ΠΈ Π²Π°ΠΌ Π² Π²Π°ΡˆΠΈΡ… ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°Ρ…!

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ ΡˆΠ°Ρ€Π΄ Π² дискорд Π±ΠΎΡ‚Π΅?

Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. ΠšΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΏΡ€ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π€ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС

Π¨Π°Ρ€Π΄ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ (Π³ΠΎΡ€ΠΈΠ·ΠΎΠ½Ρ‚Π°Π»ΡŒΠ½ΠΎΠ΅ ΠΏΠ°Ρ€Ρ‚ΠΈΡ†ΠΈΠΎΠ½ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅) β€” это ΠΏΡ€ΠΈΠ½Ρ†ΠΈΠΏ проСктирования Π±Π°Π·Ρ‹ Π΄Π°Π½Π½Ρ‹Ρ…, ΠΏΡ€ΠΈ ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ логичСски нСзависимыС строки Ρ‚Π°Π±Π»ΠΈΡ†Ρ‹ Π±Π°Π·Ρ‹ Π΄Π°Π½Π½Ρ‹Ρ… хранятся Ρ€Π°Π·Π΄Π΅Π»ΡŒΠ½ΠΎ, Π·Π°Ρ€Π°Π½Π΅Π΅ сгруппированныС Π² сСкции, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅, Π² свою ΠΎΡ‡Π΅Ρ€Π΅Π΄ΡŒ, Ρ€Π°Π·ΠΌΠ΅Ρ‰Π°ΡŽΡ‚ΡΡ Π½Π° Ρ€Π°Π·Π½Ρ‹Ρ…, физичСски ΠΈ логичСски нСзависимых сСрвСрах Π±Π°Π·Ρ‹ Π΄Π°Π½Π½Ρ‹Ρ…, ΠΏΡ€ΠΈ этом ΠΎΠ΄ΠΈΠ½ физичСский ΡƒΠ·Π΅Π» кластСра ΠΌΠΎΠΆΠ΅Ρ‚ ΡΠΎΠ΄Π΅Ρ€ΠΆΠ°Ρ‚ΡŒ нСсколько сСрвСров Π±Π°Π· Π΄Π°Π½Π½Ρ‹Ρ….

Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π‘ΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. ΠšΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΏΡ€ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС. Π€ΠΎΡ‚ΠΎ Π§Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ guild Π² дискордС

As bots grow and are added to an increasing number of guilds, some developers may find it necessary to break or split portions of their bots operations into separate logical processes. As such, Discord gateways implement a method of user-controlled guild sharding which allows for splitting events across a number of gateway connections. Guild sharding is entirely user controlled, and requires no state-sharing between separate connections to operate

Π’ Ρ‚ΠΎ врСмя ΠΊΠ°ΠΊ Π±ΠΎΡ‚Ρ‹ растут, ΠΈ растёт количСство сСрвСров, Π½Π΅ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚Ρ‡ΠΈΠΊΠΈ ΠΌΠΎΠ³ΡƒΡ‚ ΠΏΠΎΡΡ‡ΠΈΡ‚Π°Ρ‚ΡŒ Π½ΡƒΠΆΠ½Ρ‹ΠΌ Ρ€Π°Π·Π±Π°Π²Π»ΡΡ‚ΡŒ ΠΈΠ»ΠΈ Ρ€Π°Π·Π΄Π΅Π»ΡΡ‚ΡŒ ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ Π±ΠΎΡ‚ΠΎΠ² Π½Π° нСсколько логичСских процСссов. ΠŸΠΎΡΡ‚ΠΎΠΌΡƒ, Discord gateway (Ρ‚ΠΎ, ΠΊ Ρ‡Π΅ΠΌΡƒ Π±ΠΎΡ‚ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π°Π΅Ρ‚ΡΡ Ρ‡Π΅Ρ€Π΅Π· websockets для ΠΏΡ€ΠΎΡΠ»ΡƒΡˆΠΈΠ²Π°Π½ΠΈΡ событий, ΠΈ контроля статуса) ΠΏΡ€Π΅Π΄ΡΡ‚Π°Π²Π»ΡΡŽΡ‚ ΠΌΠ΅Ρ‚ΠΎΠ΄ раздСлСния сСрвСров ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΌ, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ допускаСт Ρ€Π°Π·Π΄Π΅Π»Π΅Π½ΠΈΠ΅ событий Π½Π° нСсколько ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠΉ ΠΊ gateway. Π Π°Π·Π΄Π΅Π»Π΅Π½ΠΈΠ΅ сСрвСров ΠΏΠΎΠ»Π½ΠΎΡΡ‚ΡŒΡŽ контроллируСтся ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΌ, ΠΈ Π½Π΅ Ρ‚Ρ€Π΅Π±ΡƒΠ΅Ρ‚ ΠΎΠ±Ρ‰Π΅Π³ΠΎ доступа ΠΌΠ΅ΠΆ Ρ€Π°Π·Π½Ρ‹Ρ… ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠΉ для управлСния.

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

Class DiscordGuild

Represents a Discord guild.

Inheritance
Inherited Members
Namespace: DSharpPlus.Entities
Assembly: cs.temp.dll.dll
Syntax

Properties

AfkChannel

Gets the guild’s AFK voice channel.

Declaration
Property Value

AfkTimeout

Gets the guild’s AFK timeout.

Declaration
Property Value

ApplicationId

Gets the application id of this guild if it is bot created.

Declaration
Property Value

ApproximateMemberCount

Gets the approximate number of members in this guild, when using GetGuildAsync(UInt64, Nullable ) and having withCounts set to true.

Declaration
Property Value

ApproximatePresenceCount

Gets the approximate number of presences in this guild, when using GetGuildAsync(UInt64, Nullable ) and having withCounts set to true.

Declaration
Property Value

Banner

Gets this guild’s banner hash, when applicable.

Declaration
Property Value

BannerUrl

Gets this guild’s banner in url form.

Declaration
Property Value

Channels

Gets a dictionary of all the channels associated with this guild. The dictionary’s key is the channel ID.

Declaration
Property Value

CurrentMember

Gets the guild member for current user.

Declaration
Property Value

DefaultMessageNotifications

Gets the guild’s default notification settings.

Declaration
Property Value

Description

Gets the guild description, when applicable.

Declaration
Property Value

DiscoverySplashHash

Gets the guild discovery splash’s hash.

Declaration
Property Value

DiscoverySplashUrl

Gets the guild discovery splash’s url.

Declaration
Property Value

Emojis

Gets a collection of this guild’s emojis.

Declaration
Property Value

EveryoneRole

Gets the @everyone role for this guild.

Declaration
Property Value

ExplicitContentFilter

Gets the guild’s explicit content filter settings.

Declaration
Property Value

Features

Gets a collection of this guild’s features.

Declaration
Property Value

IconHash

Gets the guild icon’s hash.

Declaration
Property Value

IconUrl

Gets the guild icon’s url.

Declaration
Property Value

IsLarge

Gets whether this guild is considered to be a large guild.

Declaration
Property Value

IsNSFW

Gets whether this guild is designated as NSFW.

Declaration
Property Value

IsOwner

Gets whether the current user is the guild’s owner.

Declaration
Property Value

IsUnavailable

Gets whether this guild is unavailable.

Declaration
Property Value

JoinedAt

Gets this guild’s join date.

Declaration
Property Value

MaxMembers

Gets the maximum amount of members allowed for this guild.

Declaration
Property Value

MaxPresences

Gets the maximum amount of presences allowed for this guild.

Declaration
Property Value

MaxVideoChannelUsers

Gets the maximum amount of users allowed per video channel.

Declaration
Property Value

MemberCount

Gets the total number of members in this guild.

Declaration
Property Value

Members

Gets a dictionary of all the members that belong to this guild. The dictionary’s key is the member ID.

Declaration
Property Value

MfaLevel

Gets the required multi-factor authentication level for this guild.

Declaration
Property Value

Gets the guild’s name.

Declaration
Property Value

NsfwLevel

Gets the guild’s nsfw level.

Declaration
Property Value

Owner

Gets the guild’s owner.

Declaration
Property Value

OwnerId

Gets the ID of the guild’s owner.

Declaration
Property Value

Permissions

Gets permissions for the user in the guild (does not include channel overrides)

Declaration
Property Value

PreferredLocale

Gets the preferred locale of this guild.

This is used for server discovery and notices from Discord. Defaults to en-US.

Declaration
Property Value

PremiumSubscriptionCount

Gets the amount of members that boosted this guild.

Declaration
Property Value

PremiumTier

Gets this guild’s premium tier (Nitro boosting).

Declaration
Property Value

PublicUpdatesChannel

Gets the public updates channel (where admins and moderators receive messages from Discord) for this guild.

This is only available if the guild is considered «discoverable».

Declaration
Property Value

Roles

Gets a collection of this guild’s roles.

Declaration
Property Value

RulesChannel

Gets the rules channel for this guild.

This is only available if the guild is considered «discoverable».

Declaration
Property Value

SplashHash

Gets the guild splash’s hash.

Declaration
Property Value

SplashUrl

Gets the guild splash’s url.

Declaration
Property Value

Stickers

Gets a collection of this guild’s stickers.

Declaration
Property Value

SystemChannel

Gets the channel where system messages (such as boost and welcome messages) are sent.

Declaration
Property Value

SystemChannelFlags

Gets the settings for this guild’s system channel.

Declaration
Property Value

VanityUrlCode

Gets the vanity URL code for this guild, when applicable.

Declaration
Property Value

VerificationLevel

Gets the guild’s verification level.

Declaration
Property Value

VoiceRegion

Gets the guild’s voice region.

Declaration
Property Value

VoiceStates

Gets a dictionary of all the voice states for this guilds. The key for this dictionary is the ID of the user the voice state corresponds to.

Declaration
Property Value

WidgetChannel

Gets the widget channel for this guild.

Declaration
Property Value

WidgetEnabled

Gets whether this guild’s widget is enabled.

Declaration
Property Value

Methods

Adds a new member to this guild

Declaration
Parameters

User’s access token (OAuth2)

whether this user has to be muted

whether this user has to be deafened

Returns
Exceptions

Thrown when the client does not have the CreateInstantInvite permission.

Thrown when the user or access_token is not found.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

AttachUserIntegrationAsync(DiscordIntegration)

Attaches an integration from current user to this guild.

Declaration
Parameters

Integration to attach.

Returns

The integration after being attached to the guild.

Exceptions

Thrown when the client does not have the ManageGuild permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

BanMemberAsync(DiscordMember, Int32, String)

Bans a specified member from this guild.

Declaration
Parameters

How many days to remove messages from.

Reason for audit logs.

Returns
Exceptions

Thrown when the client does not have the BanMembers permission.

Thrown when the member does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

BanMemberAsync(UInt64, Int32, String)

Bans a specified user by ID. This doesn’t require the user to be in this guild.

Declaration
Parameters

ID of the user to ban.

How many days to remove messages from.

Reason for audit logs.

Returns
Exceptions

Thrown when the client does not have the BanMembers permission.

Thrown when the member does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

BatchEditApplicationCommandPermissionsAsync(IEnumerable )

Batch edits permissions for a slash command in this guild.

Declaration
Parameters

The list of permissions to use.

Returns

A list of edited permissions.

BulkOverwriteApplicationCommandsAsync(IEnumerable )

Overwrites the existing slash commands in this guild. New commands are automatically created and missing commands are automatically delete

Declaration
Parameters

The list of commands to overwrite with.

Returns

The list of guild commands

CreateApplicationCommandAsync(DiscordApplicationCommand)

Creates or overwrites a slash command in this guild.

Declaration
Parameters

The command to create.

Returns

The created command.

Creates a new channel in this guild.

Declaration
Parameters

Name of the new channel.

Type of the new channel.

Category to put this channel in.

Topic of the channel.

Bitrate of the channel. Applies to voice only.

Maximum number of users in the channel. Applies to voice only.

Permission overwrites for this channel.

Whether the channel is to be flagged as not safe for work. Applies to text only.

Slow mode timeout for users.

Video quality mode of the channel. Applies to voice only.

Reason for audit logs.

Returns

The newly-created channel.

Exceptions

Thrown when the client does not have the ManageChannels permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

Creates a new channel category in this guild.

Declaration
Parameters

Name of the new category.

Permission overwrites for this category.

Reason for audit logs.

Returns

The newly-created channel category.

Exceptions

Thrown when the client does not have the ManageChannels permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

Creates a new custom emoji for this guild.

Declaration
Parameters

Name of the new emoji.

Image to use as the emoji.

Roles for which the emoji will be available. This works only if your application is whitelisted as integration.

Reason for audit log.

Returns

The newly-created emoji.

Exceptions

Thrown when the client does not have the ManageEmojis permission.

Thrown when Discord is unable to process the request.

CreateRoleAsync(String, Nullable

Creates a new role in this guild.

Declaration
Parameters

Permissions for the role.

Color for the role.

Whether the role is to be hoisted.

Whether the role is to be mentionable.

Reason for audit logs.

Returns

The newly-created role.

Exceptions

Thrown when the client does not have the ManageRoles permission.

Thrown when Discord is unable to process the request.

CreateStickerAsync(String, String, String, Stream, StickerFormat)

Creates a sticker in this guild.

Declaration
Parameters

The name of the sticker.

The description of the sticker.

The tags of the sticker.

The image content of the sticker.

The image format of the sticker.

Returns

CreateTemplateAsync(String, String)

Creates a guild template.

Declaration
Parameters

Name of the template.

Description of the template.

Returns

The template created.

Exceptions

Throws when a template already exists for the guild or a null parameter is provided for the name.

Throws when the client does not have the ManageGuild permission.

Thrown when Discord is unable to process the request.

Creates a new text channel in this guild.

Declaration
Parameters

Name of the new channel.

Category to put this channel in.

Topic of the channel.

Permission overwrites for this channel.

Whether the channel is to be flagged as not safe for work.

Slow mode timeout for users.

Reason for audit logs.

Returns

The newly-created channel.

Exceptions

Thrown when the client does not have the ManageChannels permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

Creates a new voice channel in this guild.

Declaration
Parameters

Name of the new channel.

Category to put this channel in.

Bitrate of the channel.

Maximum number of users in the channel.

Permission overwrites for this channel.

Video quality mode of the channel.

Reason for audit logs.

Returns

The newly-created channel.

Exceptions

Thrown when the client does not have the ManageChannels permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

DeleteAllChannelsAsync()

Deletes all channels in this guild.

Note that this is irreversible. Use carefully!

Declaration
Returns

DeleteAsync()

Deletes this guild. Requires the caller to be the owner of the guild.

Declaration
Returns
Exceptions

Thrown when the client is not the owner of the guild.

Thrown when Discord is unable to process the request.

DeleteEmojiAsync(DiscordGuildEmoji, String)

Deletes this guild’s custom emoji.

Declaration
Parameters

Reason for audit log.

Returns
Exceptions

Thrown when the client does not have the ManageEmojis permission.

Thrown when Discord is unable to process the request.

DeleteIntegrationAsync(DiscordIntegration)

Removes an integration from this guild.

Declaration
Parameters

Integration to remove.

Returns
Exceptions

Thrown when the client does not have the ManageGuild permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

DeleteStickerAsync(UInt64)

Declaration
Parameters
Returns

DeleteTemplateAsync(String)

Deletes the template.

Declaration
Parameters

The code of the template to delete.

Returns

The deleted template.

Exceptions

Throws when the template for the code cannot be found

Throws when the client does not have the ManageGuild permission.

Thrown when Discord is unable to process the request.

EditApplicationCommandAsync(UInt64, Action)

Edits a slash command in this guild.

Declaration
Parameters

The id of the command to edit.

Returns

EditApplicationCommandPermissionsAsync(DiscordApplicationCommand, IEnumerable )

Edits permissions for a slash command in this guild.

Declaration
Parameters

The command to edit permissions for.

The list of permissions to use.

Returns

The edited permissions.

Equals(DiscordGuild)

Checks whether this DiscordGuild is equal to another DiscordGuild.

Declaration
Parameters
Returns

Whether the DiscordGuild is equal to this DiscordGuild.

Equals(Object)

Checks whether this DiscordGuild is equal to another object.

Declaration
Parameters

Object to compare to.

Returns

Whether the object is equal to this DiscordGuild.

Overrides

GetAllMembersAsync()

Retrieves a full list of members from Discord. This method will bypass cache.

Declaration
Returns

A collection of all members in this guild.

Exceptions

Thrown when Discord is unable to process the request.

GetApplicationCommandPermissionsAsync(DiscordApplicationCommand)

Gets permissions for a slash command in this guild.

Declaration
Parameters

The command to get them for.

Returns

GetApplicationCommandsAsync()

Gets all the slash commands in this guild.

Declaration
Returns

A list of slash commands in this guild.

GetApplicationCommandsPermissionsAsync()

Gets all slash command permissions in this guild.

Declaration
Returns

A list of permissions.

Gets audit log entries for this guild.

Declaration
Parameters

Maximum number of entries to fetch.

Filter by member responsible.

Filter by action type.

Returns

A collection of requested audit log entries.

Exceptions

Thrown when the client does not have the ViewAuditLog permission.

Thrown when Discord is unable to process the request.

GetBanAsync(DiscordUser)

Gets a ban for a specific user.

Declaration
Parameters

The user to get the ban for.

Returns

The requested ban object.

GetBanAsync(UInt64)

Gets a ban for a specific user.

Declaration
Parameters

The Id of the user to get the ban for.

Returns

The requested ban object.

GetBansAsync()

Gets the bans for this guild.

Declaration
Returns

Collection of bans in this guild.

Exceptions

Thrown when the client does not have the BanMembers permission.

Thrown when Discord is unable to process the request.

GetChannel(UInt64)

Gets a channel from this guild by its ID.

Declaration
Parameters

ID of the channel to get.

Returns
Exceptions

Thrown when Discord is unable to process the request.

GetChannelsAsync()

Gets all the channels this guild has.

Declaration
Returns

A collection of this guild’s channels.

Exceptions

Thrown when Discord is unable to process the request.

GetDefaultChannel()

Gets the default channel for this guild.

Default channel is the first channel current member can see.

Declaration
Returns

This member’s default guild.

Exceptions

Thrown when Discord is unable to process the request.

GetEmojiAsync(UInt64)

Gets this guild’s specified custom emoji.

Declaration
Parameters

ID of the emoji to get.

Returns

The requested custom emoji.

Exceptions

Thrown when Discord is unable to process the request.

GetEmojisAsync()

Gets all of this guild’s custom emojis.

Declaration
Returns

All of this guild’s custom emojis.

Exceptions

Thrown when Discord is unable to process the request.

GetHashCode()

Gets the hash code for this DiscordGuild.

Declaration
Returns

The hash code for this DiscordGuild.

Overrides

GetIntegrationsAsync()

Gets integrations attached to this guild.

Declaration
Returns

Collection of integrations attached to this guild.

Exceptions

Thrown when the client does not have the ManageGuild permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

GetInvite(String)

Gets an invite from this guild from an invite code.

Declaration
Parameters
Returns

An invite, or null if not in cache.

GetInvitesAsync()

Gets all the invites created for all the channels in this guild.

Declaration
Returns

A collection of invites.

Exceptions

Thrown when Discord is unable to process the request.

GetMemberAsync(UInt64)

Gets a member of this guild by their user ID.

Declaration
Parameters

ID of the member to get.

Returns

The requested member.

Exceptions

Thrown when Discord is unable to process the request.

GetMembershipScreeningFormAsync()

Gets this guild’s membership screening form.

Declaration
Returns

This guild’s membership screening form.

Exceptions

Thrown when Discord is unable to process the request.

GetPruneCountAsync(Int32, IEnumerable )

Estimates the number of users to be pruned.

Declaration
Parameters

Minimum number of inactivity days required for users to be pruned. Defaults to 7.

The roles to be included in the prune.

Returns

Number of users that will be pruned.

Exceptions

Thrown when the client does not have the KickMembers permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

GetRole(UInt64)

Gets a role from this guild by its ID.

Declaration
Parameters

ID of the role to get.

Returns
Exceptions

Thrown when Discord is unable to process the request.

GetStickerAsync(UInt64)

Gets a sticker from this guild.

Declaration
Parameters

The id of the sticker.

Returns

GetStickersAsync()

Gets a list of stickers from this guild.

Declaration
Returns

GetTemplatesAsync()

Gets all of this guild’s templates.

Declaration
Returns

All of the guild’s templates.

Exceptions

Throws when the client does not have the ManageGuild permission.

Thrown when Discord is unable to process the request.

GetVanityInviteAsync()

Gets the vanity invite for this guild.

Declaration
Returns

A partial vanity invite.

Exceptions

Thrown when the client does not have the ManageGuild permission.

Thrown when Discord is unable to process the request.

GetWebhooksAsync()

Gets all the webhooks created for all the channels in this guild.

Declaration
Returns

A collection of webhooks this guild has.

Exceptions

Thrown when the client does not have the ManageWebhooks permission.

Thrown when Discord is unable to process the request.

GetWelcomeScreenAsync()

Gets this guild’s welcome screen.

Declaration
Returns

This guild’s welcome screen object.

Exceptions

Thrown when Discord is unable to process the request.

GetWidgetAsync()

Gets the guild’s widget

Declaration
Returns

GetWidgetImage(WidgetType)

Gets this guild’s widget image.

Declaration
Parameters

The format of the widget.

Returns

The URL of the widget image.

GetWidgetSettingsAsync()

Gets the guild’s widget settings

Declaration
Returns

The guild’s widget settings

LeaveAsync()

Declaration
Returns
Exceptions

Thrown when Discord is unable to process the request.

ListVoiceRegionsAsync()

Gets the voice regions for this guild.

Declaration
Returns

Voice regions available for this guild.

Exceptions

Thrown when Discord is unable to process the request.

ModifyAsync(Action )

Modifies this guild.

Declaration
Parameters

Action to perform on this guild..

Returns

The modified guild object.

Exceptions

Thrown when the client does not have the ManageGuild permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

Modifies a this guild’s custom emoji.

Declaration
Parameters

New name for the emoji.

Roles for which the emoji will be available. This works only if your application is whitelisted as integration.

Reason for audit log.

Returns

The modified emoji.

Exceptions

Thrown when the client does not have the ManageEmojis permission.

Thrown when Discord is unable to process the request.

ModifyIntegrationAsync(DiscordIntegration, Int32, Int32, Boolean)

Modifies an integration in this guild.

Declaration
Parameters

Integration to modify.

Number of days after which the integration expires.

Length of grace period which allows for renewing the integration.

Whether emotes should be synced from this integration.

Returns

The modified integration.

Exceptions

Thrown when the client does not have the ManageGuild permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

ModifyMembershipScreeningFormAsync(Action )

Modifies this guild’s membership screening form.

Declaration
Parameters
Returns

The modified screening form.

Exceptions

Thrown when the client doesn’t have the ManageGuild permission, or community is not enabled on this guild.

Thrown when Discord is unable to process the request.

ModifyStickerAsync(UInt64, Action )

Declaration
Parameters
TypeNameDescription
System.UInt64stickerId
Action StickerEditModel >action
Returns

ModifyTemplateAsync(String, String, String)

Modifies the template’s metadata.

Declaration
Parameters

The template’s code.

Name of the template.

Description of the template.

Returns

The template modified.

Exceptions

Throws when the template for the code cannot be found

Throws when the client does not have the ManageGuild permission.

Thrown when Discord is unable to process the request.

ModifyWelcomeScreenAsync(Action )

Modifies this guild’s welcome screen.

Declaration
Parameters
Returns

The modified welcome screen.

Exceptions

Thrown when the client doesn’t have the ManageGuild permission, or community is not enabled on this guild.

Thrown when Discord is unable to process the request.

Modifies the guild’s widget settings

Declaration
Parameters

If the widget is enabled or not

Reason the widget settings were modified

Returns

The newly modified widget settings

Prunes inactive users from this guild.

Declaration
Parameters

Minimum number of inactivity days required for users to be pruned. Defaults to 7.

Whether to return the prune count after this method completes. This is discouraged for larger guilds.

The roles to be included in the prune.

Reason for audit logs.

Returns

Number of users pruned.

Exceptions

Thrown when the client does not have the ManageChannels permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

Requests that Discord send a list of guild members based on the specified arguments. This method will fire the GuildMembersChunked event.

If no arguments aside from presences and nonce are specified, this will request all guild members.

Declaration
Parameters

Filters the returned members based on what the username starts with. Either this or userIds must not be null. The limit must also be greater than 0 if this is specified.

Total number of members to request. This must be greater than 0 if query is specified.

Whether to include the associated with the fetched members.

Whether to limit the request to the specified user ids. Either this or query must not be null.

The unique string to identify the response.

Returns

SearchMembersAsync(String, Nullable )

Searches the current guild for members who’s display name start with the specified name.

Declaration
Parameters

The name to search for.

The maximum amount of members to return. Max 1000. Defaults to 1.

Returns

The members found, if any.

SyncIntegrationAsync(DiscordIntegration)

Forces re-synchronization of an integration for this guild.

Declaration
Parameters

Integration to synchronize.

Returns
Exceptions

Thrown when the client does not have the ManageGuild permission.

Thrown when the guild does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

SyncTemplateAsync(String)

Syncs the template to the current guild’s state.

Declaration
Parameters

The code of the template to sync.

Returns

The template synced.

Exceptions

Throws when the template for the code cannot be found

Throws when the client does not have the ManageGuild permission.

Thrown when Discord is unable to process the request.

ToString()

Returns a string representation of this guild.

Declaration
Returns

String representation of this guild.

Overrides

UnbanMemberAsync(DiscordUser, String)

Unbans a user from this guild.

Declaration
Parameters

Reason for audit logs.

Returns
Exceptions

Thrown when the client does not have the BanMembers permission.

Thrown when the user does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

UnbanMemberAsync(UInt64, String)

Unbans a user by ID.

Declaration
Parameters

ID of the user to unban.

Reason for audit logs.

Returns
Exceptions

Thrown when the client does not have the BanMembers permission.

Thrown when the user does not exist.

Thrown when an invalid parameter was provided.

Thrown when Discord is unable to process the request.

Operators

Equality(DiscordGuild, DiscordGuild)

Gets whether the two DiscordGuild objects are equal.

Declaration
Parameters

First member to compare.

Second member to compare.

Returns

Whether the two members are equal.

Inequality(DiscordGuild, DiscordGuild)

Gets whether the two DiscordGuild objects are not equal.

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ

Π’Π°Ρˆ адрСс email Π½Π΅ Π±ΡƒΠ΄Π΅Ρ‚ ΠΎΠΏΡƒΠ±Π»ΠΈΠΊΠΎΠ²Π°Π½. ΠžΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ поля ΠΏΠΎΠΌΠ΅Ρ‡Π΅Π½Ρ‹ *

TypeDescription
System.Threading.Tasks.Task System.Nullable System.Int32 >>