Skip to content

Commit

Permalink
Basic Bot Configuration
Browse files Browse the repository at this point in the history
- Created main file.

- Created various functions.

- Created a api schema.

- Created a json links file.

- Created basic commands.
  • Loading branch information
SimonePY committed Apr 18, 2023
1 parent 15564cb commit ce82bcf
Show file tree
Hide file tree
Showing 17 changed files with 560 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .idea/Winston.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions commands/about_command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import datetime as date
import logging as log
from typing import Dict

import disnake as snake
from disnake.ext import commands

from functions.file_loader import file_loader

log.getLogger(__name__)
log.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', )

keywords: Dict[str, str] = await file_loader(folder="files", file="keywords", extension="toml")


class About(commands.Cog):
def __init__(self, bot):
self.bot = bot

@commands.slash_command(name="about", description="Return bot information", dm_permission=False, nsfw=False,
auto_sync=True, )
async def about(self, about: snake.ApplicationCommandInteraction):
try:
about_embed = snake.embeds.Embed(title=keywords.get("discord_bot_name", "Winston"),
description=keywords.get("discord_bot_description",
"Winston is a Discord bot for Diplomacy and Strife"),
color=snake.Color.green(), timestamp=date.datetime.now(), )
about_embed.add_field(name="Github",
value=f"[Github Page]({keywords.get('discord_bot_github', 'https://github.com/SimonePY/Winston')})",
inline=True)
about_embed.add_field(name="Wiki",
value=f"[Wiki Page]({keywords.get('discord_bot_wiki', 'https://github.com/SimonePY/Winston/wiki')})",
inline=True)
about_embed.add_field(name="Support Server",
value=f"[Discord Invite]({keywords.get('discord_bot_support', 'https://discord.gg/feBVcXVYhC')})",
inline=True)
about_embed.set_footer(text=keywords.get("discord_bot_version", "v0.0.1"))
await about.response.send_message(embed=about_embed)
except Exception as e:
await about.response.send_message(e)
log.error(f"About Command Exception: {e}")


def setup(bot):
bot.add_cog(About(bot))
32 changes: 32 additions & 0 deletions commands/invite_command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import logging as log
from typing import Dict

import disnake as snake
from disnake.ext import commands

from functions.file_loader import file_loader

log.getLogger(__name__)
log.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', )

keywords: Dict[str, str] = await file_loader(folder="files", file="keywords", extension="toml")


class Invite(commands.Cog):
def __init__(self, bot):
self.bot = bot

@commands.slash_command(name="invite", description="Return a bot invite", dm_permission=False, nsfw=False,
auto_sync=True)
async def invite(self, invite: snake.ApplicationCommandInteraction):
try:
await invite.response.send_message(
f"You can invite the bot by clicking on the application and using the blue bottom.\nYou can also "
f"invite the bot by using this link : [Bot Invite]({keywords.get('discord_bot_invite_link', 'https://discord.com/api/oauth2/authorize?client_id=1097527654971879464&permissions=277025508352&scope=bot%20applications.commands')})")
except Exception as e:
await invite.response.send_message(e)
log.error(f"Invite Command Exception: {e}")


def setup(bot):
bot.add_cog(Invite(bot))
40 changes: 40 additions & 0 deletions commands/links_command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import datetime as date
import json
import logging as log
from typing import Dict

import disnake as snake
from disnake.ext import commands

from functions.file_loader import file_loader

log.getLogger(__name__)
log.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', )

keywords: Dict[str, str] = await file_loader(folder="files", file="keywords", extension="toml")

with open('files/links.json') as f:
names_urls = json.load(f)


class Links(commands.Cog):
def __init__(self, bot):
self.bot = bot

@commands.slash_command(name="links", description="Return useful game links", dm_permission=False, nsfw=False,
auto_sync=True)
async def links(self, links: snake.ApplicationCommandInteraction):
try:
links_embed = snake.Embed(title="Useful Game Links", description="Diplomacy and Strife useful links.",
color=snake.Color.green(), timestamp=date.datetime.now())
for name_url in names_urls['links']:
links_embed.add_field(name=name_url["name"], value=f"[Redirect]({name_url['url']})", inline=True)
links_embed.set_footer(text=keywords.get("discord_bot_version", "v0.0.1"))
await links.response.send_message(embed=links_embed)
except Exception as e:
await links.response.send_message(e)
log.error(f"Links Command Exception: {e}")


def setup(bot):
bot.add_cog(Links(bot))
44 changes: 44 additions & 0 deletions files/links.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"links": [
{
"name": "Homepage",
"url": "https://diplomacyandstrife.com/home"
},
{
"name": "Register Page",
"url": "https://diplomacyandstrife.com/register"
},
{
"name": "Login Page",
"url": "https://diplomacyandstrife.com/login"
},
{
"name": "Rules Page",
"url": "https://diplomacyandstrife.com/rules"
},
{
"name": "Discord Invite",
"url": "https://discord.gg/zPBms9dJhK"
},
{
"name": "Wiki Page",
"url": "https://diplomacy-strife.fandom.com/wiki/Diplomacy_%26_Strife_Wiki"
},
{
"name": "Edit Page",
"url": "https://politicsandwar.com/nation/edit/"
},
{
"name": "Tools Page",
"url": "https://diplomacyandstrife.com/tools"
},
{
"name": "Board Page",
"url": "https://diplomacyandstrife.com/allianceboard"
},
{
"name": "Account Page",
"url": "https://diplomacyandstrife.com/account"
}
]
}
16 changes: 16 additions & 0 deletions files/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Endpoint": [
{
"name": "Nations",
"url": "http://diplomacyandstrifeapi.com/api//nation?APICode="
},
{
"name": "Nation",
"url": "http://diplomacyandstrifeapi.com/api//nation?APICode=&&NationId="
},
{
"name": "Alliances",
"url": "http://diplomacyandstrifeapi.com/api//alliance?APICode="
}
]
}
Loading

0 comments on commit ce82bcf

Please sign in to comment.