Skip to content

Commit

Permalink
Merge pull request #76 from murpii/pr_testing_changes
Browse files Browse the repository at this point in the history
Testing changes
  • Loading branch information
def- authored Feb 2, 2024
2 parents f5049b8 + 4b85a4f commit ef9835f
Show file tree
Hide file tree
Showing 16 changed files with 227 additions and 145 deletions.
106 changes: 106 additions & 0 deletions cogs/bot_messages/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# This cog is primarily used to edit or send messages via bot

import discord
import os
import importlib

from . import dictionary
from discord.ext import commands

CHAN_WELCOME = 1125706766999629854
CHAN_TESTING_INFO = 1201860080463511612
GUILD_DDNET = 252358080522747904
ROLE_ADMIN = 293495272892399616

banners_dir = 'data/banners'


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

async def send_messages(self, ctx: commands.Context, channel_id, messages):
channel = self.bot.get_channel(channel_id)
await ctx.message.add_reaction("👌")
await channel.purge()

description = None

for filename, message_attr in messages:
if filename is not None:
banner_path = os.path.join(banners_dir, filename)
await channel.send(file=discord.File(banner_path, filename=filename))

if message_attr is not None:
description = getattr(dictionary, message_attr, None)

if description is not None:
await channel.send(content=description, allowed_mentions=discord.AllowedMentions(roles=False))


@commands.command(hidden=True)
async def welcome(self, ctx: commands.Context):
if ctx.guild is None or ctx.guild.id != GUILD_DDNET or ROLE_ADMIN not in [role.id for role in ctx.author.roles]:
return

await self.send_messages(ctx, CHAN_WELCOME, [
('welcome_main.png', 'welcome_main'),
('welcome_rules.png', 'welcome_rules'),
('welcome_channels.png', 'welcome_channel_listing'),
('welcome_links.png', 'welcome_ddnet_links'),
('welcome_roles.png', 'welcome_ddnet_roles'),
('welcome_communities.png', 'welcome_community_links')
])

@commands.command(name='tinfo', hidden=True)
async def testing_info(self, ctx: commands.Context):
if ctx.guild is None or ctx.guild.id != GUILD_DDNET or ROLE_ADMIN not in [role.id for role in ctx.author.roles]:
return

await self.send_messages(ctx, CHAN_TESTING_INFO, [
('testing_map_testing.png', None),
('testing_main.png', 'testing_info_header'),
(None, 'testing_info'),
(None, 'testing_channel_access')
])

channel = self.bot.get_channel(CHAN_TESTING_INFO)
reaction_message = None
async for message in channel.history(limit=1):
reaction_message = message
break

await reaction_message.add_reaction("✅")

@commands.command(name='update', hidden=True)
async def update_message(self, ctx, message_id, message_variable):
"""
Usage: $update <message_id> <message_variable>
The message variables can be found in 'cogs/bot_messages/dictionary.py'
"""
if ctx.guild is None or ctx.guild.id != GUILD_DDNET or ROLE_ADMIN not in [role.id for role in ctx.author.roles]:
return

channel_ids = [CHAN_WELCOME, CHAN_TESTING_INFO]
message_id = int(message_id)

var = getattr(dictionary, message_variable, None)
if var is None:
await ctx.reply(f"Message variable not found.")
return

for channel_id in channel_ids:
channel = self.bot.get_channel(channel_id)
try:
message_to_edit = await channel.fetch_message(message_id)
await message_to_edit.edit(content=var)
await ctx.message.add_reaction("👌")
return
except discord.NotFound:
pass

await ctx.send("Invalid message ID. Please provide a valid message ID.")


async def setup(bot):
await bot.add_cog(BotMessages(bot))
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
# Okey this is a bit annoying. In order to have the bot link to the channels and roles, it needs the channel/role ids.

# Channels
WELCOME = 1125706766999629854
ANNOUNCEMENTS = 420565311863914496
MAP_RELEASES = 392853737099624449
RECORDS = 338779500085116938

DEVELOPER = 293493549758939136
BUGS = 757720336274948198

GENERAL = 342454474117218334
SHOWROOM = 295908390956433410
QUESTIONS = 745926398140612678
WIKI = 871738312849752104
OFF_TOPIC = 252358080522747904
MAPPING = 746534464984973323
BOT_CMDS = 500032072455290880

TICKETS = 1124657351442579486
SKIN_INFO = 985554143525601350
SKIN_SUBM = 985717921600929872
TESTING_INFO = 1139589065759531038
TESTING_SUBM = 455392372663123989
WELCOME = 1125706766999629854
ANNOUNCEMENTS = 420565311863914496
MAP_RELEASES = 392853737099624449
RECORDS = 338779500085116938

DEVELOPER = 293493549758939136
BUGS = 757720336274948198

GENERAL = 342454474117218334
SHOWROOM = 295908390956433410
QUESTIONS = 745926398140612678
WIKI = 871738312849752104
OFF_TOPIC = 252358080522747904
MAPPING = 746534464984973323
BOT_CMDS = 500032072455290880

TICKETS = 1124657351442579486
SKIN_INFO = 985554143525601350
SKIN_SUBM = 985717921600929872
TESTING_INFO = 1139589065759531038
TESTING_SUBM = 455392372663123989

# Roles
ADMIN = 293495272892399616
DISCORD_MOD = 737776812234506270
MODERATOR = 252523225810993153
TESTING_LEAD = 746414504488861747
TESTER = 293543421426008064
SKIN_DB_CREW = 390516461741015040
WIKI_CONTRIBUTOR = 1085663898910339072
DEV = 293541515781996568
TOURNAMENT_WINNER = 400715872647249920
TESTING = 455814387169755176

main = """
ADMIN = 293495272892399616
DISCORD_MOD = 737776812234506270
MODERATOR = 252523225810993153
TESTING_LEAD = 746414504488861747
TESTER = 293543421426008064
SKIN_DB_CREW = 390516461741015040
WIKI_CONTRIBUTOR = 1085663898910339072
DEV = 293541515781996568
TOURNAMENT_WINNER = 400715872647249920
TESTING = 455814387169755176

welcome_main = """
Welcome to the official DDraceNetwork Discord Server!
This server serves as the central hub for our vibrant gaming community. Here, you can chat with friends, forge new friendships, and engage in discussions about the game's development.
Expand All @@ -46,9 +46,7 @@
<https://store.steampowered.com/app/412220/DDraceNetwork/>
"""

# Server Rules

rules = f"""
welcome_rules = f"""
`#1` **Be nice** – Don't insult others or engage in lazy negativity towards other people's projects, even as a joke.
`#2` **No NSFW** - No pornography, gore, or anything that could be considered Not Safe For Work.
`#3` **Don't spam** - Includes all types of spamming (messages, emojis, reactions, etc.).
Expand All @@ -58,9 +56,7 @@
`#7` **Don't promote or encourage illegal activities** - Includes botting/cheating.
"""

# Channel Listing

channel_listing = f"""
welcome_channel_listing = f"""
**「INFO CATEGORY」**
<#{WELCOME}> - Welcome! Here you'll find basic information about our server and it's rules!
<#{ANNOUNCEMENTS}> - Any announcements about the game are posted here, including game update notes.
Expand All @@ -81,28 +77,26 @@
<#{BOT_CMDS}> - Game and server stats commands. Type /help for more info.
**「Tickets」**
<#{TICKETS}>- This channel is dedicated to addressing various issues and requests.
<#{TICKETS}>- This channel is dedicated to addressing various issues and requests.
Here's a quick overview of the available categories:
- In-Game Issues
- Report (For in-game issues, like race blockers)
- Rename Requests
- Ban Appeals
- Complaints
- Other (for miscellaneous issues)
- Admin-Mail (for miscellaneous issues)
* Note: No technical support.
**「Skin Submissions」**
<#{SKIN_INFO}> - Skin submission information and rules.
<#{SKIN_SUBM}> - Share and evaluate user-submitted player skins for our official database.
**「Map Testing」**
<#{TESTING_INFO}> - Discover the vital rules map creators must adhere to for their community-created maps to be released in this channel.
<#{TESTING_INFO}> - Discover the vital rules map creators must adhere to for their community-created maps to be released on DDNet in this channel.
<#{TESTING_SUBM}> - This is the channel where creators can upload their map creations for evaluation.
"""

# DDNet Links

ddnet_links = f"""
welcome_ddnet_links = f"""
<https://ddnet.org/> - The official DDNet homepage
<https://forum.ddnet.org/> - Our forums for staff applications, Events, Tutorials and more
<https://wiki.ddnet.org/> - The official DDNet wiki, maintained by: <@!97739437772902400> and <@!846386020756226098>
Expand All @@ -114,9 +108,7 @@
<https://ddnet.org/discord/> OR <https://discord.gg/ddracenetwork>
"""

#Server Roles

ddnet_roles = f"""
welcome_ddnet_roles = f"""
**「DDNet Staff」**
<@&{ADMIN}>: The administrators of DDNet.
<@&{DISCORD_MOD}>: People who keep our Discord server in check.
Expand All @@ -136,9 +128,7 @@
<@&{TESTING}>: - All users can obtain this role in <#{TESTING_INFO}> to access all existing testing channels.
"""

# Community Links

community_links = """
welcome_community_links = """
**「Sites」**
<https://teeworlds.com/> - The official Teeworlds homepage
<https://skins.tw/> - A database containing game assets for both Teeworlds 0.6 and 0.7
Expand All @@ -149,16 +139,51 @@
**「Other Community Servers」**
<https://discord.kog.tw/> - KoG (King of Gores)
<https://discord.gg/utB4Rs3> - FNG, hosted by @noby
<https://discord.com/gbgEs7m6kK> - Unique, a server network that prioritizes maps specifically designed for racing.
<https://discord.gg/gbgEs7m6kK> - Unique, a server network that prioritizes maps specifically designed for racing.
<https://gores.pro/> - Gores Champions Ladder, Competitive Gores Mode
<https://discord.gg/mTVQuEDzzc> - Teeworlds Data, a hub for game asset resources.
<https://discord.gg/YnwAXPB3zj> - Tee Directory, another hub for game asset resources.
<https://discord.gg/fYaBTzY> - Blockworlds
<https://discord.gg/vYtgKvuvTS> - Tee Café, a server for making new friends and simply playing with other people to stay in touch!
<https://discord.gg/NUfhgTe> - iF|City, a city mod server to hang out with friends.
**「Non English Speaking Servers」**
<https://discord.gg/CauG396Waa> - Tee Olympics :flag_fr:
<https://discord.gg/2hdeGVtKdt> - New Generation Clan [NwG] + Community :flag_es:
<https://discord.gg/mpvWdvH> <> [QQ](https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&inviteCode=AI8a2&from=246610&biz=ka#/out) - Teeworlds中文社区 :flag_cn:
<https://discord.gg/mpvWdvH> <> [QQ](https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&inviteCode=AI8a2&from=246610&biz=ka#/out) - Teeworlds中文社区 :flag_cn:
<https://discord.gg/vxgcBSnPPC> - DDRusNetwork :flag_ru:
<https://discord.gg/8SDH76SfXM> - 好問題 𝔾ძωт :flag_tw:
"""
"""

testing_info_header = f"""
# :ddnet: Map release requirements
If you want to have your map released on DDNet, it has to follow the [mapping rules](https://ddnet.org/rules/).
If you're looking for tips on how to improve your submission, be sure to check out our [guidelines](https://ddnet.org/guidelines/).
"""

testing_info = f"""
# 📬 Map submissions
When you are ready to release it, send it in <#{TESTING_SUBM}>.
The message has to contain the map's details as follows: "<map_name>" by <mapper> [<server_type>]
```markdown
# Server Types
👶 Novice
🌸 Moderate
💪 Brutal
💀 Insane
♿ Dummy
👴 Oldschool
⚡ Solo
🏁 Race
🎉 Fun
```
`[Credits: Cøke, Jao, Ravie, Lady Saavik, Pipou, Patiga, Learath, RayB, Soreu, hi_leute_gll, Knight, Oblique. & Index]`
"""

testing_channel_access = f"""
# Accessing testing channels
- To see all channels, add a ✅ reaction to this message
- To see individual testing channels, add a ✅ reaction to the submission message in <#{TESTING_SUBM}> of the map's channel you want to see,
removing the reaction reverts it
- Find archived channels at https://ddnet.org/testlogs/
"""
31 changes: 21 additions & 10 deletions cogs/map_testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
CAT_EVALUATED_MAPS = 462954029643989003
CHAN_ANNOUNCEMENTS = 420565311863914496
CHAN_INFO = 1139589065759531038
THREAD_INFO = 1147560492043350087
CHAN_TESTER = 1203008423726157845
CHAN_SUBMIT_MAPS = 455392372663123989
ROLE_ADMIN = 293495272892399616
ROLE_TESTER = 293543421426008064
Expand Down Expand Up @@ -65,7 +65,7 @@ async def load_map_channels(self):
for category_id in (CAT_MAP_TESTING, CAT_WAITING_MAPPER, CAT_EVALUATED_MAPS):
category = self.bot.get_channel(category_id)
for channel in category.text_channels:
if channel.id in (CHAN_INFO, CHAN_SUBMIT_MAPS):
if channel.id in (CHAN_INFO, CHAN_SUBMIT_MAPS, CHAN_TESTER):
continue

try:
Expand Down Expand Up @@ -296,7 +296,7 @@ async def handle_perms(self, payload: discord.RawReactionActionEvent):
if member is None:
return

if channel.id == THREAD_INFO:
if channel.id == CHAN_INFO:
testing_role = guild.get_role(ROLE_TESTING)
if testing_role in member.roles:
if action == 'REACTION_REMOVE':
Expand Down Expand Up @@ -460,13 +460,24 @@ async def waiting(self, ctx: commands.Context):
async def ready(self, ctx: commands.Context):
"""Ready a map"""
map_channel = self.get_map_channel(ctx.channel.id)

if map_channel.state == MapState.RC:
await map_channel.set_state(state=MapState.READY)
await ctx.reply('The map is now ready to be released!')
else:
await ctx.reply('First ready set. It needs to be tested again by a different tester before fully evaluated.')
await map_channel.set_state(state=MapState.RC)
try:
if map_channel.state == MapState.TESTING and is_staff(ctx.author):
print(ctx.author.roles)
if ROLE_TRIAL_TESTER in [role.id for role in ctx.author.roles]:
msg = 'First ready set by Trial Tester. It needs to be tested again by an official tester before fully evaluated.'
else:
msg = 'First ready set. It needs to be tested again by a different tester before fully evaluated.'
await ctx.reply(msg)
await map_channel.set_state(state=MapState.RC, ready_state_set_by=ctx.author.mention)
elif map_channel.state == MapState.RC and any(
role_id in [role.id for role in ctx.author.roles] for role_id in [ROLE_ADMIN, ROLE_TESTER]):
await ctx.reply('The map is now ready to be released!')
await map_channel.set_state(state=MapState.READY, ready_state_set_by=ctx.author.mention)
else:
if map_channel.state == MapState.WAITING and is_staff(ctx.author):
await ctx.reply('Unable to ready a map in `WAITING`. Reset the map first, then try again.')
except ValueError as error:
await ctx.reply(f"{error}")

@commands.command()
@tester_check()
Expand Down
Loading

0 comments on commit ef9835f

Please sign in to comment.