# DNET0001

<table>
<tr>
  <td>TypeName</td>
  <td>GuildAccessAnalyzer</td>
</tr>
<tr>
  <td>CheckId</td>
  <td>DNET0001</td>
</tr>
<tr>
  <td>Category</td>
  <td>API Usage</td>
</tr>
</table>

## Cause

A method identified as a command is accessing `Context.Guild` without the requisite precondition.

## Rule description

The value of `Context.Guild` is `null` if a command is invoked in a DM channel. Attempting to access
guild properties in such a case will result in a `NullReferenceException` at runtime.
This exception is entirely avoidable by using the library's provided preconditions.

## How to fix violations

Add the precondition `[RequireContext(ContextType.Guild)]` to the command or module class.
