Repository: Pycord-Development/pycord

Issue:
Guild only commands are not registered as guild only.
### Summary

Guild only commands are not registered as guild only

### Reproduction Steps

Have an application command (slash command, context menu command or slash command group) with `guild_only` set to `True` and try running it from DMs

### Minimal Reproducible Code

```python
@commands.slash_command(
        name="test",
        guild_only=True
    )
async def test(self, ctx):
    await ctx.respond('Response')
```


### Expected Results

Not being able to run this command from DMs

### Actual Results

I'm able to run this command in DMs

### Intents

Members

### System Information

- Python v3.10.0-final
- py-cord v2.0.0-candidate
    - py-cord pkg_resources: v2.0.0rc1
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19044


### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

When I checked the return value of `register_commands` in `bot.py` (line 565), I found this:

```
{
	...
	'name': 'test', 
	...
	'dm_permission': True
}
```

I think, `dm_permission` should be `False` for guild only commands, but this is not the case.

I've found this workaround: change parts of `to_dict` methods for SlashCommand (lines 769, 770), SlashCommandGroup (lines 1027, 1028) and ContextMenuCommand (lines 1302, 1303) classes to what's below

```
if self.guild_only is not None:
    as_dict["dm_permission"] = not self.guild_only
```

With the workaround the return value of `register_commands` in `bot.py` (line 565) is this:

```
{
	...
	'name': 'test', 
	...
	'dm_permission': False
}
```

I think this is because Discord API documentation has `dm_permission` as a parameter for creating and editing global commands and not `guild_only`, but Pycord sends a json with `guild_only` and not `dm_permission`, so `guild_only` is ignored.


Discussion:

Resolving patch:
diff --git a/discord/commands/core.py b/discord/commands/core.py
--- a/discord/commands/core.py
+++ b/discord/commands/core.py
@@ -767,7 +767,7 @@ def to_dict(self) -> Dict:
             as_dict["type"] = SlashCommandOptionType.sub_command.value
 
         if self.guild_only is not None:
-            as_dict["guild_only"] = self.guild_only
+            as_dict["dm_permission"] = not self.guild_only
 
         if self.default_member_permissions is not None:
             as_dict["default_member_permissions"] = self.default_member_permissions.value
@@ -1025,7 +1025,7 @@ def to_dict(self) -> Dict:
             as_dict["type"] = self.input_type.value
 
         if self.guild_only is not None:
-            as_dict["guild_only"] = self.guild_only
+            as_dict["dm_permission"] = not self.guild_only
 
         if self.default_member_permissions is not None:
             as_dict["default_member_permissions"] = self.default_member_permissions.value
@@ -1300,7 +1300,7 @@ def to_dict(self) -> Dict[str, Union[str, int]]:
         }
 
         if self.guild_only is not None:
-            as_dict["guild_only"] = self.guild_only
+            as_dict["dm_permission"] = not self.guild_only
 
         if self.default_member_permissions is not None:
             as_dict["default_member_permissions"] = self.default_member_permissions.value


Test patch: