-
Notifications
You must be signed in to change notification settings - Fork 0
/
cog.py
56 lines (48 loc) · 1.9 KB
/
cog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""The cog for bf2042 portal"""
import discord
from discord.ext import commands
from discord import app_commands
from . import server_list, player_list
class Bf1Marne(commands.Cog, name="marne"):
"""Battlefield 1 Marne"""
def __init__(self, bot: commands.AutoShardedBot):
self.bot = bot
super().__init__()
group = app_commands.Group(name="marne", description="Battlefield 1 Marne cog")
group.allowed_installs = app_commands.AppInstallationType(guild=True, user=True)
@group.command(
name="serverlist",
description="List all the servers based on a searchterm for Battlefield 1 marne.",
)
@app_commands.user_install()
async def serverlist(
self, interaction: discord.Interaction, servername: str
) -> None:
"""marne servers"""
await interaction.response.defer()
await server_list.main(interaction, servername)
@serverlist.error
async def serverlist_error(self, interaction: discord.Interaction, _error) -> None:
"""Error handling"""
embed = discord.Embed(
color=0xE74C3C, description="Failed to get serverlist for marne"
)
await interaction.followup.send(embed=embed)
@group.command(
name="playerlist",
description="Get playerlist of the server in Battlefield 1 marne.",
)
@app_commands.user_install()
async def playerlist(
self, interaction: discord.Interaction, servername: str
) -> None:
"""marne playerlist"""
await interaction.response.defer()
await player_list.main(interaction, servername)
@playerlist.error
async def playerlist_error(self, interaction: discord.Interaction, _error) -> None:
"""Error handling"""
embed = discord.Embed(
color=0xE74C3C, description="Failed to get playerlist for a server on marne"
)
await interaction.followup.send(embed=embed)