Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions Dedsec/Commands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using System.Timers;

namespace _10minstut.Modules
{

public class Commands : ModuleBase<SocketCommandContext>
{
public static Timer SitTimer;
public static Timer SleepTimer;

public async void sit_straight_reminder(object obj, ElapsedEventArgs e)
{
await ReplyAsync("Sit Straight, you don't want your back to pain when you get old do you?");
}

public async void water_reminder(object obj, ElapsedEventArgs e)
{
await ReplyAsync("Drink water, you don't want kidney stones do you? ");
}

[Command("Sit")]

public async Task sitTimer()
{
await ReplyAsync("Okay,I will remind you in 15 minutes!");
System.Timers.Timer SitTimer = new System.Timers.Timer();
SitTimer.Elapsed += new ElapsedEventHandler(sit_straight_reminder);
SitTimer.Interval = 900000;
SitTimer.Enabled = true;
SitTimer.AutoReset = true;
}

[Command("Water")]

public async Task water()
{
await ReplyAsync("Okay,I will remind you in 30 minutes!");
System.Timers.Timer SleepTimer = new System.Timers.Timer();
SleepTimer.Elapsed += new ElapsedEventHandler(water_reminder);
SleepTimer.Interval = 1800000;
SleepTimer.Enabled = true;
SleepTimer.AutoReset = true;
}


}






}
Binary file added Dedsec/Dedsec.docx
Binary file not shown.
Binary file added Dedsec/Dedsec.pptx
Binary file not shown.
93 changes: 93 additions & 0 deletions Dedsec/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using System;
using System.Reflection;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using Microsoft.Extensions.DependencyInjection;

namespace _10minstut
{
class Program
{
static void Main(string[] args) => new Program().RunBotAsync().GetAwaiter().GetResult();
public String time;
public String time_1;
private DiscordSocketClient _client;
private CommandService _commands;
private IServiceProvider _services;

public async Task RunBotAsync()
{
_client = new DiscordSocketClient();
_commands = new CommandService();
_services = new ServiceCollection()
.AddSingleton(_client)
.AddSingleton(_commands)
.BuildServiceProvider();



string token = "TOKEN FOR THE BOT";

_client.Log += _client_Log;

await RegisterCommandsAsync();

await _client.LoginAsync(TokenType.Bot, token);

await _client.StartAsync();

await Task.Delay(-1);

}

private Task _client_Log(LogMessage arg)
{
Console.WriteLine(arg);
return Task.CompletedTask;
}

public async Task RegisterCommandsAsync()
{
_client.MessageReceived += HandleCommandAsync;
await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services);
}



private async Task HandleCommandAsync(SocketMessage arg)
{
var message = arg as SocketUserMessage;
var context = new SocketCommandContext(_client, message);
if (message.Author.IsBot) return;

int argPos = 0;
if (message.HasStringPrefix("*", ref argPos))
{
var result = await _commands.ExecuteAsync(context, argPos, _services);
if (!result.IsSuccess) Console.WriteLine(result.ErrorReason);
if (result.Error.Equals(CommandError.UnmetPrecondition)) await message.Channel.SendMessageAsync(result.ErrorReason);
}



if (arg.Content.StartsWith("*Sleep"))
{
time = arg.Content.ToLower();
time_1 = time.Replace("*sleep", "");
await arg.Channel.SendMessageAsync("I will remind you in " + time_1 + " minutes!");
Console.WriteLine(time_1);
int time_int = int.Parse(time_1);

time_int *= 60000;
System.Threading.Thread.Sleep(time_int);

await arg.Channel.SendMessageAsync(arg.Author.Mention + " Sleep,Wasn't that your last game?");

}

}

}
}
6 changes: 6 additions & 0 deletions Dedsec/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Asterix - Discord Bot

A simple discord bot which has the following commands:
1.Sit: It will remind you to sit straight while gaming every 15 minutes.
2.Sleep: It will remind you to sleep after a specific amount of time which you can set.
3.Water: It will remind you to drink water while gaming every 30 minutes.