Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dnns01
root
Commits
b0495711
Commit
b0495711
authored
2 years ago
by
dnns01
Browse files
Options
Downloads
Patches
Plain Diff
Modify bot to be used on different servers.
parent
a6f37ad8
Branches
Branches containing commit
No related tags found
1 merge request
!15
Aktualisierung von News-Branch
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
extensions/voice.py
+28
-0
28 additions, 0 deletions
extensions/voice.py
extensions/welcome.py
+26
-16
26 additions, 16 deletions
extensions/welcome.py
with
54 additions
and
16 deletions
extensions/voice.py
0 → 100644
+
28
−
0
View file @
b0495711
from
discord
import
app_commands
,
Interaction
from
discord.app_commands
import
Choice
from
discord.ext
import
commands
@app_commands.guild_only
()
class
Welcome
(
commands
.
Cog
):
def
__init__
(
self
,
bot
):
self
.
bot
=
bot
@app_commands.command
(
name
=
"
voice
"
,
description
=
"
Sprachkanäle öffnen oder schließen
"
)
@app_commands.describe
(
state
=
"
Wähle, ob die Sprachkanäle geöffnet oder geschlossen werden sollen.
"
)
@app_commands.choices
(
state
=
[
Choice
(
name
=
"
open
"
,
value
=
"
open
"
),
Choice
(
name
=
"
close
"
,
value
=
"
close
"
)])
@app_commands.default_permissions
(
manage_permissions
=
True
)
async
def
cmd_voice
(
self
,
interaction
:
Interaction
,
state
:
Choice
[
str
]):
await
interaction
.
response
.
defer
(
ephemeral
=
True
)
voice_channels
=
interaction
.
guild
.
voice_channels
if
state
.
value
==
"
open
"
:
for
voice_channel
in
voice_channels
:
await
voice_channel
.
edit
(
user_limit
=
0
)
elif
state
.
value
==
"
close
"
:
for
voice_channel
in
voice_channels
:
await
voice_channel
.
edit
(
user_limit
=
1
)
await
interaction
.
edit_original_response
(
content
=
"
Status der Voice Channel erfolgreich geändert.
"
)
async
def
setup
(
bot
:
commands
.
Bot
)
->
None
:
await
bot
.
add_cog
(
Welcome
(
bot
))
This diff is collapsed.
Click to expand it.
extensions/welcome.py
+
26
−
16
View file @
b0495711
import
random
import
re
import
discord
from
discord
import
app_commands
,
Interaction
from
discord.ext
import
commands
...
...
@@ -16,6 +19,9 @@ class Welcome(commands.GroupCog, name="welcome", description="Neue Mitglieder Wi
@app_commands.default_permissions
(
manage_guild
=
True
)
async
def
cmd_update_welcome
(
self
,
interaction
:
Interaction
):
await
interaction
.
response
.
defer
(
ephemeral
=
True
)
if
not
self
.
channel_id
:
await
interaction
.
edit_original_response
(
content
=
"
Diese Funktion steht hier nicht zur Verfügung
"
)
return
channel
=
await
self
.
bot
.
fetch_channel
(
self
.
channel_id
)
message
=
None
if
self
.
message_id
==
0
else
await
channel
.
fetch_message
(
self
.
message_id
)
...
...
@@ -55,26 +61,30 @@ class Welcome(commands.GroupCog, name="welcome", description="Neue Mitglieder Wi
@commands.Cog.listener
()
async
def
on_member_join
(
self
,
member
):
if
member
.
dm_channel
is
None
:
await
member
.
create_dm
()
await
member
.
dm_channel
.
send
(
f
"
Herzlich Willkommen bei der FernUni Föderation! Alle notwendigen Informationen,
"
f
"
die du für den Einstieg brauchst, sowie die wenige Regeln, die aufgestellt
"
f
"
sind, findest du in <#
{
self
.
channel_id
}
>
\n
"
f
"
Du darfst dir außerdem gerne im Channel <#
{
self
.
config
[
'
role_channel
'
]
}
>
"
f
"
die passende Rolle zu deiner Fakultät zuweisen lassen.
\n\n
"
f
"
Falls du Fragen haben solltest, kannst du sie gerne bei der
"
f
"
<#
{
self
.
config
[
'
offtopic_channel
'
]
}
> stellen. Wenn du bei etwas Hilfe vom
"
f
"
Moderationsteam brauchst, schreib mir doch eine private Nachricht, ich werde
"
f
"
sie weiterleiten :writing_hand:.
\n\n
"
f
"
Viel Spaß beim erkunden des Servers und bis bald!
"
)
if
self
.
config
.
get
(
"
dm_message
"
):
if
member
.
dm_channel
is
None
:
await
member
.
create_dm
()
await
member
.
dm_channel
.
send
(
self
.
replace_variables
(
self
.
config
[
"
dm_message
"
]))
if
self
.
config
.
get
(
"
greeting_messages
"
)
and
self
.
config
.
get
(
"
greeting_on_join
"
):
channel
=
await
self
.
bot
.
fetch_channel
(
self
.
config
[
"
greeting_channel
"
])
await
channel
.
send
(
self
.
replace_variables
(
random
.
choice
(
self
.
config
[
"
greeting_messages
"
]).
replace
(
"
{user_id}
"
,
f
"
{
member
.
id
}
"
)))
@commands.Cog.listener
()
async
def
on_member_update
(
self
,
before
,
after
):
if
before
.
pending
!=
after
.
pending
and
not
after
.
pending
:
channel
=
await
self
.
bot
.
fetch_channel
(
self
.
config
[
"
greeting_channel
"
])
await
channel
.
send
(
f
"
Willkommen <@!
{
before
.
id
}
> im Kreise der FernUni-Studierenden :student:
"
)
if
self
.
config
.
get
(
"
greeting_messages
"
)
and
self
.
config
.
get
(
"
greeting_after_verification
"
):
if
before
.
pending
!=
after
.
pending
and
not
after
.
pending
:
channel
=
await
self
.
bot
.
fetch_channel
(
self
.
config
[
"
greeting_channel
"
])
await
channel
.
send
(
self
.
replace_variables
(
random
.
choice
(
self
.
config
[
"
greeting_messages
"
]).
replace
(
"
{user_id}
"
,
f
"
{
before
.
id
}
"
)))
def
replace_variables
(
self
,
message
:
str
)
->
str
:
return
re
.
sub
(
"
\{[a-z_]+}
"
,
self
.
repl
,
message
)
def
repl
(
self
,
matchobj
):
return
f
"
{
self
.
config
.
get
(
matchobj
.
group
(
0
)[
1
:
-
1
])
}
"
async
def
setup
(
bot
:
commands
.
Bot
)
->
None
:
await
bot
.
add_cog
(
Welcome
(
bot
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment